Added order by created_by to accessories

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-09-19 16:45:39 +01:00
parent a77a7065d7
commit c93229179b
3 changed files with 22 additions and 9 deletions

View file

@ -111,7 +111,10 @@ class AccessoriesController extends Controller
break;
case 'supplier':
$accessories = $accessories->OrderSupplier($order);
break;
break;
case 'created_by':
$accessories = $accessories->OrderByCreatedByName($order);
break;
default:
$accessories = $accessories->orderBy($column_sort, $order);
break;

View file

@ -422,6 +422,16 @@ class Accessory extends SnipeModel
* -----------------------------------------------
**/
/**
* Query builder scope to order on created_by name
*
*/
public function scopeOrderByCreatedByName($query, $order)
{
return $query->leftJoin('users as admin_sort', 'accessories.created_by', '=', 'admin_sort.id')->select('accessories.*')->orderBy('admin_sort.first_name', $order)->orderBy('admin_sort.last_name', $order);
}
/**
* Query builder scope to order on company
*

View file

@ -127,13 +127,6 @@ class AccessoryPresenter extends Presenter
'visible' => false,
'title' => trans('general.notes'),
'formatter' => 'notesFormatter'
], [
'field' => 'change',
'searchable' => false,
'sortable' => false,
'visible' => true,
'title' => trans('general.change'),
'formatter' => 'accessoriesInOutFormatter',
], [
'field' => 'created_by',
'searchable' => false,
@ -157,7 +150,14 @@ class AccessoryPresenter extends Presenter
'title' => trans('general.updated_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
],[
], [
'field' => 'change',
'searchable' => false,
'sortable' => false,
'visible' => true,
'title' => trans('general.change'),
'formatter' => 'accessoriesInOutFormatter',
], [
'field' => 'actions',
'searchable' => false,
'sortable' => false,