Added created_by to components

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-09-19 17:01:36 +01:00
parent 951f03094a
commit 6699995972
2 changed files with 8 additions and 0 deletions

View file

@ -98,6 +98,9 @@ class ComponentsController extends Controller
case 'supplier': case 'supplier':
$components = $components->OrderSupplier($order); $components = $components->OrderSupplier($order);
break; break;
case 'created_by':
$components = $components->OrderByCreatedBy($order);
break;
default: default:
$components = $components->orderBy($column_sort, $order); $components = $components->orderBy($column_sort, $order);
break; break;

View file

@ -310,4 +310,9 @@ class Component extends SnipeModel
{ {
return $query->leftJoin('suppliers', 'components.supplier_id', '=', 'suppliers.id')->orderBy('suppliers.name', $order); return $query->leftJoin('suppliers', 'components.supplier_id', '=', 'suppliers.id')->orderBy('suppliers.name', $order);
} }
public function scopeOrderByCreatedBy($query, $order)
{
return $query->leftJoin('users as admin_sort', 'components.created_by', '=', 'admin_sort.id')->select('components.*')->orderBy('admin_sort.first_name', $order)->orderBy('admin_sort.last_name', $order);
}
} }