Fixed sorting issue on company/manufacturer/supplier

This commit is contained in:
snipe 2017-11-02 20:01:39 -07:00
parent 0bd09f9c46
commit 53175d5035

View file

@ -77,14 +77,14 @@ class LicensesController extends Controller
switch ($request->input('sort')) { switch ($request->input('sort')) {
case 'manufacturer': case 'manufacturer':
$licenses = $licenses->OrderManufacturer($order); $licenses = $licenses->leftJoin('manufacturers', 'licenses.manufacturer_id', '=', 'manufacturers.id')->orderBy('manufacturers.name', $order);
break; break;
case 'supplier': case 'supplier':
$licenses = $licenses->OrderSupplier($order); $licenses = $licenses->leftJoin('suppliers', 'licenses.supplier_id', '=', 'suppliers.id')->orderBy('suppliers.name', $order);
break; break;
case 'company': case 'company':
$licenses = $licenses->OrderCompany($order); $licenses = $licenses->leftJoin('companies', 'licenses.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
break; break;
default: default:
$allowed_columns = ['id','name','purchase_cost','expiration_date','purchase_order','order_number','notes','purchase_date','serial','company','license_name','license_email','free_seats_count','seats']; $allowed_columns = ['id','name','purchase_cost','expiration_date','purchase_order','order_number','notes','purchase_date','serial','company','license_name','license_email','free_seats_count','seats'];
@ -95,6 +95,7 @@ class LicensesController extends Controller
$total = $licenses->count(); $total = $licenses->count();
$licenses = $licenses->skip($offset)->take($limit)->get(); $licenses = $licenses->skip($offset)->take($limit)->get();
return (new LicensesTransformer)->transformLicenses($licenses, $total); return (new LicensesTransformer)->transformLicenses($licenses, $total);