- User model: add missing pivot columns (service_email, service_phone, cabinet, sort) to departments_work() and departments_teach() withPivot - ListDepartmentWorkersAction/TeachersAction: fix where() to wherePivot() for position filters - Dashboard Workers/Teachers Index.vue: display validation errors in add/edit modals - Dashboard Workers/Teachers Index.vue: add links to client person pages - DepartmentCacheService: clear person_* cache when department data changes - Filament WorkersRelationManager/TeachersRelationManager: fix pivot columns in table (pivot.position etc), add cache clearing on edit/detach/bulk actions
32 lines
878 B
PHP
32 lines
878 B
PHP
<?php
|
|
|
|
namespace App\Containers\Dashboard\Actions\Departments;
|
|
|
|
use App\Containers\InstituteStructure\Models\Department;
|
|
use App\Containers\User\Models\User;
|
|
|
|
class ListDepartmentWorkersAction
|
|
{
|
|
public function run(Department $department, array $filters = []): array
|
|
{
|
|
$query = $department->workers();
|
|
|
|
// Поиск по имени
|
|
if (!empty($filters['search'])) {
|
|
$query->where('name', 'like', '%' . $filters['search'] . '%');
|
|
}
|
|
|
|
// Фильтр по должности
|
|
if (!empty($filters['position'])) {
|
|
$query->wherePivot('position', 'like', '%' . $filters['position'] . '%');
|
|
}
|
|
|
|
$workers = $query->orderBy('workers_departments.sort')->paginate(20)->withQueryString();
|
|
|
|
return [
|
|
'workers' => $workers,
|
|
'filters' => $filters,
|
|
];
|
|
}
|
|
}
|