- 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
37 lines
975 B
PHP
Executable File
37 lines
975 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Services\App\Cache;
|
|
|
|
use App\Containers\InstituteStructure\Models\Department;
|
|
use App\Ship\Enums\CacheKeys;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class DepartmentCacheService extends AbstractCacheService implements CacheInterface
|
|
{
|
|
private const DEFAULT_TTL = 3600;
|
|
|
|
public function clearCache($entity): void
|
|
{
|
|
if ($entity instanceof Department) {
|
|
$this->clearAllCacheByModel();
|
|
}
|
|
}
|
|
|
|
public function clearAllCacheByModel(): void
|
|
{
|
|
$this->clearCacheByPrefix(CacheKeys::DEPARTMENT_PREFIX->value.'*');
|
|
$this->clearCacheByPrefix(CacheKeys::DEPARTMENTS_PREFIX->value.'*');
|
|
$this->clearCacheByPrefix(CacheKeys::USER_PREFIX->value.'*');
|
|
}
|
|
|
|
public function getCachedData(string $key)
|
|
{
|
|
return Cache::get($key);
|
|
}
|
|
|
|
public function cacheData(string $key, $data, int $ttl = null): void
|
|
{
|
|
Cache::put($key, $data, $ttl ?? self::DEFAULT_TTL);
|
|
}
|
|
|
|
} |