- 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
31 lines
856 B
PHP
31 lines
856 B
PHP
<?php
|
|
|
|
namespace App\Containers\Dashboard\Actions\Departments;
|
|
|
|
use App\Containers\InstituteStructure\Models\Department;
|
|
|
|
class ListDepartmentTeachersAction
|
|
{
|
|
public function run(Department $department, array $filters = []): array
|
|
{
|
|
$query = $department->teachers();
|
|
|
|
// Поиск по имени
|
|
if (!empty($filters['search'])) {
|
|
$query->where('name', 'like', '%' . $filters['search'] . '%');
|
|
}
|
|
|
|
// Фильтр по должности
|
|
if (!empty($filters['position'])) {
|
|
$query->wherePivot('teaching_position', 'like', '%' . $filters['position'] . '%');
|
|
}
|
|
|
|
$teachers = $query->orderBy('teachers_departments.sort')->paginate(20)->withQueryString();
|
|
|
|
return [
|
|
'teachers' => $teachers,
|
|
'filters' => $filters,
|
|
];
|
|
}
|
|
}
|