small fix
This commit is contained in:
@@ -7,43 +7,50 @@ use App\Containers\AppStructure\UI\WEB\Transformers\PageResource;
|
||||
use App\Ship\Contracts\SeoServiceInterface;
|
||||
use App\Ship\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
public function __construct(readonly SeoServiceInterface $seoPageProvider){}
|
||||
|
||||
public function render(string $path): \Inertia\Response
|
||||
public function render(string $path): Response
|
||||
{
|
||||
// Генерируем уникальный ключ для кеширования
|
||||
$cacheKey = 'page_' . md5($path);
|
||||
|
||||
// Пытаемся получить данные из кеша
|
||||
$page = Cache::remember($cacheKey, now()->addHours(48), function () use ($path) {
|
||||
return Page::where('path', '=', $path)
|
||||
->with('section.pages.section', 'section.mainSection')
|
||||
->first();
|
||||
});
|
||||
|
||||
if ($page === null) {
|
||||
abort(404);
|
||||
}
|
||||
$page = $this->getPageByPath($path);
|
||||
$this->handleCheckNotFoundStatusCode($page);
|
||||
$subSectionPages = $page->section ? PageResource::collection($page->section->pages) : null;
|
||||
|
||||
$seo = $this->seoPageProvider->getSeoForModel($page);
|
||||
|
||||
|
||||
$page = new PageResource($page);
|
||||
|
||||
|
||||
if ($page->code != 200) {
|
||||
abort($page->code);
|
||||
}
|
||||
$pageResource = new PageResource($page);
|
||||
$this->handlePageStatusCode($pageResource);
|
||||
|
||||
return inertia()->render('Page', [
|
||||
'page' => $page,
|
||||
'page' => $pageResource,
|
||||
'subSectionPages' => $subSectionPages,
|
||||
'seo' => $seo,
|
||||
]);
|
||||
}
|
||||
|
||||
private function handlePageStatusCode(PageResource $pageResource): void
|
||||
{
|
||||
if ($pageResource->code != 200) {
|
||||
abort($pageResource->code);
|
||||
}
|
||||
}
|
||||
|
||||
private function handleCheckNotFoundStatusCode($page): void
|
||||
{
|
||||
if ($page === null) {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPageByPath(string $path): ?Page
|
||||
{
|
||||
$cacheKey = 'page_' . md5($path);
|
||||
|
||||
return Cache::remember($cacheKey, now()->addHours(48), function () use ($path) {
|
||||
return Page::where('path', '=', $path)
|
||||
->with('section.pages.section', 'section.mainSection')
|
||||
->first();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ class MainController extends Controller
|
||||
$event_date_start = (new DateTime())->format('Y-m-d');
|
||||
|
||||
return EventThumbnailResource::collection(
|
||||
Event::select('title', 'slug', 'event_date_start', 'address', 'is_online', 'category_id')
|
||||
Event::select('title', 'slug', 'event_date_start', 'event_time_start' , 'address', 'is_online', 'category_id')
|
||||
->where('event_date_start', '>=', $event_date_start)
|
||||
->orderBy('event_date_start', 'asc')
|
||||
->limit(3)
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
|
||||
namespace App\Services\Filament\Domain\Posts;
|
||||
|
||||
use App\Enums\PostStatus;
|
||||
use App\Jobs\CreateTgPost;
|
||||
use App\Jobs\CreateTgPostJob;
|
||||
use App\Jobs\UpdateTgPost;
|
||||
use App\Models\Post;
|
||||
use App\Containers\Article\Enums\PostStatus;
|
||||
use App\Containers\Article\Models\Post;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user