Files
ntspi-app/app/Containers/User/UI/WEB/Controllers/PersonController.php
T
F4ilji c01016a154 Migrate backend to Porto architecture and fix minor bugs
- Fully transitioned the backend to the Porto architectural pattern
- Improved code organization and maintainability
- Fixed minor bugs and inconsistencies
2025-05-12 08:47:43 +05:00

41 lines
1.2 KiB
PHP

<?php
namespace App\Containers\User\UI\WEB\Controllers;
use App\Containers\User\Models\User;
use App\Containers\User\UI\WEB\Transformers\FullInfoPersonResource;
use App\Ship\Contracts\SeoServiceInterface;
use App\Ship\Controllers\Controller;
use App\Ship\Enums\CacheKeys;
use Illuminate\Support\Facades\Cache;
use Inertia\Inertia;
class PersonController extends Controller
{
public function __construct(readonly SeoServiceInterface $seoPageProvider){}
public function show(string $slug)
{
$personData = 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)
->firstOrFail()
);
$seo = Cache::remember(
CacheKeys::USER_PREFIX->value . 'seo_' . $slug,
now()->addHours(24),
fn() => $this->seoPageProvider->getSeoForModel($personData)
);
$person = new FullInfoPersonResource($personData);
return Inertia::render('Client/Persons/Show', compact('person', 'seo'));
}
}