From d484636bbabccb558598d36f26c9503018df8fde Mon Sep 17 00:00:00 2001 From: Daniel Meltzer Date: Tue, 28 Jun 2016 01:32:40 -0400 Subject: [PATCH 1/2] Add model number column to the hardware list. (#2204) * Add model number column to the hardware list and allow searching based on model number. Column is hidden by default. * Fix sorting. Add scope to order by model number. --- app/Http/Controllers/AssetsController.php | 5 +++++ app/Models/Asset.php | 16 +++++++++++++++- resources/views/hardware/index.blade.php | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index 943a4a52d1..13774ba549 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -1425,6 +1425,7 @@ class AssetsController extends Controller 'asset_tag', 'serial', 'model', + 'model_number', 'last_checkout', 'category', 'manufacturer', @@ -1452,6 +1453,9 @@ class AssetsController extends Controller case 'model': $assets = $assets->OrderModels($order); break; + case 'model_number': + $assets = $assets->OrderModelNumber($order); + break; case 'category': $assets = $assets->OrderCategory($order); break; @@ -1507,6 +1511,7 @@ class AssetsController extends Controller 'asset_tag' => ''.e($asset->asset_tag).'', 'serial' => e($asset->serial), 'model' => ($asset->model) ? (string)link_to('/hardware/models/'.$asset->model->id.'/view', e($asset->model->name)) : 'No model', + 'model_number' => ($asset->model && $asset->model->modelno) ? (string)$asset->model->modelno : '', 'status_label' => ($asset->assigneduser) ? 'Deployed' : ((e($asset->assetstatus)) ? e($asset->assetstatus->name) : ''), 'assigned_to' => ($asset->assigneduser) ? (string)link_to(config('app.url').'/admin/users/'.$asset->assigned_to.'/view', e($asset->assigneduser->fullName())) : '', 'location' => (($asset->assigneduser) && ($asset->assigneduser->userloc!='')) ? (string)link_to('admin/settings/locations/'.$asset->assigneduser->userloc->id.'/edit', e($asset->assigneduser->userloc->name)) : (($asset->defaultLoc!='') ? (string)link_to('admin/settings/locations/'.$asset->defaultLoc->id.'/edit', e($asset->defaultLoc->name)) : ''), diff --git a/app/Models/Asset.php b/app/Models/Asset.php index e2958fcb4c..9d9003f8b0 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -736,7 +736,8 @@ class Asset extends Depreciable $query->whereHas('category', function ($query) use ($search) { $query->where(function ($query) use ($search) { $query->where('categories.name', 'LIKE', '%'.$search.'%') - ->orWhere('models.name', 'LIKE', '%'.$search.'%'); + ->orWhere('models.name', 'LIKE', '%'.$search.'%') + ->orWhere('models.modelno', 'LIKE', '%'.$search.'%'); }); }); })->orWhereHas('model', function ($query) use ($search) { @@ -794,6 +795,19 @@ class Asset extends Depreciable return $query->join('models', 'assets.model_id', '=', 'models.id')->orderBy('models.name', $order); } + /** + * Query builder scope to order on model number + * + * @param Illuminate\Database\Query\Builder $query Query builder instance + * @param text $order Order + * + * @return Illuminate\Database\Query\Builder Modified query builder + */ + public function scopeOrderModelNumber($query, $order) + { + return $query->join('models', 'assets.model_id', '=', 'models.id')->orderBy('models.modelno', $order); + } + /** * Query builder scope to order on assigned user diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.php index bb5b25be45..265422f5b7 100755 --- a/resources/views/hardware/index.blade.php +++ b/resources/views/hardware/index.blade.php @@ -78,6 +78,7 @@ {{ trans('admin/hardware/table.asset_tag') }} {{ trans('admin/hardware/table.serial') }} {{ trans('admin/hardware/form.model') }} + {{ trans('admin/models/table.modelnumber') }} {{ trans('admin/hardware/table.status') }} {{ trans('admin/hardware/form.checkedout_to') }} {{ trans('admin/hardware/table.location') }} From 52c89ca889a886b3b01c31f13071cb5642f7c900 Mon Sep 17 00:00:00 2001 From: Daniel Meltzer Date: Tue, 28 Jun 2016 14:50:11 -0400 Subject: [PATCH 2/2] Hide Delete action if user is deleted. (#2205) Issue: 1493 --- resources/views/users/view.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 8021f1facf..56b7c59581 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -31,7 +31,7 @@