refactor PersonController; replace caching logic with GetPersonDataAction for improved maintainability and clarity

This commit is contained in:
F4ilji
2025-07-18 17:10:49 +05:00
parent de7ef99b47
commit 1fc793089c
5 changed files with 73 additions and 72 deletions
@@ -0,0 +1,23 @@
<?php
namespace App\Containers\User\Tasks;
use App\Containers\User\Models\User;
use App\Ship\Enums\CacheKeys;
use App\Ship\Parents\Tasks\Task;
use Illuminate\Support\Facades\Cache;
class FindPersonBySlugTask
{
public function run(string $slug): User
{
return Cache::remember(
CacheKeys::USER_PREFIX->value . $slug,
now()->addHours(24),
fn() => User::with(['userDetail', 'departments_work.faculty', 'departments_teach.faculty', 'divisions', 'faculties'])
->where('slug', $slug)
->whereHas('userDetail')
->firstOrFail()
);
}
}