diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 033e4e882b..750174e3b5 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -92,6 +92,10 @@ class AssetsController extends Controller $assets->InCategory($request->input('category_id')); } + if ($request->has('manufacturer_id')) { + $assets->ByManufacturer($request->input('manufacturer_id')); + } + $request->has('order_number') ? $assets = $assets->where('order_number', '=', e($request->get('order_number'))) : ''; $offset = request('offset', 0); diff --git a/app/Models/Asset.php b/app/Models/Asset.php index e403623784..4aaf96f367 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -843,6 +843,22 @@ class Asset extends Depreciable ->join('categories', 'models.category_id', '=', 'categories.id')->where('models.category_id','=',$category_id); } + /** + * Query builder scope to return results of a manufacturer + * + * @param \Illuminate\Database\Query\Builder $query Query builder instance + * @param text $order Order + * + * @return \Illuminate\Database\Query\Builder Modified query builder + */ + public function scopeByManufacturer($query, $manufacturer_id) + { + return $query->join('models', 'assets.model_id', '=', 'models.id') + ->join('manufacturers', 'models.manufacturer_id', '=', 'manufacturers.id')->where('models.manufacturer_id','=',$manufacturer_id); + } + + + /** * Query builder scope to order on category * diff --git a/resources/views/categories/view.blade.php b/resources/views/categories/view.blade.php index 36c965709d..f8582602d9 100644 --- a/resources/views/categories/view.blade.php +++ b/resources/views/categories/view.blade.php @@ -30,7 +30,7 @@ name="category_assets" class="snipe-table" id="table" - data-url="{{ ($category->category_type=='asset') ? route('api.assets.index',['category_id'=> $category->id]) : route('api'.$category->category_type.'index', ['category_id'=> $category->id]) }} + data-url="{{ ($category->category_type=='asset') ? route('api.assets.index',['category_id'=> $category->id]) : route('api.'.$category->category_type.'s.index', ['category_id'=> $category->id]) }} data-cookie="true" data-click-to-select="true" data-cookie-id-table="categoryAssetsTable"> diff --git a/resources/views/manufacturers/index.blade.php b/resources/views/manufacturers/index.blade.php index 86d41743d2..13d948e3d3 100755 --- a/resources/views/manufacturers/index.blade.php +++ b/resources/views/manufacturers/index.blade.php @@ -31,7 +31,8 @@ {{ trans('general.id') }} - {{ trans('admin/manufacturers/table.name') }} + + {{ trans('admin/manufacturers/table.name') }} {{ trans('general.assets') }} {{ trans('general.licenses') }} {{ trans('general.accessories') }} diff --git a/resources/views/manufacturers/view.blade.php b/resources/views/manufacturers/view.blade.php index 9d782b3868..ae7d59d98f 100644 --- a/resources/views/manufacturers/view.blade.php +++ b/resources/views/manufacturers/view.blade.php @@ -48,22 +48,22 @@ name="manufacturer_assets" class="table table-striped bootstrap-table snipe-table" id="assets-table" - data-url="{{ route('api.manufacturers.show', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'assets']) }}" + data-url="{{ route('api.assets.index', ['manufacturer_id' => $manufacturer->id, 'itemtype' => 'assets']) }}" data-cookie="true" data-click-to-select="true" - data-cookie-id-table="maufacturerAssetsTable-{{config('version.hash_version') }}" - > + data-cookie-id-table="maufacturerAssetsTable-{{config('version.hash_version') }}"> - + {{ trans('general.id') }} + {{ trans('admin/companies/table.title') }} - {{ trans('general.id') }} - {{ trans('general.name') }} - {{ trans('admin/hardware/form.model') }} - {{ trans('general.asset_tag') }} - {{ trans('admin/hardware/form.serial') }} - {{ trans('general.user') }} + {{ trans('general.name') }} + {{ trans('admin/hardware/table.image') }} + {{ trans('admin/hardware/form.model') }} + {{ trans('general.asset_tag') }} + {{ trans('admin/hardware/form.serial') }} + {{ trans('general.user') }} {{ trans('admin/hardware/table.change') }} {{ trans('table.actions') }}