mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-26 05:01:06 -08:00
More cleanup
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
8baef8d7c5
commit
96d1aea54a
|
@ -7,10 +7,10 @@ use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\ImageUploadRequest;
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
use App\Models\Accessory;
|
use App\Models\Accessory;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Redirect;
|
use \Illuminate\Contracts\View\View;
|
||||||
|
use \Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/** This controller handles all actions related to Accessories for
|
/** This controller handles all actions related to Accessories for
|
||||||
|
@ -27,13 +27,10 @@ class AccessoriesController extends Controller
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @see AccessoriesController::getDatatable() method that generates the JSON response
|
* @see AccessoriesController::getDatatable() method that generates the JSON response
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index() : View
|
||||||
{
|
{
|
||||||
$this->authorize('index', Accessory::class);
|
$this->authorize('index', Accessory::class);
|
||||||
|
|
||||||
return view('accessories/index');
|
return view('accessories/index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,10 +38,8 @@ class AccessoriesController extends Controller
|
||||||
* Returns a view with a form to create a new Accessory.
|
* Returns a view with a form to create a new Accessory.
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create() : View
|
||||||
{
|
{
|
||||||
$this->authorize('create', Accessory::class);
|
$this->authorize('create', Accessory::class);
|
||||||
$category_type = 'accessory';
|
$category_type = 'accessory';
|
||||||
|
@ -58,10 +53,8 @@ class AccessoriesController extends Controller
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param ImageUploadRequest $request
|
* @param ImageUploadRequest $request
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function store(ImageUploadRequest $request)
|
public function store(ImageUploadRequest $request) : RedirectResponse
|
||||||
{
|
{
|
||||||
$this->authorize(Accessory::class);
|
$this->authorize(Accessory::class);
|
||||||
|
|
||||||
|
@ -100,15 +93,12 @@ class AccessoriesController extends Controller
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param int $accessoryId
|
* @param int $accessoryId
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function edit($accessoryId = null)
|
public function edit($accessoryId = null) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($item = Accessory::find($accessoryId)) {
|
if ($item = Accessory::find($accessoryId)) {
|
||||||
$this->authorize($item);
|
$this->authorize($item);
|
||||||
|
|
||||||
return view('accessories/edit', compact('item'))->with('category_type', 'accessory');
|
return view('accessories/edit', compact('item'))->with('category_type', 'accessory');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,9 +112,8 @@ class AccessoriesController extends Controller
|
||||||
* @author [J. Vinsmoke]
|
* @author [J. Vinsmoke]
|
||||||
* @param int $accessoryId
|
* @param int $accessoryId
|
||||||
* @since [v6.0]
|
* @since [v6.0]
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
*/
|
*/
|
||||||
public function getClone($accessoryId = null)
|
public function getClone($accessoryId = null) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('create', Accessory::class);
|
$this->authorize('create', Accessory::class);
|
||||||
|
@ -151,10 +140,8 @@ class AccessoriesController extends Controller
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param ImageUploadRequest $request
|
* @param ImageUploadRequest $request
|
||||||
* @param int $accessoryId
|
* @param int $accessoryId
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function update(ImageUploadRequest $request, $accessoryId = null)
|
public function update(ImageUploadRequest $request, $accessoryId = null) : RedirectResponse
|
||||||
{
|
{
|
||||||
if ($accessory = Accessory::withCount('users as users_count')->find($accessoryId)) {
|
if ($accessory = Accessory::withCount('users as users_count')->find($accessoryId)) {
|
||||||
|
|
||||||
|
@ -205,10 +192,8 @@ class AccessoriesController extends Controller
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param int $accessoryId
|
* @param int $accessoryId
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function destroy($accessoryId)
|
public function destroy($accessoryId) : RedirectResponse
|
||||||
{
|
{
|
||||||
if (is_null($accessory = Accessory::find($accessoryId))) {
|
if (is_null($accessory = Accessory::find($accessoryId))) {
|
||||||
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
|
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
|
||||||
|
@ -243,10 +228,8 @@ class AccessoriesController extends Controller
|
||||||
* @param int $accessoryID
|
* @param int $accessoryID
|
||||||
* @see AccessoriesController::getDataView() method that generates the JSON response
|
* @see AccessoriesController::getDataView() method that generates the JSON response
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function show($accessoryID = null)
|
public function show($accessoryID = null) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
$accessory = Accessory::withCount('users as users_count')->find($accessoryID);
|
$accessory = Accessory::withCount('users as users_count')->find($accessoryID);
|
||||||
$this->authorize('view', $accessory);
|
$this->authorize('view', $accessory);
|
||||||
|
|
|
@ -7,10 +7,11 @@ use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\UploadFileRequest;
|
use App\Http\Requests\UploadFileRequest;
|
||||||
use App\Models\Actionlog;
|
use App\Models\Actionlog;
|
||||||
use App\Models\Accessory;
|
use App\Models\Accessory;
|
||||||
use Illuminate\Support\Facades\Response;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Symfony\Accessory\HttpFoundation\JsonResponse;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use \Illuminate\Contracts\View\View;
|
||||||
|
use \Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Support\Facades\Response;
|
||||||
|
|
||||||
class AccessoriesFilesController extends Controller
|
class AccessoriesFilesController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -19,20 +20,17 @@ class AccessoriesFilesController extends Controller
|
||||||
*
|
*
|
||||||
* @param UploadFileRequest $request
|
* @param UploadFileRequest $request
|
||||||
* @param int $accessoryId
|
* @param int $accessoryId
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*@author [A. Gianotto] [<snipe@snipe.net>]
|
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @todo Switch to using the AssetFileRequest form request validator.
|
* @todo Switch to using the AssetFileRequest form request validator.
|
||||||
*/
|
*/
|
||||||
public function store(UploadFileRequest $request, $accessoryId = null)
|
public function store(UploadFileRequest $request, $accessoryId = null) : RedirectResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
if (config('app.lock_passwords')) {
|
if (config('app.lock_passwords')) {
|
||||||
return redirect()->route('accessories.show', ['accessory'=>$accessoryId])->with('error', trans('general.feature_disabled'));
|
return redirect()->route('accessories.show', ['accessory'=>$accessoryId])->with('error', trans('general.feature_disabled'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$accessory = Accessory::find($accessoryId);
|
$accessory = Accessory::find($accessoryId);
|
||||||
|
|
||||||
if (isset($accessory->id)) {
|
if (isset($accessory->id)) {
|
||||||
|
@ -69,10 +67,8 @@ class AccessoriesFilesController extends Controller
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @param int $accessoryId
|
* @param int $accessoryId
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function destroy($accessoryId = null, $fileId = null)
|
public function destroy($accessoryId = null, $fileId = null) : RedirectResponse
|
||||||
{
|
{
|
||||||
$accessory = Accessory::find($accessoryId);
|
$accessory = Accessory::find($accessoryId);
|
||||||
|
|
||||||
|
@ -107,10 +103,8 @@ class AccessoriesFilesController extends Controller
|
||||||
* @since [v1.4]
|
* @since [v1.4]
|
||||||
* @param int $accessoryId
|
* @param int $accessoryId
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @return \Symfony\Accessory\HttpFoundation\Response
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function show($accessoryId = null, $fileId = null, $download = true)
|
public function show($accessoryId = null, $fileId = null, $download = true) : View | RedirectResponse | Response
|
||||||
{
|
{
|
||||||
|
|
||||||
Log::debug('Private filesystem is: '.config('filesystems.default'));
|
Log::debug('Private filesystem is: '.config('filesystems.default'));
|
||||||
|
|
|
@ -7,8 +7,9 @@ use App\Http\Controllers\Controller;
|
||||||
use App\Models\Accessory;
|
use App\Models\Accessory;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use \Illuminate\Contracts\View\View;
|
||||||
|
use \Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class AccessoryCheckinController extends Controller
|
class AccessoryCheckinController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -19,15 +20,10 @@ class AccessoryCheckinController extends Controller
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param int $accessoryUserId
|
* @param int $accessoryUserId
|
||||||
* @param string $backto
|
* @param string $backto
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @internal param int $accessoryId
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function create($accessoryUserId = null, $backto = null)
|
public function create($accessoryUserId = null, $backto = null) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
// Check if the accessory exists
|
|
||||||
if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) {
|
if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) {
|
||||||
// Redirect to the accessory management page with error
|
|
||||||
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
|
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,15 +40,10 @@ class AccessoryCheckinController extends Controller
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param null $accessoryUserId
|
* @param null $accessoryUserId
|
||||||
* @param string $backto
|
* @param string $backto
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
* @internal param int $accessoryId
|
|
||||||
*/
|
*/
|
||||||
public function store(Request $request, $accessoryUserId = null, $backto = null)
|
public function store(Request $request, $accessoryUserId = null, $backto = null) : RedirectResponse
|
||||||
{
|
{
|
||||||
// Check if the accessory exists
|
|
||||||
if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) {
|
if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) {
|
||||||
// Redirect to the accessory management page with error
|
|
||||||
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
|
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@ use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Input;
|
use \Illuminate\Contracts\View\View;
|
||||||
|
use \Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class AccessoryCheckoutController extends Controller
|
class AccessoryCheckoutController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -19,10 +20,8 @@ class AccessoryCheckoutController extends Controller
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function create($id)
|
public function create($id) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($accessory = Accessory::withCount('users as users_count')->find($id)) {
|
if ($accessory = Accessory::withCount('users as users_count')->find($id)) {
|
||||||
|
@ -59,10 +58,8 @@ class AccessoryCheckoutController extends Controller
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param int $accessoryId
|
* @param int $accessoryId
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function store(Request $request, $accessoryId)
|
public function store(Request $request, $accessoryId) : RedirectResponse
|
||||||
{
|
{
|
||||||
// Check if the accessory exists
|
// Check if the accessory exists
|
||||||
if (is_null($accessory = Accessory::withCount('users as users_count')->find($accessoryId))) {
|
if (is_null($accessory = Accessory::withCount('users as users_count')->find($accessoryId))) {
|
||||||
|
|
|
@ -28,20 +28,18 @@ use Illuminate\Support\Str;
|
||||||
use App\Http\Controllers\SettingsController;
|
use App\Http\Controllers\SettingsController;
|
||||||
use Barryvdh\DomPDF\Facade\Pdf;
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use phpDocumentor\Reflection\Types\Compound;
|
use \Illuminate\Contracts\View\View;
|
||||||
|
use \Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class AcceptanceController extends Controller
|
class AcceptanceController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Show a listing of pending checkout acceptances for the current user
|
* Show a listing of pending checkout acceptances for the current user
|
||||||
*
|
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index() : View
|
||||||
{
|
{
|
||||||
$acceptances = CheckoutAcceptance::forUser(auth()->user())->pending()->get();
|
$acceptances = CheckoutAcceptance::forUser(auth()->user())->pending()->get();
|
||||||
|
|
||||||
return view('account/accept.index', compact('acceptances'));
|
return view('account/accept.index', compact('acceptances'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,9 +47,8 @@ class AcceptanceController extends Controller
|
||||||
* Shows a form to either accept or decline the checkout acceptance
|
* Shows a form to either accept or decline the checkout acceptance
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function create($id)
|
public function create($id) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
$acceptance = CheckoutAcceptance::find($id);
|
$acceptance = CheckoutAcceptance::find($id);
|
||||||
|
|
||||||
|
@ -80,9 +77,8 @@ class AcceptanceController extends Controller
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
*/
|
*/
|
||||||
public function store(Request $request, $id)
|
public function store(Request $request, $id) : RedirectResponse
|
||||||
{
|
{
|
||||||
$acceptance = CheckoutAcceptance::find($id);
|
$acceptance = CheckoutAcceptance::find($id);
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Models\Actionlog;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Support\Facades\Response;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use \Illuminate\Http\Response;
|
||||||
class ActionlogController extends Controller
|
class ActionlogController extends Controller
|
||||||
{
|
{
|
||||||
public function displaySig($filename)
|
public function displaySig($filename) : RedirectResponse | Response | bool
|
||||||
{
|
{
|
||||||
// PHP doesn't let you handle file not found errors well with
|
// PHP doesn't let you handle file not found errors well with
|
||||||
// file_get_contents, so we set the error reporting for just this class
|
// file_get_contents, so we set the error reporting for just this class
|
||||||
|
@ -17,6 +17,7 @@ class ActionlogController extends Controller
|
||||||
|
|
||||||
$disk = config('filesystems.default');
|
$disk = config('filesystems.default');
|
||||||
switch (config("filesystems.disks.$disk.driver")) {
|
switch (config("filesystems.disks.$disk.driver")) {
|
||||||
|
|
||||||
case 's3':
|
case 's3':
|
||||||
$file = 'private_uploads/signatures/'.$filename;
|
$file = 'private_uploads/signatures/'.$filename;
|
||||||
return redirect()->away(Storage::disk($disk)->temporaryUrl($file, now()->addMinutes(5)));
|
return redirect()->away(Storage::disk($disk)->temporaryUrl($file, now()->addMinutes(5)));
|
||||||
|
@ -30,15 +31,15 @@ class ActionlogController extends Controller
|
||||||
Log::warning('File '.$file.' not found');
|
Log::warning('File '.$file.' not found');
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return Response::make($contents)->header('Content-Type', $filetype);
|
return response()->make($contents)->header('Content-Type', $filetype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStoredEula($filename){
|
public function getStoredEula($filename) : Response
|
||||||
|
{
|
||||||
$this->authorize('view', \App\Models\Asset::class);
|
$this->authorize('view', \App\Models\Asset::class);
|
||||||
$file = config('app.private_uploads').'/eula-pdfs/'.$filename;
|
$file = config('app.private_uploads').'/eula-pdfs/'.$filename;
|
||||||
|
return response()->download($file);
|
||||||
return Response::download($file);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,10 @@ use App\Models\Asset;
|
||||||
use App\Models\CheckoutAcceptance;
|
use App\Models\CheckoutAcceptance;
|
||||||
use App\Models\LicenseSeat;
|
use App\Models\LicenseSeat;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\Facades\View;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use \Illuminate\Contracts\View\View;
|
||||||
|
use \Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class AssetCheckinController extends Controller
|
class AssetCheckinController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -26,11 +26,9 @@ class AssetCheckinController extends Controller
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param int $assetId
|
* @param int $assetId
|
||||||
* @param string $backto
|
* @param string $backto
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
*/
|
*/
|
||||||
public function create($assetId, $backto = null)
|
public function create($assetId, $backto = null) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
// Check if the asset exists
|
// Check if the asset exists
|
||||||
if (is_null($asset = Asset::find($assetId))) {
|
if (is_null($asset = Asset::find($assetId))) {
|
||||||
|
@ -60,11 +58,9 @@ class AssetCheckinController extends Controller
|
||||||
* @param AssetCheckinRequest $request
|
* @param AssetCheckinRequest $request
|
||||||
* @param int $assetId
|
* @param int $assetId
|
||||||
* @param null $backto
|
* @param null $backto
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
*/
|
*/
|
||||||
public function store(AssetCheckinRequest $request, $assetId = null, $backto = null)
|
public function store(AssetCheckinRequest $request, $assetId = null, $backto = null) : RedirectResponse
|
||||||
{
|
{
|
||||||
// Check if the asset exists
|
// Check if the asset exists
|
||||||
if (is_null($asset = Asset::find($assetId))) {
|
if (is_null($asset = Asset::find($assetId))) {
|
||||||
|
|
|
@ -9,8 +9,9 @@ use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\AssetCheckoutRequest;
|
use App\Http\Requests\AssetCheckoutRequest;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
|
use \Illuminate\Contracts\View\View;
|
||||||
|
use \Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class AssetCheckoutController extends Controller
|
class AssetCheckoutController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -25,7 +26,7 @@ class AssetCheckoutController extends Controller
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function create($assetId)
|
public function create($assetId) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
// Check if the asset exists
|
// Check if the asset exists
|
||||||
if (is_null($asset = Asset::with('company')->find(e($assetId)))) {
|
if (is_null($asset = Asset::with('company')->find(e($assetId)))) {
|
||||||
|
@ -53,11 +54,9 @@ class AssetCheckoutController extends Controller
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param AssetCheckoutRequest $request
|
* @param AssetCheckoutRequest $request
|
||||||
* @param int $assetId
|
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
*/
|
*/
|
||||||
public function store(AssetCheckoutRequest $request, $assetId)
|
public function store(AssetCheckoutRequest $request, $assetId) : RedirectResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Check if the asset exists
|
// Check if the asset exists
|
||||||
|
|
|
@ -7,8 +7,11 @@ use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\UploadFileRequest;
|
use App\Http\Requests\UploadFileRequest;
|
||||||
use App\Models\Actionlog;
|
use App\Models\Actionlog;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
use Illuminate\Support\Facades\Response;
|
use \Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use \Illuminate\Contracts\View\View;
|
||||||
|
use \Illuminate\Http\RedirectResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
class AssetFilesController extends Controller
|
class AssetFilesController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -22,7 +25,7 @@ class AssetFilesController extends Controller
|
||||||
*@since [v1.0]
|
*@since [v1.0]
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
*/
|
*/
|
||||||
public function store(UploadFileRequest $request, $assetId = null)
|
public function store(UploadFileRequest $request, $assetId = null) : RedirectResponse
|
||||||
{
|
{
|
||||||
if (! $asset = Asset::find($assetId)) {
|
if (! $asset = Asset::find($assetId)) {
|
||||||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
|
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||||
|
@ -54,10 +57,8 @@ class AssetFilesController extends Controller
|
||||||
* @param int $assetId
|
* @param int $assetId
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function show($assetId = null, $fileId = null)
|
public function show($assetId = null, $fileId = null) : View | RedirectResponse | Response | StreamedResponse
|
||||||
{
|
{
|
||||||
$asset = Asset::find($assetId);
|
$asset = Asset::find($assetId);
|
||||||
// the asset is valid
|
// the asset is valid
|
||||||
|
@ -105,10 +106,8 @@ class AssetFilesController extends Controller
|
||||||
* @param int $assetId
|
* @param int $assetId
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function destroy($assetId = null, $fileId = null)
|
public function destroy($assetId = null, $fileId = null) : RedirectResponse
|
||||||
{
|
{
|
||||||
$asset = Asset::find($assetId);
|
$asset = Asset::find($assetId);
|
||||||
$this->authorize('update', $asset);
|
$this->authorize('update', $asset);
|
||||||
|
@ -131,7 +130,6 @@ class AssetFilesController extends Controller
|
||||||
->with('success', trans('admin/hardware/message.deletefile.success'));
|
->with('success', trans('admin/hardware/message.deletefile.success'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to the hardware management page
|
|
||||||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
|
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,15 @@ use Illuminate\Support\Facades\Auth;
|
||||||
use App\View\Label;
|
use App\View\Label;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\View;
|
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
use Illuminate\Support\Facades\Redirect;
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class controls all actions related to assets for
|
* This class controls all actions related to assets for
|
||||||
|
@ -55,10 +56,8 @@ class AssetsController extends Controller
|
||||||
* @see AssetController::getDatatable() method that generates the JSON response
|
* @see AssetController::getDatatable() method that generates the JSON response
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request) : View
|
||||||
{
|
{
|
||||||
$this->authorize('index', Asset::class);
|
$this->authorize('index', Asset::class);
|
||||||
$company = Company::find($request->input('company_id'));
|
$company = Company::find($request->input('company_id'));
|
||||||
|
@ -72,13 +71,12 @@ class AssetsController extends Controller
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @internal param int $model_id
|
* @internal param int $model_id
|
||||||
*/
|
*/
|
||||||
public function create(Request $request)
|
public function create(Request $request) : View
|
||||||
{
|
{
|
||||||
$this->authorize('create', Asset::class);
|
$this->authorize('create', Asset::class);
|
||||||
$view = View::make('hardware/edit')
|
$view = view('hardware/edit')
|
||||||
->with('statuslabel_list', Helper::statusLabelList())
|
->with('statuslabel_list', Helper::statusLabelList())
|
||||||
->with('item', new Asset)
|
->with('item', new Asset)
|
||||||
->with('statuslabel_types', Helper::statusTypeList());
|
->with('statuslabel_types', Helper::statusTypeList());
|
||||||
|
@ -96,9 +94,8 @@ class AssetsController extends Controller
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
*/
|
*/
|
||||||
public function store(ImageUploadRequest $request)
|
public function store(ImageUploadRequest $request) : RedirectResponse
|
||||||
{
|
{
|
||||||
$this->authorize(Asset::class);
|
$this->authorize(Asset::class);
|
||||||
|
|
||||||
|
@ -207,7 +204,6 @@ class AssetsController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($success) {
|
if ($success) {
|
||||||
Log::debug(e($asset->asset_tag));
|
|
||||||
return redirect()->route('hardware.index')
|
return redirect()->route('hardware.index')
|
||||||
->with('success-unescaped', trans('admin/hardware/message.create.success_linked', ['link' => route('hardware.show', $asset->id), 'id', 'tag' => e($asset->asset_tag)]));
|
->with('success-unescaped', trans('admin/hardware/message.create.success_linked', ['link' => route('hardware.show', $asset->id), 'id', 'tag' => e($asset->asset_tag)]));
|
||||||
|
|
||||||
|
@ -217,11 +213,6 @@ class AssetsController extends Controller
|
||||||
return redirect()->back()->withInput()->withErrors($asset->getErrors());
|
return redirect()->back()->withInput()->withErrors($asset->getErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOptionCookie(Request $request){
|
|
||||||
$value = $request->cookie('optional_info');
|
|
||||||
echo $value;
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a view that presents a form to edit an existing asset.
|
* Returns a view that presents a form to edit an existing asset.
|
||||||
|
@ -231,7 +222,7 @@ class AssetsController extends Controller
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit($assetId = null)
|
public function edit($assetId = null) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
if (! $item = Asset::find($assetId)) {
|
if (! $item = Asset::find($assetId)) {
|
||||||
// Redirect to the asset management page with error
|
// Redirect to the asset management page with error
|
||||||
|
@ -254,7 +245,7 @@ class AssetsController extends Controller
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function show($assetId = null)
|
public function show($assetId = null) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
$asset = Asset::withTrashed()->find($assetId);
|
$asset = Asset::withTrashed()->find($assetId);
|
||||||
$this->authorize('view', $asset);
|
$this->authorize('view', $asset);
|
||||||
|
@ -292,11 +283,10 @@ class AssetsController extends Controller
|
||||||
* Validate and process asset edit form.
|
* Validate and process asset edit form.
|
||||||
*
|
*
|
||||||
* @param int $assetId
|
* @param int $assetId
|
||||||
* @return \Illuminate\Http\RedirectResponse|Redirect
|
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
*/
|
*/
|
||||||
public function update(ImageUploadRequest $request, $assetId = null)
|
public function update(ImageUploadRequest $request, $assetId = null) : RedirectResponse
|
||||||
{
|
{
|
||||||
// Check if the asset exists
|
// Check if the asset exists
|
||||||
if (! $asset = Asset::find($assetId)) {
|
if (! $asset = Asset::find($assetId)) {
|
||||||
|
@ -411,9 +401,8 @@ class AssetsController extends Controller
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param int $assetId
|
* @param int $assetId
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
*/
|
*/
|
||||||
public function destroy($assetId)
|
public function destroy($assetId) : RedirectResponse
|
||||||
{
|
{
|
||||||
// Check if the asset exists
|
// Check if the asset exists
|
||||||
if (is_null($asset = Asset::find($assetId))) {
|
if (is_null($asset = Asset::find($assetId))) {
|
||||||
|
@ -445,9 +434,8 @@ class AssetsController extends Controller
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @since [v3.0]
|
* @since [v3.0]
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
*/
|
*/
|
||||||
public function getAssetBySerial(Request $request)
|
public function getAssetBySerial(Request $request) : RedirectResponse
|
||||||
{
|
{
|
||||||
$topsearch = ($request->get('topsearch')=="true");
|
$topsearch = ($request->get('topsearch')=="true");
|
||||||
|
|
||||||
|
@ -465,7 +453,7 @@ class AssetsController extends Controller
|
||||||
* @since [v3.0]
|
* @since [v3.0]
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function getAssetByTag(Request $request, $tag=null)
|
public function getAssetByTag(Request $request, $tag=null) : RedirectResponse
|
||||||
{
|
{
|
||||||
$tag = $tag ? $tag : $request->get('assetTag');
|
$tag = $tag ? $tag : $request->get('assetTag');
|
||||||
$topsearch = ($request->get('topsearch') == 'true');
|
$topsearch = ($request->get('topsearch') == 'true');
|
||||||
|
@ -485,9 +473,8 @@ class AssetsController extends Controller
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param int $assetId
|
* @param int $assetId
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return Response
|
|
||||||
*/
|
*/
|
||||||
public function getQrCode($assetId = null)
|
public function getQrCode($assetId = null) : Response
|
||||||
{
|
{
|
||||||
$settings = Setting::getSettings();
|
$settings = Setting::getSettings();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Assets;
|
namespace App\Http\Controllers\Assets;
|
||||||
|
|
||||||
use App\Models\Actionlog;
|
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Http\Controllers\CheckInOutRequest;
|
use App\Http\Controllers\CheckInOutRequest;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
@ -12,14 +11,15 @@ use App\Models\Statuslabel;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\View\Label;
|
use App\View\Label;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
use App\Http\Requests\AssetCheckoutRequest;
|
use App\Http\Requests\AssetCheckoutRequest;
|
||||||
use App\Models\CustomField;
|
use App\Models\CustomField;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
|
||||||
class BulkAssetsController extends Controller
|
class BulkAssetsController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -36,12 +36,10 @@ class BulkAssetsController extends Controller
|
||||||
* action would make a lot more sense here and make things a lot more clear.
|
* action would make a lot more sense here and make things a lot more clear.
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @internal param int $assetId
|
* @internal param int $assetId
|
||||||
* @since [v2.0]
|
* @since [v2.0]
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
*/
|
*/
|
||||||
public function edit(Request $request)
|
public function edit(Request $request) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
$this->authorize('view', Asset::class);
|
$this->authorize('view', Asset::class);
|
||||||
|
|
||||||
|
@ -194,7 +192,7 @@ class BulkAssetsController extends Controller
|
||||||
* @internal param array $assets
|
* @internal param array $assets
|
||||||
* @since [v2.0]
|
* @since [v2.0]
|
||||||
*/
|
*/
|
||||||
public function update(Request $request)
|
public function update(Request $request) : RedirectResponse
|
||||||
{
|
{
|
||||||
$this->authorize('update', Asset::class);
|
$this->authorize('update', Asset::class);
|
||||||
$has_errors = 0;
|
$has_errors = 0;
|
||||||
|
@ -455,9 +453,8 @@ class BulkAssetsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Adds parameter to update array for an item if it exists in request
|
* Adds parameter to update array for an item if it exists in request
|
||||||
* @param string $field field name
|
* @param string $field field name
|
||||||
* @return BulkAssetsController Model for Chaining
|
|
||||||
*/
|
*/
|
||||||
protected function conditionallyAddItem($field)
|
protected function conditionallyAddItem($field) : BulkAssetsController
|
||||||
{
|
{
|
||||||
if (request()->filled($field)) {
|
if (request()->filled($field)) {
|
||||||
$this->update_array[$field] = request()->input($field);
|
$this->update_array[$field] = request()->input($field);
|
||||||
|
@ -471,12 +468,10 @@ class BulkAssetsController extends Controller
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
||||||
* @internal param array $assets
|
* @internal param array $assets
|
||||||
* @since [v2.0]
|
* @since [v2.0]
|
||||||
*/
|
*/
|
||||||
public function destroy(Request $request)
|
public function destroy(Request $request) : RedirectResponse
|
||||||
{
|
{
|
||||||
$this->authorize('delete', Asset::class);
|
$this->authorize('delete', Asset::class);
|
||||||
|
|
||||||
|
@ -505,21 +500,17 @@ class BulkAssetsController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show Bulk Checkout Page
|
* Show Bulk Checkout Page
|
||||||
* @return \Illuminate\Contracts\View\View View to checkout multiple assets
|
|
||||||
*/
|
*/
|
||||||
public function showCheckout()
|
public function showCheckout() : View
|
||||||
{
|
{
|
||||||
$this->authorize('checkout', Asset::class);
|
$this->authorize('checkout', Asset::class);
|
||||||
// Filter out assets that are not deployable.
|
|
||||||
|
|
||||||
return view('hardware/bulk-checkout');
|
return view('hardware/bulk-checkout');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process Multiple Checkout Request
|
* Process Multiple Checkout Request
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
*/
|
*/
|
||||||
public function storeCheckout(AssetCheckoutRequest $request)
|
public function storeCheckout(AssetCheckoutRequest $request) : RedirectResponse | ModelNotFoundException
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('checkout', Asset::class);
|
$this->authorize('checkout', Asset::class);
|
||||||
|
@ -584,17 +575,19 @@ class BulkAssetsController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public function restore(Request $request) {
|
public function restore(Request $request) : RedirectResponse
|
||||||
|
{
|
||||||
$this->authorize('update', Asset::class);
|
$this->authorize('update', Asset::class);
|
||||||
$assetIds = $request->get('ids');
|
$assetIds = $request->get('ids');
|
||||||
if (empty($assetIds)) {
|
|
||||||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.restore.nothing_updated'));
|
if (empty($assetIds)) {
|
||||||
|
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.restore.nothing_updated'));
|
||||||
} else {
|
} else {
|
||||||
foreach ($assetIds as $key => $assetId) {
|
foreach ($assetIds as $key => $assetId) {
|
||||||
$asset = Asset::withTrashed()->find($assetId);
|
$asset = Asset::withTrashed()->find($assetId);
|
||||||
$asset->restore();
|
$asset->restore();
|
||||||
}
|
}
|
||||||
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.restore.success'));
|
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.restore.success'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ class ReportsController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$csv = implode("\n", $rows);
|
$csv = implode("\n", $rows);
|
||||||
$response = Response::make($csv, 200);
|
$response = response()->make($csv, 200);
|
||||||
$response->header('Content-Type', 'text/csv');
|
$response->header('Content-Type', 'text/csv');
|
||||||
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue