diff --git a/app/Console/Commands/SendExpectedCheckinAlerts.php b/app/Console/Commands/SendExpectedCheckinAlerts.php index 912f2975a7..15594bee08 100644 --- a/app/Console/Commands/SendExpectedCheckinAlerts.php +++ b/app/Console/Commands/SendExpectedCheckinAlerts.php @@ -44,14 +44,14 @@ class SendExpectedCheckinAlerts extends Command { $whenNotify = Carbon::now()->addDays(7); - $assets = Asset::with('assigneduser')->whereNotNull('expected_checkin')->where('expected_checkin', '<=', $whenNotify)->get(); + $assets = Asset::with('assignedTo')->whereNotNull('expected_checkin')->where('expected_checkin', '<=', $whenNotify)->get(); $this->info($whenNotify.' is deadline'); $this->info($assets->count().' assets'); foreach ($assets as $asset) { - if ($asset->assigneduser) { - $asset->assigneduser->notify((new ExpectedCheckinNotification($asset))); + if ($asset->assignedTo && $asset->checkoutOutToUser()) { + $asset->assignedTo->notify((new ExpectedCheckinNotification($asset))); //$this->info($asset); } } diff --git a/app/Http/Controllers/Api/AssetMaintenancesController.php b/app/Http/Controllers/Api/AssetMaintenancesController.php index eb07aa6814..db0d58bfa5 100644 --- a/app/Http/Controllers/Api/AssetMaintenancesController.php +++ b/app/Http/Controllers/Api/AssetMaintenancesController.php @@ -1,16 +1,17 @@ with( - 'assetLoc', 'assetstatus', 'defaultLoc', 'assetlog', 'company', - 'model.category', 'model.manufacturer', 'model.fieldset', 'assigneduser','supplier'); - + 'assetloc', 'assetstatus', 'defaultLoc', 'assetlog', 'company', + 'model.category', 'model.manufacturer', 'model.fieldset','supplier'); // If we should search on everything if (($request->has('search')) && (count($filter) == 0)) { $assets->TextSearch($request->input('search')); @@ -97,7 +96,6 @@ class AssetsController extends Controller } } - // These are used by the API to query against specific ID numbers if ($request->has('status_id')) { $assets->where('status_id', '=', $request->input('status_id')); diff --git a/app/Http/Controllers/Api/ConsumablesController.php b/app/Http/Controllers/Api/ConsumablesController.php index ac95e951d7..793de92140 100644 --- a/app/Http/Controllers/Api/ConsumablesController.php +++ b/app/Http/Controllers/Api/ConsumablesController.php @@ -148,4 +148,47 @@ class ConsumablesController extends Controller $consumable->delete(); return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/consumables/message.delete.success'))); } + + /** + * Returns a JSON response containing details on the users associated with this consumable. + * + * @author [A. Gianotto] [] + * @see ConsumablesController::getView() method that returns the form. + * @since [v1.0] + * @param int $consumableId + * @return array + */ + public function getDataView($consumableId) + { + //$consumable = Consumable::find($consumableID); + $consumable = Consumable::with(array('consumableAssignments'=> + function ($query) { + $query->orderBy('created_at', 'DESC'); + }, + 'consumableAssignments.admin'=> function ($query) { + }, + 'consumableAssignments.user'=> function ($query) { + }, + ))->find($consumableId); + + // $consumable->load('consumableAssignments.admin','consumableAssignments.user'); + + if (!Company::isCurrentUserHasAccess($consumable)) { + return ['total' => 0, 'rows' => []]; + } + $this->authorize('view', Component::class); + $rows = array(); + + foreach ($consumable->consumableAssignments as $consumable_assignment) { + $rows[] = [ + 'name' => $consumable_assignment->user->present()->nameUrl(), + 'created_at' => ($consumable_assignment->created_at->format('Y-m-d H:i:s')=='-0001-11-30 00:00:00') ? '' : $consumable_assignment->created_at->format('Y-m-d H:i:s'), + 'admin' => ($consumable_assignment->admin) ? $consumable_assignment->admin->present()->nameUrl() : '', + ]; + } + + $consumableCount = $consumable->users->count(); + $data = array('total' => $consumableCount, 'rows' => $rows); + return $data; + } } diff --git a/app/Http/Controllers/Api/LicensesController.php b/app/Http/Controllers/Api/LicensesController.php index 70f96f9b15..ff58362f6c 100644 --- a/app/Http/Controllers/Api/LicensesController.php +++ b/app/Http/Controllers/Api/LicensesController.php @@ -21,7 +21,7 @@ class LicensesController extends Controller public function index(Request $request) { $this->authorize('view', License::class); - $licenses = Company::scopeCompanyables(License::with('company', 'licenseSeatsRelation', 'manufacturer')); + $licenses = Company::scopeCompanyables(License::with('company', 'licenseSeatsRelation', 'manufacturer', 'supplier')); if ($request->has('search')) { $licenses = $licenses->TextSearch($request->input('search')); diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index 48f9704dd0..c084a7cc80 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -537,17 +537,18 @@ class AssetsController extends Controller $this->authorize('checkin', $asset); $admin = Auth::user(); - $user = $asset->assignedUser; + if($asset->assignedType() == Asset::USER) { + $user = $asset->assignedTo; + } if (is_null($target = $asset->assignedTo)) { return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.already_checked_in')); } - // This is just used for the redirect - $return_to = $asset->assigned_to; $asset->expected_checkin = null; $asset->last_checkout = null; $asset->assigned_to = null; $asset->assignedTo()->disassociate($asset); + $asset->assigned_type = null; $asset->accepted = null; $asset->name = e(Input::get('name')); @@ -575,7 +576,7 @@ class AssetsController extends Controller } if ($backto=='user') { - return redirect()->to("admin/users/".$return_to.'/view')->with('success', trans('admin/hardware/message.checkin.success')); + return redirect()->to("admin/users/".$user->id.'/view')->with('success', trans('admin/hardware/message.checkin.success')); } return redirect()->route("hardware.index")->with('success', trans('admin/hardware/message.checkin.success')); } @@ -957,7 +958,7 @@ class AssetsController extends Controller * @since [v1.0] * @return View */ - public function getDeleteFile($assetId = null, $fileId = null) + public function deleteFile($assetId = null, $fileId = null) { $asset = Asset::find($assetId); $this->authorize('update', $asset); diff --git a/app/Http/Controllers/ConsumablesController.php b/app/Http/Controllers/ConsumablesController.php index 93f93bf946..c7c920897b 100644 --- a/app/Http/Controllers/ConsumablesController.php +++ b/app/Http/Controllers/ConsumablesController.php @@ -273,47 +273,4 @@ class ConsumablesController extends Controller } - - /** - * Returns a JSON response containing details on the users associated with this consumable. - * - * @author [A. Gianotto] [] - * @see ConsumablesController::getView() method that returns the form. - * @since [v1.0] - * @param int $consumableId - * @return array - */ - public function getDataView($consumableId) - { - //$consumable = Consumable::find($consumableID); - $consumable = Consumable::with(array('consumableAssigments'=> - function ($query) { - $query->orderBy('created_at', 'DESC'); - }, - 'consumableAssigments.admin'=> function ($query) { - }, - 'consumableAssigments.user'=> function ($query) { - }, - ))->find($consumableId); - - // $consumable->load('consumableAssigments.admin','consumableAssigments.user'); - - if (!Company::isCurrentUserHasAccess($consumable)) { - return ['total' => 0, 'rows' => []]; - } - $this->authorize('view', Component::class); - $rows = array(); - - foreach ($consumable->consumableAssigments as $consumable_assignment) { - $rows[] = [ - 'name' => $consumable_assignment->user->present()->nameUrl(), - 'created_at' => ($consumable_assignment->created_at->format('Y-m-d H:i:s')=='-0001-11-30 00:00:00') ? '' : $consumable_assignment->created_at->format('Y-m-d H:i:s'), - 'admin' => ($consumable_assignment->admin) ? $consumable_assignment->admin->present()->nameUrl() : '', - ]; - } - - $consumableCount = $consumable->users->count(); - $data = array('total' => $consumableCount, 'rows' => $rows); - return $data; - } } diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 3e6d329ff5..2668e62906 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -186,7 +186,7 @@ class ReportsController extends Controller { // Grab all the assets - $assets = Asset::with('model', 'assignedTo', 'assetstatus', 'defaultLoc', 'assetlog', 'company') + $assets = Asset::with( 'assignedTo', 'assetstatus', 'defaultLoc', 'assetloc', 'assetlog', 'company', 'model.category', 'model.depreciation') ->orderBy('created_at', 'DESC')->get(); return view('reports/depreciation', compact('assets')); @@ -390,7 +390,7 @@ class ReportsController extends Controller */ public function postCustom() { - $assets = Asset::orderBy('created_at', 'DESC')->with('company', 'assigneduser', 'assetloc', 'defaultLoc', 'assigneduser.userloc', 'model', 'supplier', 'assetstatus', 'model.manufacturer')->get(); + $assets = Asset::orderBy('created_at', 'DESC')->with('company', 'assignedTo', 'assetloc', 'defaultLoc', 'model', 'supplier', 'assetstatus', 'model.manufacturer')->get(); $customfields = CustomField::get(); $rows = [ ]; @@ -552,8 +552,8 @@ class ReportsController extends Controller if (e(Input::get('username')) == '1') { // Only works if we're checked out to a user, not anything else. - if ($asset->assigneduser) { - $row[] = '"' .e($asset->assigneduser->username). '"'; + if ($asset->checkedOutToUser()) { + $row[] = '"' .e($asset->assignedTo->username). '"'; } else { $row[] = ''; // Empty string if unassigned } @@ -561,8 +561,8 @@ class ReportsController extends Controller if (e(Input::get('employee_num')) == '1') { // Only works if we're checked out to a user, not anything else. - if ($asset->assigneduser) { - $row[] = '"' .e($asset->assigneduser->employee_num). '"'; + if ($asset->checkedOutToUser()) { + $row[] = '"' .e($asset->assignedTo->employee_num). '"'; } else { $row[] = ''; // Empty string if unassigned } diff --git a/app/Http/Controllers/ViewAssetsController.php b/app/Http/Controllers/ViewAssetsController.php index 52790fe628..5a7ac1eb9c 100755 --- a/app/Http/Controllers/ViewAssetsController.php +++ b/app/Http/Controllers/ViewAssetsController.php @@ -68,8 +68,8 @@ class ViewAssetsController extends Controller public function getRequestableIndex() { - $assets = Asset::with('model', 'defaultLoc', 'assetloc', 'assignedTo')->Hardware()->RequestableAssets()->get(); - $models = AssetModel::with('category')->RequestableModels()->get(); + $assets = Asset::with('model', 'defaultLoc', 'assetloc', 'assignedTo', 'requests')->Hardware()->RequestableAssets()->get(); + $models = AssetModel::with('category', 'requests', 'assets')->RequestableModels()->get(); return view('account/requestable-assets', compact('user', 'assets', 'models')); } diff --git a/app/Http/Transformers/ActionlogsTransformer.php b/app/Http/Transformers/ActionlogsTransformer.php index 2de8b75e5b..6b81ce33c1 100644 --- a/app/Http/Transformers/ActionlogsTransformer.php +++ b/app/Http/Transformers/ActionlogsTransformer.php @@ -25,7 +25,7 @@ class ActionlogsTransformer $array = [ 'id' => (int) $actionlog->id, 'icon' => $actionlog->present()->icon(), - 'image' => ($actionlog->item->getImageUrl()) ? $actionlog->item->getImageUrl() : null, + 'image' => (method_exists($actionlog->item, 'getImageUrl')) ? $actionlog->item->getImageUrl() : null, 'item' => ($actionlog->item) ? [ 'id' => (int) $actionlog->item->id, 'name' => e($actionlog->item->getDisplayNameAttribute()), diff --git a/app/Http/Transformers/AssetMaintenancesTransformer.php b/app/Http/Transformers/AssetMaintenancesTransformer.php index f27f022c36..875d882e82 100644 --- a/app/Http/Transformers/AssetMaintenancesTransformer.php +++ b/app/Http/Transformers/AssetMaintenancesTransformer.php @@ -38,6 +38,7 @@ class AssetMaintenancesTransformer ]; $permissions_array['available_actions'] = [ + 'update' => (bool) Gate::allows('update', Asset::class), 'delete' => (bool) Gate::allows('delete', Asset::class), ]; diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index 132fc2de71..492e86a95b 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -62,14 +62,7 @@ class AssetsTransformer 'name'=> e($asset->defaultLoc->name) ] : null, 'image' => ($asset->getImageUrl()) ? $asset->getImageUrl() : null, - 'assigned_to' => ($asset->assigneduser) ? [ - 'id' => (int) $asset->assigneduser->id, - 'username' => e($asset->assigneduser->username), - 'name' => e($asset->assigneduser->getFullNameAttribute()), - 'first_name'=> e($asset->assigneduser->first_name), - 'last_name'=> e($asset->assigneduser->last_name), - 'employee_number' => e($asset->assigneduser->employee_num), - ] : null, + 'assigned_to' => $this->transformAssignedTo($asset), 'warranty' => ($asset->warranty_months > 0) ? e($asset->warranty_months . ' ' . trans('admin/hardware/form.months')) : null, 'warranty_expires' => ($asset->warranty_months > 0) ? Helper::getFormattedDateObject($asset->warranty_expires, 'date') : null, 'created_at' => Helper::getFormattedDateObject($asset->created_at, 'datetime'), @@ -130,4 +123,24 @@ class AssetsTransformer { return (new DatatablesTransformer)->transformDatatables($assets); } + + public function transformAssignedTo($asset) + { + if ($asset->checkedOutToUser()) { + return $asset->assignedTo ? [ + 'id' => (int) $asset->assignedTo->id, + 'username' => e($asset->assignedTo->username), + 'name' => e($asset->assignedTo->getFullNameAttribute()), + 'first_name'=> e($asset->assignedTo->first_name), + 'last_name'=> e($asset->assignedTo->last_name), + 'employee_number' => e($asset->assignedTo->employee_num), + 'type' => 'user' + ] : null; + } + return $asset->assignedTo ? [ + 'id' => $asset->assignedTo->id, + 'name' => $asset->assignedTo->display_name, + 'type' => $asset->assignedType() + ] : null; + } } diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 0cbc9b5f78..11f15b9e06 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -227,16 +227,14 @@ class Asset extends Depreciable ->orderBy('created_at', 'desc'); } - /** * Even though we allow allow for checkout to things beyond users * this method is an easy way of seeing if we are checked out to a user. * @return mixed */ - public function assigneduser() + public function checkedOutToUser() { - return $this->belongsTo('\App\Models\User', 'assigned_to') - ->withTrashed(); + return $this->assignedType() === self::USER; } public function assignedTo() @@ -260,14 +258,13 @@ class Asset extends Depreciable } if ($this->assignedType() == self::LOCATION) { return $this->assignedTo(); - } elseif (!$this->assignedTo) { - return $this->defaultLoc(); - } elseif ($this->assignedType() == self::USER) { - return $this->assignedTo->userLoc(); } if ($this->assignedType() == self::USER) { return $this->assignedTo->userLoc(); } + if (!$this->assignedTo) { + return $this->defaultLoc(); + } } return $this->defaultLoc(); } @@ -529,7 +526,7 @@ class Asset extends Depreciable /** - * Query builder scope for pending assets + * Query builder scope for searching location * * @param \Illuminate\Database\Query\Builder $query Query builder instance * @@ -539,8 +536,17 @@ class Asset extends Depreciable public function scopeAssetsByLocation($query, $location) { return $query->where(function ($query) use ($location) { - $query->whereHas('assigneduser', function ($query) use ($location) { - $query->where('users.location_id', '=', $location->id); + $query->whereHas('assignedTo', function ($query) use ($location) { + $query->where([ + ['users.location_id', '=', $location->id], + ['assets.assigned_type', '=', User::class] + ])->orWhere([ + ['locations.id', '=', $location->id], + ['assets.assigned_type', '=', Location::class] + ])->orWhere([ + ['assets.rtd_location_id', '=', $location->id], + ['assets.assigned_type', '=', Asset::class] + ]); })->orWhere(function ($query) use ($location) { $query->where('assets.rtd_location_id', '=', $location->id); $query->whereNull('assets.assigned_to'); @@ -760,18 +766,26 @@ class Asset extends Depreciable $query->whereHas('defaultLoc', function ($query) use ($search) { $query->where('locations.name', 'LIKE', '%'.$search.'%'); }); - })->orWhere(function ($query) use ($search) { - $query->whereHas('assigneduser', function ($query) use ($search) { - $query->where(function ($query) use ($search) { - $query->where('users.first_name', 'LIKE', '%'.$search.'%') - ->orWhere('users.last_name', 'LIKE', '%'.$search.'%') - ->orWhere(function ($query) use ($search) { - $query->whereHas('userloc', function ($query) use ($search) { - $query->where('locations.name', 'LIKE', '%'.$search.'%'); - }); - }); - }); - }); + //FIXME: This needs attention to work with checkout to not-users. + // })->orWhere(function ($query) use ($search) { + // $query->whereHas('assignedTo', function ($query) use ($search) { + // $query->where(function ($query) use ($search) { + // $query->where('assets.assigned_type', '=', User::class) + // ->join('users', 'users.id', '=', 'assets.assigned_to') + // ->where(function($query) use ($search) { + // $query->where('users.first_name', 'LIKE', '%'.$search.'%') + // ->orWhere('users.last_name', 'LIKE', '%'.$search.'%'); + // }); + // })->orWhere(function ($query) use ($search) { + // $query->where('assets.assigned_type', '=', Location::class) + // ->join('locations', 'locations.id', '=', 'assets.assigned_to') + // ->where('locations.name', 'LIKE', '%'.$search.'%'); + // })->orWhere(function ($query) use ($search) { + // $query->where('assets.assigned_type', '=', Asset::class) + // ->join('assets as assigned_asset', 'assigned_assets.id', '=', 'assets.assigned_to') + // ->where('assigned_assets.name', 'LIKE', '%'.$search.'%'); + // }); + // }); })->orWhere('assets.name', 'LIKE', '%'.$search.'%') ->orWhere('assets.asset_tag', 'LIKE', '%'.$search.'%') ->orWhere('assets.serial', 'LIKE', '%'.$search.'%') @@ -1074,13 +1088,15 @@ class Asset extends Depreciable $query->whereHas('defaultLoc', function ($query) use ($search) { $query->where('locations.id', '=', $search); }); - })->orWhere(function ($query) use ($search) { - $query->whereHas('assigneduser', function ($query) use ($search) { - $query->whereHas('userloc', function ($query) use ($search) { - $query->where('locations.id', '=', $search); - }); - }); }); + // FIXME: This needs porting to checkout to non-user. + // ->orWhere(function ($query) use ($search) { + // $query->whereHas('assigneduser', function ($query) use ($search) { + // $query->whereHas('userloc', function ($query) use ($search) { + // $query->where('locations.id', '=', $search); + // }); + // }); + // }); } diff --git a/app/Models/Consumable.php b/app/Models/Consumable.php index 84d67c4c66..c6f632f52f 100644 --- a/app/Models/Consumable.php +++ b/app/Models/Consumable.php @@ -73,7 +73,7 @@ class Consumable extends SnipeModel return $this->belongsTo('\App\Models\User', 'user_id'); } - public function consumableAssigments() + public function consumableAssignments() { return $this->hasMany('\App\Models\ConsumableAssignment'); } diff --git a/app/Models/Requestable.php b/app/Models/Requestable.php index 3781cbadeb..878c3b69a8 100644 --- a/app/Models/Requestable.php +++ b/app/Models/Requestable.php @@ -19,9 +19,9 @@ trait Requestable public function isRequestedBy(User $user) { - return $this->requests() - ->where('user_id', $user->id) - ->exists(); + $requests = $this->requests->where('user_id', $user->id); + + return $requests->count() > 0; } public function scopeRequestedBy($query, User $user) diff --git a/app/Models/SnipeModel.php b/app/Models/SnipeModel.php index 43cf0cfc92..8e2509ed06 100644 --- a/app/Models/SnipeModel.php +++ b/app/Models/SnipeModel.php @@ -82,4 +82,8 @@ class SnipeModel extends Model { return $this->name; } + + public function name() { + return $this->name; + } } diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index 40cbe5675c..87d4469b50 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -98,7 +98,7 @@ class AssetPresenter extends Presenter "sortable" => true, "title" => trans('admin/hardware/form.checkedout_to'), "visible" => true, - "formatter" => "usersLinkObjFormatter" + "formatter" => "polymorphicItemFormatter" ], [ "field" => "employee_number", "searchable" => false, diff --git a/resources/lang/en/admin/hardware/general.php b/resources/lang/en/admin/hardware/general.php index f7644eb730..1def86dc9e 100644 --- a/resources/lang/en/admin/hardware/general.php +++ b/resources/lang/en/admin/hardware/general.php @@ -7,7 +7,7 @@ return array( 'asset' => 'Asset', 'bulk_checkout' => 'Checkout Assets to User', 'checkin' => 'Checkin Asset', - 'checkout' => 'Checkout Asset to User', + 'checkout' => 'Checkout Asset', 'clone' => 'Clone Asset', 'deployable' => 'Deployable', 'deleted' => 'This asset has been deleted. Click here to restore it.', diff --git a/resources/views/account/requestable-assets.blade.php b/resources/views/account/requestable-assets.blade.php index a615ece5e7..cabe851b6f 100644 --- a/resources/views/account/requestable-assets.blade.php +++ b/resources/views/account/requestable-assets.blade.php @@ -116,7 +116,7 @@ > {{ csrf_field() }} {{$requestableModel->name}} - {{$requestableModel->assets()->where('requestable', '1')->count()}} + {{$requestableModel->assets->where('requestable', '1')->count()}} @if ($requestableModel->isRequestedBy(Auth::user())) diff --git a/resources/views/asset_maintenances/index.blade.php b/resources/views/asset_maintenances/index.blade.php index 5a3aa18ef8..4b604f2b0a 100644 --- a/resources/views/asset_maintenances/index.blade.php +++ b/resources/views/asset_maintenances/index.blade.php @@ -60,15 +60,21 @@ @include ('partials.bootstrap-table', ['exportFile' => 'maintenances-export', 'search' => true]) diff --git a/resources/views/consumables/view.blade.php b/resources/views/consumables/view.blade.php index 7032d2c7a5..820f69dc51 100644 --- a/resources/views/consumables/view.blade.php +++ b/resources/views/consumables/view.blade.php @@ -35,7 +35,7 @@ name="consumable_users" class="table table-striped snipe-table" id="table" - data-url="{{route('api.consumables.show', $consumable->id)}}" + data-url="{{route('api.consumables.showUsers', $consumable->id)}}" data-cookie="true" data-click-to-select="true" data-cookie-id-table="consumableDetailTable-{{ config('version.hash_version') }}" diff --git a/resources/views/hardware/bulk-delete.blade.php b/resources/views/hardware/bulk-delete.blade.php index 86faff44a4..c433a6f831 100644 --- a/resources/views/hardware/bulk-delete.blade.php +++ b/resources/views/hardware/bulk-delete.blade.php @@ -48,7 +48,7 @@ @if ($asset->assignedTo) - {{ $asset->assignedTo->present()->name().' ' .$asset->assigneduser ? '('.$asset->assigneduser->username. ')' : ''}} + {{ $asset->assignedTo->present()->name()}} @endif diff --git a/resources/views/hardware/qr-view.blade.php b/resources/views/hardware/qr-view.blade.php index 30e234e608..c2f52df1b1 100644 --- a/resources/views/hardware/qr-view.blade.php +++ b/resources/views/hardware/qr-view.blade.php @@ -334,12 +334,12 @@ @endif - @if (($asset->assigneduser) && ($asset->assigned_to > 0) && ($asset->deleted_at=='')) + @if (($asset->checkedOutToUser()) && ($asset->assigned_to > 0) && ($asset->deleted_at=='')) {{-- @TODO This should be extnded for details about non users --}}

{{ trans('admin/hardware/form.checkedout_to') }}
@endif diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 8ffa1b0c55..27f9315f30 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -401,19 +401,19 @@ @if (($asset->assignedTo) && ($asset->deleted_at==''))

{{ trans('admin/hardware/form.checkedout_to') }}

- @if($asset->assigned_type == User::class) - {{ $asset->assigneduser->present()->fullName() }} + @if($asset->checkedOutToUser()) + {{ $asset->assignedTo->present()->fullName() }} @endif {!! $asset->assignedTo->present()->glyph() . ' ' .$asset->assignedTo->present()->nameUrl() !!}