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

@ -112,6 +112,9 @@ class AccessoriesController extends Controller
case 'supplier': case 'supplier':
$accessories = $accessories->OrderSupplier($order); $accessories = $accessories->OrderSupplier($order);
break; break;
case 'created_by':
$accessories = $accessories->OrderByCreatedByName($order);
break;
default: default:
$accessories = $accessories->orderBy($column_sort, $order); $accessories = $accessories->orderBy($column_sort, $order);
break; 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 * Query builder scope to order on company
* *

View file

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