Moar typehinting

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-07-04 22:37:58 +01:00
parent 7330bf5832
commit a1eafc108d
18 changed files with 180 additions and 347 deletions

View file

@ -6,8 +6,10 @@ use App\Helpers\StorageHelper;
use App\Http\Requests\UploadFileRequest; use App\Http\Requests\UploadFileRequest;
use App\Models\Actionlog; use App\Models\Actionlog;
use App\Models\AssetModel; use App\Models\AssetModel;
use Illuminate\Support\Facades\Response; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use \Symfony\Component\HttpFoundation\StreamedResponse;
class AssetModelsFilesController extends Controller class AssetModelsFilesController extends Controller
{ {
@ -21,7 +23,7 @@ class AssetModelsFilesController 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, $modelId = null) public function store(UploadFileRequest $request, $modelId = null) : RedirectResponse
{ {
if (! $model = AssetModel::find($modelId)) { if (! $model = AssetModel::find($modelId)) {
return redirect()->route('models.index')->with('error', trans('admin/hardware/message.does_not_exist')); return redirect()->route('models.index')->with('error', trans('admin/hardware/message.does_not_exist'));
@ -54,10 +56,8 @@ class AssetModelsFilesController extends Controller
* @param int $modelId * @param int $modelId
* @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($modelId = null, $fileId = null) public function show($modelId = null, $fileId = null) : StreamedResponse | Response | RedirectResponse
{ {
$model = AssetModel::find($modelId); $model = AssetModel::find($modelId);
// the asset is valid // the asset is valid
@ -101,10 +101,8 @@ class AssetModelsFilesController extends Controller
* @param int $modelId * @param int $modelId
* @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($modelId = null, $fileId = null) public function destroy($modelId = null, $fileId = null) : RedirectResponse
{ {
$model = AssetModel::find($modelId); $model = AssetModel::find($modelId);
$this->authorize('update', $model); $this->authorize('update', $model);

View file

@ -5,7 +5,8 @@ namespace App\Http\Controllers;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Models\AssetModel; use App\Models\AssetModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect; use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
class BulkAssetModelsController extends Controller class BulkAssetModelsController extends Controller
{ {
@ -15,9 +16,8 @@ class BulkAssetModelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.7] * @since [v1.7]
* @param Request $request * @param Request $request
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
*/ */
public function edit(Request $request) public function edit(Request $request) : View | RedirectResponse
{ {
$models_raw_array = $request->input('ids'); $models_raw_array = $request->input('ids');
@ -60,9 +60,8 @@ class BulkAssetModelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.7] * @since [v1.7]
* @param Request $request * @param Request $request
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
*/ */
public function update(Request $request) public function update(Request $request): View | RedirectResponse
{ {
$this->authorize('update', AssetModel::class); $this->authorize('update', AssetModel::class);
@ -104,9 +103,8 @@ class BulkAssetModelsController 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 destroy(Request $request) public function destroy(Request $request) : RedirectResponse
{ {
$this->authorize('delete', AssetModel::class); $this->authorize('delete', AssetModel::class);

View file

@ -4,9 +4,11 @@ namespace App\Http\Controllers;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use App\Models\Category as Category; use App\Models\Category;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
/** /**
* This class controls all actions related to Categories for * This class controls all actions related to Categories for
@ -24,10 +26,8 @@ class CategoriesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see CategoriesController::getDatatable() method that generates the JSON response * @see CategoriesController::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
{ {
// Show the page // Show the page
$this->authorize('view', Category::class); $this->authorize('view', Category::class);
@ -41,10 +41,8 @@ class CategoriesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see CategoriesController::store() method that stores the data * @see CategoriesController::store() method that stores the data
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create() public function create() : View
{ {
// Show the page // Show the page
$this->authorize('create', Category::class); $this->authorize('create', Category::class);
@ -60,10 +58,8 @@ class CategoriesController extends Controller
* @see CategoriesController::create() method that makes the form. * @see CategoriesController::create() method that makes the form.
* @since [v1.0] * @since [v1.0]
* @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('create', Category::class); $this->authorize('create', Category::class);
$category = new Category(); $category = new Category();
@ -90,10 +86,8 @@ class CategoriesController extends Controller
* @see CategoriesController::postEdit() method saves the data * @see CategoriesController::postEdit() method saves the data
* @param int $categoryId * @param int $categoryId
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit($categoryId = null) public function edit($categoryId = null) : RedirectResponse | View
{ {
$this->authorize('update', Category::class); $this->authorize('update', Category::class);
if (is_null($item = Category::find($categoryId))) { if (is_null($item = Category::find($categoryId))) {
@ -111,11 +105,9 @@ class CategoriesController extends Controller
* @see CategoriesController::getEdit() method that makes the form. * @see CategoriesController::getEdit() method that makes the form.
* @param ImageUploadRequest $request * @param ImageUploadRequest $request
* @param int $categoryId * @param int $categoryId
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
* @since [v1.0] * @since [v1.0]
*/ */
public function update(ImageUploadRequest $request, $categoryId = null) public function update(ImageUploadRequest $request, $categoryId = null) : RedirectResponse
{ {
$this->authorize('update', Category::class); $this->authorize('update', Category::class);
if (is_null($category = Category::find($categoryId))) { if (is_null($category = Category::find($categoryId))) {
@ -149,10 +141,8 @@ class CategoriesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @param int $categoryId * @param int $categoryId
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($categoryId) public function destroy($categoryId) : RedirectResponse
{ {
$this->authorize('delete', Category::class); $this->authorize('delete', Category::class);
// Check if the category exists // Check if the category exists
@ -177,11 +167,9 @@ class CategoriesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see CategoriesController::getDataView() method that generates the JSON response * @see CategoriesController::getDataView() method that generates the JSON response
* @param $id * @param $id
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
* @since [v1.8] * @since [v1.8]
*/ */
public function show($id) public function show($id) : View | RedirectResponse
{ {
$this->authorize('view', Category::class); $this->authorize('view', Category::class);
if ($category = Category::find($id)) { if ($category = Category::find($id)) {

View file

@ -11,9 +11,8 @@ trait CheckInOutRequest
{ {
/** /**
* Find target for checkout * Find target for checkout
* @return SnipeModel Target asset is being checked out to.
*/ */
protected function determineCheckoutTarget() protected function determineCheckoutTarget() : ?SnipeModel
{ {
// This item is checked out to a location // This item is checked out to a location
switch (request('checkout_to_type')) { switch (request('checkout_to_type')) {
@ -34,7 +33,7 @@ trait CheckInOutRequest
* @param SnipeModel $target Target with location * @param SnipeModel $target Target with location
* @return Asset Asset being updated * @return Asset Asset being updated
*/ */
protected function updateAssetLocation($asset, $target) protected function updateAssetLocation($asset, $target) : Asset
{ {
switch (request('checkout_to_type')) { switch (request('checkout_to_type')) {
case 'location': case 'location':

View file

@ -7,6 +7,8 @@ use App\Models\Company;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
/** /**
* This controller handles all actions related to Companies for * This controller handles all actions related to Companies for
@ -21,10 +23,8 @@ final class CompaniesController extends Controller
* *
* @author [Abdullah Alansari] [<ahimta@gmail.com>] * @author [Abdullah Alansari] [<ahimta@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function index() public function index() : View
{ {
$this->authorize('view', Company::class); $this->authorize('view', Company::class);
@ -36,10 +36,8 @@ final class CompaniesController extends Controller
* *
* @author [Abdullah Alansari] [<ahimta@gmail.com>] * @author [Abdullah Alansari] [<ahimta@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create() public function create() : View
{ {
$this->authorize('create', Company::class); $this->authorize('create', Company::class);
@ -52,10 +50,8 @@ final class CompaniesController extends Controller
* @author [Abdullah Alansari] [<ahimta@gmail.com>] * @author [Abdullah Alansari] [<ahimta@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @param Request $request * @param Request $request
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request) : RedirectResponse
{ {
$this->authorize('create', Company::class); $this->authorize('create', Company::class);
@ -81,10 +77,8 @@ final class CompaniesController extends Controller
* @author [Abdullah Alansari] [<ahimta@gmail.com>] * @author [Abdullah Alansari] [<ahimta@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @param int $companyId * @param int $companyId
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit($companyId) public function edit($companyId) : View | RedirectResponse
{ {
if (is_null($item = Company::find($companyId))) { if (is_null($item = Company::find($companyId))) {
return redirect()->route('companies.index') return redirect()->route('companies.index')
@ -103,10 +97,8 @@ final class CompaniesController extends Controller
* @since [v1.8] * @since [v1.8]
* @param ImageUploadRequest $request * @param ImageUploadRequest $request
* @param int $companyId * @param int $companyId
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function update(ImageUploadRequest $request, $companyId) public function update(ImageUploadRequest $request, $companyId) : RedirectResponse
{ {
if (is_null($company = Company::find($companyId))) { if (is_null($company = Company::find($companyId))) {
return redirect()->route('companies.index')->with('error', trans('admin/companies/message.does_not_exist')); return redirect()->route('companies.index')->with('error', trans('admin/companies/message.does_not_exist'));
@ -135,10 +127,8 @@ final class CompaniesController extends Controller
* @author [Abdullah Alansari] [<ahimta@gmail.com>] * @author [Abdullah Alansari] [<ahimta@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @param int $companyId * @param int $companyId
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($companyId) public function destroy($companyId) : RedirectResponse
{ {
if (is_null($company = Company::find($companyId))) { if (is_null($company = Company::find($companyId))) {
return redirect()->route('companies.index') return redirect()->route('companies.index')
@ -165,7 +155,7 @@ final class CompaniesController extends Controller
->with('success', trans('admin/companies/message.delete.success')); ->with('success', trans('admin/companies/message.delete.success'));
} }
public function show($id) public function show($id) : View | RedirectResponse
{ {
$this->authorize('view', Company::class); $this->authorize('view', Company::class);

View file

@ -8,6 +8,8 @@ use App\Models\CustomField;
use App\Models\CustomFieldset; use App\Models\CustomFieldset;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
/** /**
* This controller handles all actions related to Custom Asset Fields for * This controller handles all actions related to Custom Asset Fields for
@ -25,10 +27,8 @@ class CustomFieldsController extends Controller
* *
* @author [Brady Wetherington] [<uberbrady@gmail.com>] * @author [Brady Wetherington] [<uberbrady@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function index() public function index() : View
{ {
$this->authorize('view', CustomField::class); $this->authorize('view', CustomField::class);
@ -45,10 +45,8 @@ class CustomFieldsController extends Controller
* @see CustomFieldsController::storeField() * @see CustomFieldsController::storeField()
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v5.1.5] * @since [v5.1.5]
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function show() public function show() : RedirectResponse
{ {
return redirect()->route('fields.index'); return redirect()->route('fields.index');
} }
@ -60,10 +58,8 @@ class CustomFieldsController extends Controller
* @see CustomFieldsController::storeField() * @see CustomFieldsController::storeField()
* @author [Brady Wetherington] [<uberbrady@gmail.com>] * @author [Brady Wetherington] [<uberbrady@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create(Request $request) public function create(Request $request) : View
{ {
$this->authorize('create', CustomField::class); $this->authorize('create', CustomField::class);
$fieldsets = CustomFieldset::get(); $fieldsets = CustomFieldset::get();
@ -82,10 +78,8 @@ class CustomFieldsController extends Controller
* @see CustomFieldsController::createField() * @see CustomFieldsController::createField()
* @author [Brady Wetherington] [<uberbrady@gmail.com>] * @author [Brady Wetherington] [<uberbrady@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function store(CustomFieldRequest $request) public function store(CustomFieldRequest $request) : RedirectResponse
{ {
$this->authorize('create', CustomField::class); $this->authorize('create', CustomField::class);
@ -144,10 +138,8 @@ class CustomFieldsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0] * @since [v3.0]
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function deleteFieldFromFieldset($field_id, $fieldset_id) public function deleteFieldFromFieldset($field_id, $fieldset_id) : RedirectResponse
{ {
$field = CustomField::find($field_id); $field = CustomField::find($field_id);
@ -176,10 +168,8 @@ class CustomFieldsController extends Controller
* *
* @author [Brady Wetherington] [<uberbrady@gmail.com>] * @author [Brady Wetherington] [<uberbrady@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($field_id) public function destroy($field_id) : RedirectResponse
{ {
if ($field = CustomField::find($field_id)) { if ($field = CustomField::find($field_id)) {
$this->authorize('delete', $field); $this->authorize('delete', $field);
@ -202,10 +192,8 @@ class CustomFieldsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $id * @param int $id
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit(Request $request, $id) public function edit(Request $request, $id) : View | RedirectResponse
{ {
if ($field = CustomField::find($id)) { if ($field = CustomField::find($id)) {
@ -241,7 +229,7 @@ class CustomFieldsController extends Controller
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException * @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function update(CustomFieldRequest $request, $id) public function update(CustomFieldRequest $request, $id) : RedirectResponse
{ {
$field = CustomField::find($id); $field = CustomField::find($id);

View file

@ -6,10 +6,9 @@ use App\Models\AssetModel;
use App\Models\CustomField; use App\Models\CustomField;
use App\Models\CustomFieldset; use App\Models\CustomFieldset;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Redirect; use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
/** /**
* This controller handles all actions related to Custom Asset Fields for * This controller handles all actions related to Custom Asset Fields for
@ -23,7 +22,7 @@ use Redirect;
class CustomFieldsetsController extends Controller class CustomFieldsetsController extends Controller
{ {
public function index() public function index() : RedirectResponse
{ {
return redirect()->route("fields.index") return redirect()->route("fields.index")
->with("error", trans('admin/custom_fields/message.fieldset.does_not_exist')); ->with("error", trans('admin/custom_fields/message.fieldset.does_not_exist'));
@ -34,11 +33,9 @@ class CustomFieldsetsController extends Controller
* *
* @author [Brady Wetherington] [<uberbrady@gmail.com>] * @author [Brady Wetherington] [<uberbrady@gmail.com>]
* @param int $id * @param int $id
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
* @since [v1.8] * @since [v1.8]
*/ */
public function show($id) public function show($id) : View | RedirectResponse
{ {
$cfset = CustomFieldset::with('fields') $cfset = CustomFieldset::with('fields')
->where('id', '=', $id)->orderBy('id', 'ASC')->first(); ->where('id', '=', $id)->orderBy('id', 'ASC')->first();
@ -70,10 +67,8 @@ class CustomFieldsetsController extends Controller
* *
* @author [Brady Wetherington] [<uberbrady@gmail.com>] * @author [Brady Wetherington] [<uberbrady@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create() public function create() : View
{ {
$this->authorize('create', CustomField::class); $this->authorize('create', CustomField::class);
@ -89,7 +84,7 @@ class CustomFieldsetsController extends Controller
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException * @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function store(Request $request) public function store(Request $request) : RedirectResponse
{ {
$this->authorize('create', CustomField::class); $this->authorize('create', CustomField::class);
@ -126,10 +121,8 @@ class CustomFieldsetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $id * @param int $id
* @since [v6.0.14] * @since [v6.0.14]
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit($id) public function edit($id) : View | RedirectResponse
{ {
$this->authorize('create', CustomField::class); $this->authorize('create', CustomField::class);
@ -147,10 +140,8 @@ class CustomFieldsetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $id * @param int $id
* @since [v6.0.14] * @since [v6.0.14]
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function update(Request $request, $id) public function update(Request $request, $id) : RedirectResponse
{ {
$this->authorize('create', CustomField::class); $this->authorize('create', CustomField::class);
@ -175,10 +166,8 @@ class CustomFieldsetsController extends Controller
* @author [Brady Wetherington] [<uberbrady@gmail.com>] * @author [Brady Wetherington] [<uberbrady@gmail.com>]
* @param int $id * @param int $id
* @since [v1.8] * @since [v1.8]
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($id) public function destroy($id) : RedirectResponse
{ {
$fieldset = CustomFieldset::find($id); $fieldset = CustomFieldset::find($id);
@ -203,9 +192,8 @@ class CustomFieldsetsController extends Controller
* *
* @author [Brady Wetherington] [<uberbrady@gmail.com>] * @author [Brady Wetherington] [<uberbrady@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @return \Illuminate\Contracts\View\View
*/ */
public function associate(Request $request, $id) public function associate(Request $request, $id) : RedirectResponse
{ {
$set = CustomFieldset::find($id); $set = CustomFieldset::find($id);
@ -232,7 +220,7 @@ class CustomFieldsetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v5.0] * @since [v5.0]
*/ */
public function makeFieldRequired($fieldset_id, $field_id) public function makeFieldRequired($fieldset_id, $field_id) : RedirectResponse
{ {
$this->authorize('update', CustomField::class); $this->authorize('update', CustomField::class);
$field = CustomField::findOrFail($field_id); $field = CustomField::findOrFail($field_id);
@ -250,7 +238,7 @@ class CustomFieldsetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v5.0] * @since [v5.0]
*/ */
public function makeFieldOptional($fieldset_id, $field_id) public function makeFieldOptional($fieldset_id, $field_id) : RedirectResponse
{ {
$this->authorize('update', CustomField::class); $this->authorize('update', CustomField::class);
$field = CustomField::findOrFail($field_id); $field = CustomField::findOrFail($field_id);

View file

@ -2,8 +2,9 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
/** /**
@ -21,9 +22,8 @@ class DashboardController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View
*/ */
public function index() public function index() : View | RedirectResponse
{ {
// Show the page // Show the page
if (auth()->user()->hasAccess('admin')) { if (auth()->user()->hasAccess('admin')) {

View file

@ -6,7 +6,8 @@ use App\Http\Requests\ImageUploadRequest;
use App\Models\Department; use App\Models\Department;
use App\Models\Company; use App\Models\Company;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
@ -26,10 +27,8 @@ class DepartmentsController extends Controller
* @see AssetController::getDatatable() method that generates the JSON response * @see AssetController::getDatatable() method that generates the JSON response
* @since [v4.0] * @since [v4.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', Department::class); $this->authorize('index', Department::class);
$company = null; $company = null;
@ -46,10 +45,8 @@ class DepartmentsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @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('create', Department::class); $this->authorize('create', Department::class);
$department = new Department; $department = new Department;
@ -74,10 +71,8 @@ class DepartmentsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $id * @param int $id
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function show($id) public function show($id) : View | RedirectResponse
{ {
$department = Department::find($id); $department = Department::find($id);
@ -96,10 +91,8 @@ class DepartmentsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see DepartmentsController::postCreate() method that validates and stores the data * @see DepartmentsController::postCreate() method that validates and stores the data
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create() public function create() : View
{ {
$this->authorize('create', Department::class); $this->authorize('create', Department::class);
@ -112,10 +105,8 @@ class DepartmentsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $locationId * @param int $locationId
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($id) public function destroy($id) : RedirectResponse
{ {
if (is_null($department = Department::find($id))) { if (is_null($department = Department::find($id))) {
return redirect()->to(route('departments.index'))->with('error', trans('admin/departments/message.not_found')); return redirect()->to(route('departments.index'))->with('error', trans('admin/departments/message.not_found'));
@ -146,10 +137,8 @@ class DepartmentsController extends Controller
* @see LocationsController::postCreate() method that validates and stores * @see LocationsController::postCreate() method that validates and stores
* @param int $departmentId * @param int $departmentId
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit($departmentId = null) public function edit($departmentId = null) : View | RedirectResponse
{ {
if (is_null($item = Department::find($departmentId))) { if (is_null($item = Department::find($departmentId))) {
return redirect()->back()->with('error', trans('admin/locations/message.does_not_exist')); return redirect()->back()->with('error', trans('admin/locations/message.does_not_exist'));
@ -167,10 +156,8 @@ class DepartmentsController extends Controller
* @see LocationsController::postCreate() method that validates and stores * @see LocationsController::postCreate() method that validates and stores
* @param int $departmentId * @param int $departmentId
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function update(ImageUploadRequest $request, $id) public function update(ImageUploadRequest $request, $id) : RedirectResponse
{ {
if (is_null($department = Department::find($id))) { if (is_null($department = Department::find($id))) {
return redirect()->route('departments.index')->with('error', trans('admin/departments/message.does_not_exist')); return redirect()->route('departments.index')->with('error', trans('admin/departments/message.does_not_exist'));

View file

@ -5,7 +5,8 @@ namespace App\Http\Controllers;
use App\Models\Depreciation; use App\Models\Depreciation;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
/** /**
* This controller handles all actions related to Depreciations for * This controller handles all actions related to Depreciations for
* the Snipe-IT Asset Management application. * the Snipe-IT Asset Management application.
@ -21,14 +22,10 @@ class DepreciationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net] * @author [A. Gianotto] [<snipe@snipe.net]
* @see DepreciationsController::getDatatable() method that generates the JSON response * @see DepreciationsController::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('view', Depreciation::class); $this->authorize('view', Depreciation::class);
// Show the page
return view('depreciations/index'); return view('depreciations/index');
} }
@ -38,10 +35,8 @@ class DepreciationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net] * @author [A. Gianotto] [<snipe@snipe.net]
* @see DepreciationsController::postCreate() * @see DepreciationsController::postCreate()
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create() public function create() : View
{ {
$this->authorize('create', Depreciation::class); $this->authorize('create', Depreciation::class);
@ -56,10 +51,8 @@ class DepreciationsController extends Controller
* @see DepreciationsController::postCreate() * @see DepreciationsController::postCreate()
* @since [v1.0] * @since [v1.0]
* @param Request $request * @param Request $request
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function store(Request $request) public function store(Request $request) : RedirectResponse
{ {
$this->authorize('create', Depreciation::class); $this->authorize('create', Depreciation::class);
@ -87,10 +80,8 @@ class DepreciationsController extends Controller
* @see DepreciationsController::postEdit() * @see DepreciationsController::postEdit()
* @param int $depreciationId * @param int $depreciationId
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit($depreciationId = null) public function edit($depreciationId = null) : RedirectResponse | View
{ {
// Check if the depreciation exists // Check if the depreciation exists
if (is_null($item = Depreciation::find($depreciationId))) { if (is_null($item = Depreciation::find($depreciationId))) {
@ -110,11 +101,9 @@ class DepreciationsController extends Controller
* @see DepreciationsController::getEdit() * @see DepreciationsController::getEdit()
* @param Request $request * @param Request $request
* @param int $depreciationId * @param int $depreciationId
* @return \Illuminate\Http\RedirectResponse
* @since [v1.0] * @since [v1.0]
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function update(Request $request, $depreciationId = null) public function update(Request $request, $depreciationId = null) : RedirectResponse
{ {
// Check if the depreciation exists // Check if the depreciation exists
if (is_null($depreciation = Depreciation::find($depreciationId))) { if (is_null($depreciation = Depreciation::find($depreciationId))) {
@ -146,10 +135,8 @@ class DepreciationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net] * @author [A. Gianotto] [<snipe@snipe.net]
* @since [v1.0] * @since [v1.0]
* @param int $depreciationId * @param int $depreciationId
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($depreciationId) public function destroy($depreciationId) : RedirectResponse
{ {
// Check if the depreciation exists // Check if the depreciation exists
if (is_null($depreciation = Depreciation::withCount('models as models_count')->find($depreciationId))) { if (is_null($depreciation = Depreciation::withCount('models as models_count')->find($depreciationId))) {
@ -175,10 +162,8 @@ class DepreciationsController extends Controller
* @see DepreciationsController::postEdit() * @see DepreciationsController::postEdit()
* @param int $depreciationId * @param int $depreciationId
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function show($id) public function show($id) : View | RedirectResponse
{ {
if (is_null($depreciation = Depreciation::find($id))) { if (is_null($depreciation = Depreciation::find($id))) {
// Redirect to the blogs management page // Redirect to the blogs management page

View file

@ -2,7 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\RedirectResponse;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Laravel\Socialite\Facades\Socialite; use Laravel\Socialite\Facades\Socialite;
@ -30,7 +30,7 @@ class GoogleAuthController extends Controller
return Socialite::driver('google')->redirect(); return Socialite::driver('google')->redirect();
} }
public function handleGoogleCallback() public function handleGoogleCallback() : RedirectResponse
{ {
try { try {
$socialUser = Socialite::driver('google')->user(); $socialUser = Socialite::driver('google')->user();

View file

@ -5,7 +5,8 @@ namespace App\Http\Controllers;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Models\Group; use App\Models\Group;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
/** /**
* This controller handles all actions related to User Groups for * This controller handles all actions related to User Groups for
@ -22,11 +23,9 @@ class GroupsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net] * @author [A. Gianotto] [<snipe@snipe.net]
* @see GroupsController::getDatatable() method that generates the JSON response * @see GroupsController::getDatatable() method that generates the JSON response
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View
*/ */
public function index() public function index(): View
{ {
// Show the page
return view('groups/index'); return view('groups/index');
} }
@ -36,9 +35,8 @@ class GroupsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net] * @author [A. Gianotto] [<snipe@snipe.net]
* @see GroupsController::postCreate() * @see GroupsController::postCreate()
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View
*/ */
public function create(Request $request) public function create(Request $request) : View
{ {
$group = new Group; $group = new Group;
// Get all the available permissions // Get all the available permissions
@ -56,9 +54,8 @@ class GroupsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net] * @author [A. Gianotto] [<snipe@snipe.net]
* @see GroupsController::getCreate() * @see GroupsController::getCreate()
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/ */
public function store(Request $request) public function store(Request $request) : RedirectResponse
{ {
// create a new group instance // create a new group instance
$group = new Group(); $group = new Group();
@ -80,9 +77,8 @@ class GroupsController extends Controller
* @see GroupsController::postEdit() * @see GroupsController::postEdit()
* @param int $id * @param int $id
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
*/ */
public function edit($id) public function edit($id) : View | RedirectResponse
{ {
$group = Group::find($id); $group = Group::find($id);
@ -104,9 +100,8 @@ class GroupsController extends Controller
* @see GroupsController::getEdit() * @see GroupsController::getEdit()
* @param int $id * @param int $id
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/ */
public function update(Request $request, $id = null) public function update(Request $request, $id = null) : RedirectResponse
{ {
if (! $group = Group::find($id)) { if (! $group = Group::find($id)) {
return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', ['id' => $id])); return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', ['id' => $id]));
@ -132,10 +127,8 @@ class GroupsController extends Controller
* @see GroupsController::getEdit() * @see GroupsController::getEdit()
* @param int $id * @param int $id
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
* @throws \Exception
*/ */
public function destroy($id) public function destroy($id) : RedirectResponse
{ {
if (! config('app.lock_passwords')) { if (! config('app.lock_passwords')) {
if (! $group = Group::find($id)) { if (! $group = Group::find($id)) {
@ -154,10 +147,9 @@ class GroupsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param $id * @param $id
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @since [v4.0.11] * @since [v4.0.11]
*/ */
public function show($id) public function show($id) : View | RedirectResponse
{ {
$group = Group::find($id); $group = Group::find($id);

View file

@ -6,11 +6,11 @@ use App\Http\Requests\ImageUploadRequest;
use App\Models\Asset; use App\Models\Asset;
use App\Models\Location; use App\Models\Location;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
/** /**
* This controller handles all actions related to Locations for * This controller handles all actions related to Locations for
* the Snipe-IT Asset Management application. * the Snipe-IT Asset Management application.
@ -26,10 +26,8 @@ class LocationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see LocationsController::getDatatable() method that generates the JSON response * @see LocationsController::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
{ {
// Grab all the locations // Grab all the locations
$this->authorize('view', Location::class); $this->authorize('view', Location::class);
@ -43,10 +41,8 @@ class LocationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see LocationsController::postCreate() method that validates and stores the data * @see LocationsController::postCreate() method that validates and stores the data
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create() public function create() : View
{ {
$this->authorize('create', Location::class); $this->authorize('create', Location::class);
@ -62,10 +58,8 @@ class LocationsController extends Controller
* @see LocationsController::getCreate() method that makes the form * @see LocationsController::getCreate() method that makes the form
* @since [v1.0] * @since [v1.0]
* @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('create', Location::class); $this->authorize('create', Location::class);
$location = new Location(); $location = new Location();
@ -80,7 +74,7 @@ class LocationsController extends Controller
$location->zip = $request->input('zip'); $location->zip = $request->input('zip');
$location->ldap_ou = $request->input('ldap_ou'); $location->ldap_ou = $request->input('ldap_ou');
$location->manager_id = $request->input('manager_id'); $location->manager_id = $request->input('manager_id');
$location->user_id = Auth::id(); $location->user_id = auth()->id();
$location->phone = request('phone'); $location->phone = request('phone');
$location->fax = request('fax'); $location->fax = request('fax');
@ -100,10 +94,8 @@ class LocationsController extends Controller
* @see LocationsController::postCreate() method that validates and stores * @see LocationsController::postCreate() method that validates and stores
* @param int $locationId * @param int $locationId
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit($locationId = null) public function edit($locationId = null) : View | RedirectResponse
{ {
$this->authorize('update', Location::class); $this->authorize('update', Location::class);
// Check if the location exists // Check if the location exists
@ -121,11 +113,9 @@ class LocationsController extends Controller
* @see LocationsController::getEdit() method that makes the form view * @see LocationsController::getEdit() method that makes the form view
* @param ImageUploadRequest $request * @param ImageUploadRequest $request
* @param int $locationId * @param int $locationId
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
* @since [v1.0] * @since [v1.0]
*/ */
public function update(ImageUploadRequest $request, $locationId = null) public function update(ImageUploadRequest $request, $locationId = null) : RedirectResponse
{ {
$this->authorize('update', Location::class); $this->authorize('update', Location::class);
// Check if the location exists // Check if the location exists
@ -163,10 +153,8 @@ class LocationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $locationId * @param int $locationId
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($locationId) public function destroy($locationId) : RedirectResponse
{ {
$this->authorize('delete', Location::class); $this->authorize('delete', Location::class);
if (is_null($location = Location::find($locationId))) { if (is_null($location = Location::find($locationId))) {
@ -202,9 +190,8 @@ class LocationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $id * @param int $id
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
*/ */
public function show($id = null) public function show($id = null) : View | RedirectResponse
{ {
$location = Location::find($id); $location = Location::find($id);
@ -215,7 +202,7 @@ class LocationsController extends Controller
return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist')); return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist'));
} }
public function print_assigned($id) public function print_assigned($id) : View | RedirectResponse
{ {
if ($location = Location::where('id', $id)->first()) { if ($location = Location::where('id', $id)->first()) {
@ -240,9 +227,8 @@ class LocationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $locationId * @param int $locationId
* @since [v6.0.14] * @since [v6.0.14]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
*/ */
public function getClone($locationId = null) public function getClone($locationId = null) : View | RedirectResponse
{ {
$this->authorize('create', Location::class); $this->authorize('create', Location::class);
@ -263,7 +249,7 @@ class LocationsController extends Controller
} }
public function print_all_assigned($id) public function print_all_assigned($id) : View | RedirectResponse
{ {
if ($location = Location::where('id', $id)->first()) { if ($location = Location::where('id', $id)->first()) {
$parent = Location::where('id', $location->parent_id)->first(); $parent = Location::where('id', $location->parent_id)->first();
@ -282,9 +268,8 @@ class LocationsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v6.3.1] * @since [v6.3.1]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
*/ */
public function postBulkDelete(Request $request) public function postBulkDelete(Request $request) : View | RedirectResponse
{ {
$locations_raw_array = $request->input('ids'); $locations_raw_array = $request->input('ids');
@ -315,9 +300,10 @@ class LocationsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v6.3.1] * @since [v6.3.1]
* @return \Illuminate\Http\RedirectResponse
*/ */
public function postBulkDeleteStore(Request $request) { public function postBulkDeleteStore(Request $request) : RedirectResponse
{
$locations_raw_array = $request->input('ids'); $locations_raw_array = $request->input('ids');
if ((is_array($locations_raw_array)) && (count($locations_raw_array) > 0)) { if ((is_array($locations_raw_array)) && (count($locations_raw_array) > 0)) {

View file

@ -2,17 +2,15 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Helpers\Helper;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use App\Models\Actionlog; use App\Models\Actionlog;
use App\Models\Asset;
use App\Models\Manufacturer; use App\Models\Manufacturer;
use App\Models\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Redirect;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
/** /**
* This controller handles all actions related to Manufacturers for * This controller handles all actions related to Manufacturers for
@ -29,13 +27,10 @@ class ManufacturersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see Api\ManufacturersController::index() method that generates the JSON response * @see Api\ManufacturersController::index() 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', Manufacturer::class); $this->authorize('index', Manufacturer::class);
return view('manufacturers/index'); return view('manufacturers/index');
} }
@ -45,10 +40,8 @@ class ManufacturersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see ManufacturersController::store() * @see ManufacturersController::store()
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create() public function create() : View
{ {
$this->authorize('create', Manufacturer::class); $this->authorize('create', Manufacturer::class);
@ -62,10 +55,8 @@ class ManufacturersController extends Controller
* @see ManufacturersController::create() * @see ManufacturersController::create()
* @since [v1.0] * @since [v1.0]
* @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('create', Manufacturer::class); $this->authorize('create', Manufacturer::class);
$manufacturer = new Manufacturer; $manufacturer = new Manufacturer;
@ -92,10 +83,8 @@ class ManufacturersController extends Controller
* @see ManufacturersController::update() * @see ManufacturersController::update()
* @param int $manufacturerId * @param int $manufacturerId
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit($manufacturerId = null) public function edit($manufacturerId = null) : View | RedirectResponse
{ {
// Handles manufacturer checks and permissions. // Handles manufacturer checks and permissions.
$this->authorize('update', Manufacturer::class); $this->authorize('update', Manufacturer::class);
@ -116,11 +105,9 @@ class ManufacturersController extends Controller
* @see ManufacturersController::getEdit() * @see ManufacturersController::getEdit()
* @param Request $request * @param Request $request
* @param int $manufacturerId * @param int $manufacturerId
* @return \Illuminate\Http\RedirectResponse
* @since [v1.0] * @since [v1.0]
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function update(ImageUploadRequest $request, $manufacturerId = null) public function update(ImageUploadRequest $request, $manufacturerId = null) : RedirectResponse
{ {
$this->authorize('update', Manufacturer::class); $this->authorize('update', Manufacturer::class);
// Check if the manufacturer exists // Check if the manufacturer exists
@ -157,10 +144,8 @@ class ManufacturersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $manufacturerId * @param int $manufacturerId
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($manufacturerId) public function destroy($manufacturerId) : RedirectResponse
{ {
$this->authorize('delete', Manufacturer::class); $this->authorize('delete', Manufacturer::class);
if (is_null($manufacturer = Manufacturer::withTrashed()->withCount('models as models_count')->find($manufacturerId))) { if (is_null($manufacturer = Manufacturer::withTrashed()->withCount('models as models_count')->find($manufacturerId))) {
@ -197,10 +182,8 @@ class ManufacturersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $manufacturerId * @param int $manufacturerId
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function show($manufacturerId = null) public function show($manufacturerId = null) : View | RedirectResponse
{ {
$this->authorize('view', Manufacturer::class); $this->authorize('view', Manufacturer::class);
$manufacturer = Manufacturer::find($manufacturerId); $manufacturer = Manufacturer::find($manufacturerId);
@ -220,10 +203,8 @@ class ManufacturersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.1.15] * @since [v4.1.15]
* @param int $manufacturers_id * @param int $manufacturers_id
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function restore($id) public function restore($id) : RedirectResponse
{ {
$this->authorize('delete', Manufacturer::class); $this->authorize('delete', Manufacturer::class);

View file

@ -10,7 +10,8 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
/** /**
* This controller handles all actions related to User Profiles for * This controller handles all actions related to User Profiles for
* the Snipe-IT Asset Management application. * the Snipe-IT Asset Management application.
@ -24,9 +25,8 @@ class ProfileController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View
*/ */
public function getIndex() public function getIndex() : View
{ {
$this->authorize('self.profile'); $this->authorize('self.profile');
$user = auth()->user(); $user = auth()->user();
@ -38,9 +38,8 @@ class ProfileController 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 postIndex(ImageUploadRequest $request) public function postIndex(ImageUploadRequest $request) : RedirectResponse
{ {
$this->authorize('self.profile'); $this->authorize('self.profile');
$user = auth()->user(); $user = auth()->user();
@ -84,7 +83,7 @@ class ProfileController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
*/ */
public function api(): \Illuminate\Contracts\View\View public function api(): View
{ {
// Make sure the self.api permission has been granted // Make sure the self.api permission has been granted
if (!Gate::allows('self.api')) { if (!Gate::allows('self.api')) {
@ -97,21 +96,17 @@ class ProfileController extends Controller
/** /**
* User change email page. * User change email page.
* *
* @return \Illuminate\Contracts\View\View
*/ */
public function password() public function password() : View
{ {
$user = auth()->user(); $user = auth()->user();
return view('account/change-password', compact('user')); return view('account/change-password', compact('user'));
} }
/** /**
* Users change password form processing page. * Users change password form processing page.
*
* @return \Illuminate\Http\RedirectResponse
*/ */
public function passwordSave(Request $request) public function passwordSave(Request $request) : RedirectResponse
{ {
if (config('app.lock_passwords')) { if (config('app.lock_passwords')) {
return redirect()->route('account.password.index')->with('error', trans('admin/users/table.lock_passwords')); return redirect()->route('account.password.index')->with('error', trans('admin/users/table.lock_passwords'));
@ -178,9 +173,8 @@ class ProfileController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Contracts\View\View
*/ */
public function getMenuState(Request $request) public function getMenuState(Request $request) : void
{ {
if ($request->input('state') == 'open') { if ($request->input('state') == 'open') {
$request->session()->put('menu_state', 'open'); $request->session()->put('menu_state', 'open');
@ -195,9 +189,8 @@ class ProfileController extends Controller
* *
* @author A. Gianotto * @author A. Gianotto
* @since [v6.0.12] * @since [v6.0.12]
* @return Illuminate\View\View
*/ */
public function printInventory() public function printInventory() : View
{ {
$show_user = auth()->user(); $show_user = auth()->user();
@ -215,9 +208,8 @@ class ProfileController extends Controller
* *
* @author A. Gianotto * @author A. Gianotto
* @since [v6.0.12] * @since [v6.0.12]
* @return \Illuminate\Http\RedirectResponse
*/ */
public function emailAssetList() public function emailAssetList() : RedirectResponse
{ {
if (!$user = User::find(auth()->id())) { if (!$user = User::find(auth()->id())) {

View file

@ -6,6 +6,8 @@ use App\Helpers\Helper;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\Actionlog; use App\Models\Actionlog;
use App\Models\Asset; use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\AssetMaintenance; use App\Models\AssetMaintenance;
use App\Models\CheckoutAcceptance; use App\Models\CheckoutAcceptance;
use App\Models\CustomField; use App\Models\CustomField;
@ -14,17 +16,16 @@ use App\Models\License;
use App\Models\Setting; use App\Models\Setting;
use App\Notifications\CheckoutAssetNotification; use App\Notifications\CheckoutAssetNotification;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Response; use \Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\View;
use League\Csv\Reader; use League\Csv\Reader;
use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\StreamedResponse;
use League\Csv\EscapeFormula; use League\Csv\EscapeFormula;
use App\Http\Requests\CustomAssetReportRequest; use App\Http\Requests\CustomAssetReportRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Http\RedirectResponse;
/** /**
* This controller handles all actions related to Reports for * This controller handles all actions related to Reports for
@ -49,7 +50,7 @@ class ReportsController extends Controller
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View * @return \Illuminate\Contracts\View\View
*/ */
public function getAccessoryReport() public function getAccessoryReport() : View
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
@ -65,7 +66,7 @@ class ReportsController extends Controller
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function exportAccessoryReport() public function exportAccessoryReport() : Response
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
$accessories = Accessory::orderBy('created_at', 'DESC')->get(); $accessories = Accessory::orderBy('created_at', 'DESC')->get();
@ -104,9 +105,8 @@ class ReportsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View
*/ */
public function getDeprecationReport() public function getDeprecationReport() : View
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
$depreciations = Depreciation::get(); $depreciations = Depreciation::get();
@ -119,9 +119,8 @@ class ReportsController extends Controller
* @deprecated Server-side exports have been replaced by datatables export since v2. * @deprecated Server-side exports have been replaced by datatables export since v2.
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\Response
*/ */
public function exportDeprecationReport() public function exportDeprecationReport() : Response
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
// Grab all the assets // Grab all the assets
@ -197,12 +196,10 @@ class ReportsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Contracts\View\View
*/ */
public function audit() public function audit() : View
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
return view('reports/audit'); return view('reports/audit');
} }
@ -212,9 +209,8 @@ class ReportsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View
*/ */
public function getActivityReport() public function getActivityReport() : View
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
@ -226,9 +222,8 @@ class ReportsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v5.0.7] * @since [v5.0.7]
* @return \Illuminate\Http\Response
*/ */
public function postActivityReport(Request $request) public function postActivityReport(Request $request) : StreamedResponse
{ {
ini_set('max_execution_time', 12000); ini_set('max_execution_time', 12000);
$this->authorize('reports.view'); $this->authorize('reports.view');
@ -328,9 +323,8 @@ class ReportsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Contracts\View\View
*/ */
public function getLicenseReport() public function getLicenseReport() : View
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
$licenses = License::with('depreciation')->orderBy('created_at', 'DESC') $licenses = License::with('depreciation')->orderBy('created_at', 'DESC')
@ -346,9 +340,8 @@ class ReportsController extends Controller
* @deprecated Server-side exports have been replaced by datatables export since v2. * @deprecated Server-side exports have been replaced by datatables export since v2.
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\Response
*/ */
public function exportLicenseReport() public function exportLicenseReport() : Response
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
$licenses = License::orderBy('created_at', 'DESC')->get(); $licenses = License::orderBy('created_at', 'DESC')->get();
@ -398,9 +391,8 @@ class ReportsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see ReportsController::postCustomReport() method that generates the CSV * @see ReportsController::postCustomReport() method that generates the CSV
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\Response
*/ */
public function getCustomReport() public function getCustomReport() : View
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
$customfields = CustomField::get(); $customfields = CustomField::get();
@ -414,9 +406,8 @@ class ReportsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see ReportsController::getCustomReport() method that generates form view * @see ReportsController::getCustomReport() method that generates form view
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\Response
*/ */
public function postCustom(CustomAssetReportRequest $request) public function postCustom(CustomAssetReportRequest $request) : StreamedResponse
{ {
ini_set('max_execution_time', env('REPORT_TIME_LIMIT', 12000)); //12000 seconds = 200 minutes ini_set('max_execution_time', env('REPORT_TIME_LIMIT', 12000)); //12000 seconds = 200 minutes
$this->authorize('reports.view'); $this->authorize('reports.view');
@ -681,15 +672,15 @@ class ReportsController extends Controller
} }
if (($request->filled('created_start')) && ($request->filled('created_end'))) { if (($request->filled('created_start')) && ($request->filled('created_end'))) {
$created_start = \Carbon::parse($request->input('created_start'))->startOfDay(); $created_start = Carbon::parse($request->input('created_start'))->startOfDay();
$created_end = \Carbon::parse($request->input('created_end'))->endOfDay(); $created_end = Carbon::parse($request->input('created_end'))->endOfDay();
$assets->whereBetween('assets.created_at', [$created_start, $created_end]); $assets->whereBetween('assets.created_at', [$created_start, $created_end]);
} }
if (($request->filled('checkout_date_start')) && ($request->filled('checkout_date_end'))) { if (($request->filled('checkout_date_start')) && ($request->filled('checkout_date_end'))) {
$checkout_start = \Carbon::parse($request->input('checkout_date_start'))->startOfDay(); $checkout_start = Carbon::parse($request->input('checkout_date_start'))->startOfDay();
$checkout_end = \Carbon::parse($request->input('checkout_date_end',now()))->endOfDay(); $checkout_end = Carbon::parse($request->input('checkout_date_end',now()))->endOfDay();
$actionlogassets = Actionlog::where('action_type','=', 'checkout') $actionlogassets = Actionlog::where('action_type','=', 'checkout')
->where('item_type', 'LIKE', '%Asset%',) ->where('item_type', 'LIKE', '%Asset%',)
@ -700,9 +691,9 @@ class ReportsController extends Controller
} }
if (($request->filled('checkin_date_start'))) { if (($request->filled('checkin_date_start'))) {
$checkin_start = \Carbon::parse($request->input('checkin_date_start'))->startOfDay(); $checkin_start = Carbon::parse($request->input('checkin_date_start'))->startOfDay();
// use today's date is `checkin_date_end` is not provided // use today's date is `checkin_date_end` is not provided
$checkin_end = \Carbon::parse($request->input('checkin_date_end', now()))->endOfDay(); $checkin_end = Carbon::parse($request->input('checkin_date_end', now()))->endOfDay();
$assets->whereBetween('assets.last_checkin', [$checkin_start, $checkin_end ]); $assets->whereBetween('assets.last_checkin', [$checkin_start, $checkin_end ]);
} }
@ -713,8 +704,8 @@ class ReportsController extends Controller
} }
if (($request->filled('last_audit_start')) && ($request->filled('last_audit_end'))) { if (($request->filled('last_audit_start')) && ($request->filled('last_audit_end'))) {
$last_audit_start = \Carbon::parse($request->input('last_audit_start'))->startOfDay(); $last_audit_start = Carbon::parse($request->input('last_audit_start'))->startOfDay();
$last_audit_end = \Carbon::parse($request->input('last_audit_end'))->endOfDay(); $last_audit_end = Carbon::parse($request->input('last_audit_end'))->endOfDay();
$assets->whereBetween('assets.last_audit_date', [$last_audit_start, $last_audit_end]); $assets->whereBetween('assets.last_audit_date', [$last_audit_start, $last_audit_end]);
} }
@ -1015,11 +1006,10 @@ class ReportsController extends Controller
/** /**
* getImprovementsReport * getImprovementsReport
* *
* @return \Illuminate\Contracts\View\View
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
*/ */
public function getAssetMaintenancesReport() public function getAssetMaintenancesReport() : View
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
@ -1029,11 +1019,10 @@ class ReportsController extends Controller
/** /**
* exportImprovementsReport * exportImprovementsReport
* *
* @return \Illuminate\Http\Response
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
*/ */
public function exportAssetMaintenancesReport() public function exportAssetMaintenancesReport() : Response
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
// Grab all the improvements // Grab all the improvements
@ -1090,13 +1079,10 @@ class ReportsController extends Controller
/** /**
* getAssetAcceptanceReport * getAssetAcceptanceReport
* *
* @return mixed
* @throws \Illuminate\Auth\Access\AuthorizationException
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
*/ */
public function getAssetAcceptanceReport($deleted = false) public function getAssetAcceptanceReport($deleted = false) : View
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
$showDeleted = $deleted == 'deleted'; $showDeleted = $deleted == 'deleted';
@ -1132,11 +1118,9 @@ class ReportsController extends Controller
* sentAssetAcceptanceReminder * sentAssetAcceptanceReminder
* *
* @param integer|null $acceptanceId * @param integer|null $acceptanceId
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
* @version v1.0 * @version v1.0
*/ */
public function sentAssetAcceptanceReminder(Request $request) public function sentAssetAcceptanceReminder(Request $request) : RedirectResponse
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
@ -1190,11 +1174,9 @@ class ReportsController extends Controller
* sentAssetAcceptanceReminder * sentAssetAcceptanceReminder
* *
* @param integer|null $acceptanceId * @param integer|null $acceptanceId
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
* @version v1.0 * @version v1.0
*/ */
public function deleteAssetAcceptance($acceptanceId = null) public function deleteAssetAcceptance($acceptanceId = null) : RedirectResponse
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
@ -1213,11 +1195,10 @@ class ReportsController extends Controller
/** /**
* Exports the AssetAcceptance report to CSV * Exports the AssetAcceptance report to CSV
* *
* @return \Illuminate\Http\Response
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
*/ */
public function postAssetAcceptanceReport($deleted = false) public function postAssetAcceptanceReport($deleted = false) : Response
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
$showDeleted = $deleted == 'deleted'; $showDeleted = $deleted == 'deleted';
@ -1284,7 +1265,7 @@ class ReportsController extends Controller
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
*/ */
protected function getCheckedOutAssetsRequiringAcceptance($modelsInCategoriesThatRequireAcceptance) protected function getCheckedOutAssetsRequiringAcceptance($modelsInCategoriesThatRequireAcceptance) : View
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
$assets = Asset::deployed() $assets = Asset::deployed()
@ -1304,11 +1285,11 @@ class ReportsController extends Controller
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
*/ */
protected function getModelsInCategoriesThatRequireAcceptance($assetCategoriesRequiringAcceptance) protected function getModelsInCategoriesThatRequireAcceptance($assetCategoriesRequiringAcceptance) : array
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
return array_pluck(Model::inCategory($assetCategoriesRequiringAcceptance) return array_pluck(AssetModel::inCategory($assetCategoriesRequiringAcceptance)
->select('id') ->select('id')
->get() ->get()
->toArray(), 'id'); ->toArray(), 'id');
@ -1321,7 +1302,7 @@ class ReportsController extends Controller
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
*/ */
protected function getCategoriesThatRequireAcceptance() protected function getCategoriesThatRequireAcceptance() : array
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
@ -1334,11 +1315,10 @@ class ReportsController extends Controller
/** /**
* getAssetsCheckedOutRequiringAcceptance * getAssetsCheckedOutRequiringAcceptance
* *
* @return array
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
*/ */
protected function getAssetsCheckedOutRequiringAcceptance() protected function getAssetsCheckedOutRequiringAcceptance() : array
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');

View file

@ -19,7 +19,8 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
use Illuminate\View\View; use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@ -49,7 +50,7 @@ class SettingsController extends Controller
* *
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\Response * @return \Illuminate\Contracts\View\View | \Illuminate\Http\Response
*/ */
public function getSetupIndex() public function getSetupIndex() : View
{ {
$start_settings['php_version_min'] = false; $start_settings['php_version_min'] = false;
@ -123,7 +124,7 @@ class SettingsController extends Controller
* @return bool This method will return true when exceptions (such as curl exception) is thrown. * @return bool This method will return true when exceptions (such as curl exception) is thrown.
* Check the log files to see more details about the exception. * Check the log files to see more details about the exception.
*/ */
protected function dotEnvFileIsExposed() protected function dotEnvFileIsExposed() : bool
{ {
try { try {
return Http::timeout(10) return Http::timeout(10)
@ -153,12 +154,11 @@ class SettingsController extends Controller
* Save the first admin user from Setup. * Save the first admin user from Setup.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
*
* @since [v3.0] * @since [v3.0]
* *
* @return \Illuminate\Http\RedirectResponse
*/ */
public function postSaveFirstAdmin(SetupUserRequest $request) public function postSaveFirstAdmin(SetupUserRequest $request) : RedirectResponse
{
{ {
$user = new User(); $user = new User();
$user->first_name = $data['first_name'] = $request->input('first_name'); $user->first_name = $data['first_name'] = $request->input('first_name');
@ -214,10 +214,8 @@ class SettingsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* *
* @since [v3.0] * @since [v3.0]
*
* @return \Illuminate\Contracts\View\View
*/ */
public function getSetupUser() public function getSetupUser() : View
{ {
return view('setup/user') return view('setup/user')
->with('step', 3) ->with('step', 3)
@ -230,10 +228,8 @@ class SettingsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* *
* @since [v3.0] * @since [v3.0]
*
* @return \Illuminate\Contracts\View\View
*/ */
public function getSetupDone() public function getSetupDone() : View
{ {
return view('setup/done') return view('setup/done')
->with('step', 4) ->with('step', 4)
@ -247,10 +243,8 @@ class SettingsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* *
* @since [v3.0] * @since [v3.0]
*
* @return \Illuminate\Contracts\View\View
*/ */
public function getSetupMigrate() public function getSetupMigrate() : View
{ {
Artisan::call('migrate', ['--force' => true]); Artisan::call('migrate', ['--force' => true]);
if ((! file_exists(storage_path().'/oauth-private.key')) || (! file_exists(storage_path().'/oauth-public.key'))) { if ((! file_exists(storage_path().'/oauth-private.key')) || (! file_exists(storage_path().'/oauth-public.key'))) {
@ -270,10 +264,8 @@ class SettingsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* *
* @since [v1.0] * @since [v1.0]
*
* @return \Illuminate\Contracts\View\View
*/ */
public function index() public function index() : View
{ {
$settings = Setting::getSettings(); $settings = Setting::getSettings();
@ -286,10 +278,9 @@ class SettingsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* *
* @since [v1.0] * @since [v1.0]
*
* @return \Illuminate\Contracts\View\View
*/ */
public function getEdit() public function getEdit() : View
{ {
$setting = Setting::getSettings(); $setting = Setting::getSettings();
@ -302,10 +293,8 @@ class SettingsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* *
* @since [v1.0] * @since [v1.0]
*
* @return \Illuminate\Contracts\View\View
*/ */
public function getSettings() public function getSettings() : View
{ {
$setting = Setting::getSettings(); $setting = Setting::getSettings();
@ -318,10 +307,9 @@ class SettingsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* *
* @since [v1.0] * @since [v1.0]
*
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
*/ */
public function postSettings(Request $request) public function postSettings(Request $request) : RedirectResponse
{ {
if (is_null($setting = Setting::getSettings())) { if (is_null($setting = Setting::getSettings())) {
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error')); return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
@ -375,10 +363,8 @@ class SettingsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* *
* @since [v1.0] * @since [v1.0]
*
* @return \Illuminate\Contracts\View\View
*/ */
public function getBranding() public function getBranding() : View
{ {
$setting = Setting::getSettings(); $setting = Setting::getSettings();
@ -391,10 +377,8 @@ class SettingsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* *
* @since [v1.0] * @since [v1.0]
*
* @return \Illuminate\Contracts\View\View | \Illuminate\Http\RedirectResponse
*/ */
public function postBranding(ImageUploadRequest $request) public function postBranding(ImageUploadRequest $request) : RedirectResponse
{ {
// Something has gone horribly wrong - no settings record exists! // Something has gone horribly wrong - no settings record exists!
if (is_null($setting = Setting::getSettings())) { if (is_null($setting = Setting::getSettings())) {
@ -493,10 +477,8 @@ class SettingsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* *
* @since [v1.0] * @since [v1.0]
*
* @return \Illuminate\Contracts\View\View
*/ */
public function getSecurity() public function getSecurity() : View
{ {
$setting = Setting::getSettings(); $setting = Setting::getSettings();
@ -509,10 +491,8 @@ class SettingsController 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 postSecurity(Request $request) public function postSecurity(Request $request) : RedirectResponse
{ {
$this->validate($request, [ $this->validate($request, [
'pwd_secure_complexity' => 'array', 'pwd_secure_complexity' => 'array',

View file

@ -2,8 +2,9 @@
namespace App\Http\Requests; namespace App\Http\Requests;
use App\Models\AssetModel;
use App\Models\Category; use App\Models\Category;
use Illuminate\Validation\Rule; use Illuminate\Support\Facades\Gate;
class StoreAssetModelRequest extends ImageUploadRequest class StoreAssetModelRequest extends ImageUploadRequest
{ {
@ -13,7 +14,7 @@ class StoreAssetModelRequest extends ImageUploadRequest
*/ */
public function authorize(): bool public function authorize(): bool
{ {
return true; return Gate::allows('create', new AssetModel);
} }
public function prepareForValidation(): void public function prepareForValidation(): void