Narrowed down the accessories, consumables, etc APIs for manufacturer filtering
This commit is contained in:
@@ -29,6 +29,14 @@ class AccessoriesController extends Controller
|
||||
$accessories = $accessories->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$accessories->where('company_id','=',$request->input('company_id'));
|
||||
}
|
||||
|
||||
if ($request->has('manufacturer_id')) {
|
||||
$accessories->where('manufacturer_id','=',$request->input('manufacturer_id'));
|
||||
}
|
||||
|
||||
$offset = $request->input('offset', 0);
|
||||
$limit = $request->input('limit', 50);
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
@@ -32,12 +32,22 @@ class ConsumablesController extends Controller
|
||||
$consumables = $consumables->TextSearch(e($request->input('search')));
|
||||
}
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$consumables->where('company_id','=',$request->input('company_id'));
|
||||
}
|
||||
|
||||
if ($request->has('manufacturer_id')) {
|
||||
$consumables->where('manufacturer_id','=',$request->input('manufacturer_id'));
|
||||
}
|
||||
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
$allowed_columns = ['id','name','order_number','min_amt','purchase_date','purchase_cost','company','category','model_number', 'item_no', 'manufacturer','location','qty'];
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||
|
||||
|
||||
switch ($sort) {
|
||||
case 'category':
|
||||
$consumables = $consumables->OrderCategory($order);
|
||||
@@ -56,6 +66,8 @@ class ConsumablesController extends Controller
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$total = $consumables->count();
|
||||
$consumables = $consumables->skip($offset)->take($limit)->get();
|
||||
return (new ConsumablesTransformer)->transformConsumables($consumables, $total);
|
||||
|
||||
@@ -26,6 +26,19 @@ class LicensesController extends Controller
|
||||
if ($request->has('search')) {
|
||||
$licenses = $licenses->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$licenses->where('company_id','=',$request->input('company_id'));
|
||||
}
|
||||
|
||||
if ($request->has('manufacturer_id')) {
|
||||
$licenses->where('manufacturer_id','=',$request->input('manufacturer_id'));
|
||||
}
|
||||
|
||||
if ($request->has('supplier_id')) {
|
||||
$licenses->where('supplier_id','=',$request->input('supplier_id'));
|
||||
}
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
|
||||
@@ -23,14 +23,14 @@ class AccessoriesTransformer
|
||||
$array = [
|
||||
'id' => $accessory->id,
|
||||
'name' => e($accessory->name),
|
||||
'company' => ($accessory->company) ? $accessory->company : null,
|
||||
'manufacturer' => ($accessory->manufacturer_id) ? $accessory->manufacturer : null,
|
||||
'company' => ($accessory->company) ? ['id' => $accessory->company->id,'name'=> e($accessory->company->name)] : '',
|
||||
'manufacturer' => ($accessory->manufacturer) ? ['id' => $accessory->manufacturer->id,'name'=> e($accessory->manufacturer->name)] : '',
|
||||
'model_number' => ($accessory->model_number) ? e($accessory->model_number) : null,
|
||||
'category' => ($accessory->category_id) ? $accessory->category : null,
|
||||
'location' => ($accessory->location) ? $accessory->location : null,
|
||||
'category' => ($accessory->category) ? ['id' => $accessory->category->id,'name'=> e($accessory->category->name)] : '',
|
||||
'location' => ($accessory->location) ? ['id' => $accessory->location->id,'name'=> e($accessory->location->name)] : '',
|
||||
'notes' => ($accessory->notes) ? e($accessory->notes) : null,
|
||||
'qty' => ($accessory->qty) ? e($accessory->qty) : null,
|
||||
'purchase_date' => ($accessory->purchase_date) ? e($accessory->purchase_date) : null,
|
||||
'purchase_date' => ($accessory->purchase_date) ? Helper::getFormattedDateObject($accessory->purchase_date, 'date') : null,
|
||||
'purchase_cost' => ($accessory->purchase_cost) ? e($accessory->purchase_cost) : null,
|
||||
'order_number' => ($accessory->order_number) ? e($accessory->order_number) : null,
|
||||
'min_qty' => ($accessory->min_amt) ? e($accessory->min_amt) : null,
|
||||
|
||||
Reference in New Issue
Block a user