Skip to content

A free open source IT asset/license management system

Updated baseline and fixed small phpstan issues

snipe032fde304a0f
diff --git a/app/Http/Controllers/Accessories/AccessoryCheckinController.php b/app/Http/Controllers/Accessories/AccessoryCheckinController.php
index 093859cd27..f43e211c86 100644
--- a/app/Http/Controllers/Accessories/AccessoryCheckinController.php
+++ b/app/Http/Controllers/Accessories/AccessoryCheckinController.php
@@ -10,7 +10,6 @@ use App\Models\AccessoryCheckout;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
-use Illuminate\Support\Facades\DB;
class AccessoryCheckinController extends Controller
{
@@ -19,38 +18,28 @@ class AccessoryCheckinController extends Controller
*
* @author [A. Gianotto] [<[email protected]>]
*
- * @param Request $request
- * @param int $accessoryUserId
- * @param string $backto
+ * @param int|null $accessoryCheckoutId
+ * @param string|null $backto
*/
- public function create($accessoryUserId = null, $backto = null): View|RedirectResponse
+ public function create($accessoryCheckoutId = null, $backto = null): View|RedirectResponse
{
- if (is_null($accessory_user = DB::table('accessories_checkout')->find($accessoryUserId))) {
+ if (is_null($accessory_checkout = AccessoryCheckout::find($accessoryCheckoutId))) {
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
}
- $accessory = Accessory::find($accessory_user->accessory_id);
+ $accessory = Accessory::find($accessory_checkout->accessory_id);
$this->authorize('checkin', $accessory);
// based on what the accessory is checked out to the target redirect option will be displayed accordingly.
- $target_option = match ($accessory_user->assigned_type) {
+ $target_option = match ($accessory_checkout->assigned_type) {
'App\Models\Asset' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset')]),
'App\Models\Location' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.location')]),
default => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.user')]),
};
- // Hydrate the polymorphic target so the checkin form can
- // display which user, asset, or location the accessory is
- // currently checked out to.
- $target = null;
- if ($accessory_user->assigned_type && $accessory_user->assigned_to) {
- $targetClass = $accessory_user->assigned_type;
- if (class_exists($targetClass)) {
- $target = $targetClass::find($accessory_user->assigned_to);
- }
- }
-
- return view('accessories/checkin', compact('accessory', 'target', 'target_option'))->with('backto', $backto);
+ return view('accessories/checkin', compact('accessory', 'target_option'))
+ ->with('target', $accessory_checkout->assignedTo)
+ ->with('backto', $backto);
}
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index e3dc01396e..52f1ba6aff 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -876,24 +876,6 @@ parameters:
count: 1
path: app/Http/Controllers/Accessories/AccessoriesController.php
- -
- message: '#^Cannot access property \$accessory_id on array\<mixed\>\|object\.$#'
- identifier: property.nonObject
- count: 1
- path: app/Http/Controllers/Accessories/AccessoryCheckinController.php
-
- -
- message: '#^Cannot access property \$assigned_type on array\<mixed\>\|object\.$#'
- identifier: property.nonObject
- count: 1
- path: app/Http/Controllers/Accessories/AccessoryCheckinController.php
-
- -
- message: '#^PHPDoc tag @param references unknown parameter\: \$request$#'
- identifier: parameter.notFound
- count: 1
- path: app/Http/Controllers/Accessories/AccessoryCheckinController.php
-
-
message: '#^Access to an undefined property App\\Models\\Accessory\:\:\$checkout_qty\.$#'
identifier: property.notFound
diff --git a/resources/views/blade/button/add.blade.php b/resources/views/blade/button/add.blade.php
index b6f2d69d62..b44a7da96a 100644
--- a/resources/views/blade/button/add.blade.php
+++ b/resources/views/blade/button/add.blade.php
@@ -7,7 +7,7 @@
@can('create', $item)
<!-- start add button component -->
- <a href="{{ $route }}" class="btn btn-sm btn-info hidden-print{{ ($wide=='true') ?? ' btn-block btn-social' }}" data-tooltip="true" data-placement="top" data-title="{{ $tooltip }}">
+ <a href="{{ $route }}" class="btn btn-sm btn-info hidden-print{{ $wide == 'true' ? ' btn-block btn-social' : '' }}" data-tooltip="true" data-placement="top" data-title="{{ $tooltip }}">
<x-icon type="create" class="fa-fw" />
@if ($wide=='true')
{{ trans('general.create') }}
diff --git a/resources/views/blade/button/clone.blade.php b/resources/views/blade/button/clone.blade.php
index 6c61308761..3531b200ce 100644
--- a/resources/views/blade/button/clone.blade.php
+++ b/resources/views/blade/button/clone.blade.php
@@ -6,7 +6,7 @@
@can('create', $item)
<!-- start clone button component -->
- <a href="{{ $route }}" class="btn btn-sm btn-info hidden-print{{ ($wide=='true') ?? ' btn-block btn-social' }}" data-tooltip="true" data-placement="top" data-title="{{ trans('general.clone') }}">
+ <a href="{{ $route }}" class="btn btn-sm btn-info hidden-print{{ $wide == 'true' ? ' btn-block btn-social' : '' }}" data-tooltip="true" data-placement="top" data-title="{{ trans('general.clone') }}">
<x-icon type="clone" class="fa-fw" />
@if ($wide=='true')
{{ trans('general.clone') }}