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\Contracts\SeoServiceInterface;
use App\Ship\Enums\CacheKeys;
use App\Ship\Models\Seo;
use Illuminate\Support\Facades\Cache;
class GetSeoForPersonTask
{
public function __construct(readonly SeoServiceInterface $seoPageProvider){}
public function run(User $personData): array|null
{
return Cache::remember(
CacheKeys::USER_PREFIX->value . 'seo_' . $personData->slug,
now()->addHours(24),
fn() => $this->seoPageProvider->getSeoForModel($personData)
);
}
}