add new default color and fix bugs
This commit is contained in:
@@ -52,25 +52,21 @@ class ClientAdditionalEducationController extends Controller
|
||||
CacheKeys::ADDITIONAL_EDUCATIONAL_PROGRAMS_PREFIX->value . $cacheKey,
|
||||
now()->addDay(),
|
||||
function () use ($request) {
|
||||
return AdditionalEducationCategoryResource::collection(
|
||||
AdditionalEducationCategory::query()
|
||||
->WithActivePrograms()
|
||||
->where('is_active', true)
|
||||
->when($request->direction, fn ($q, $direction) =>
|
||||
$q->whereHas('direction', fn ($query) => $query->where('slug', $direction))
|
||||
)
|
||||
->when($request->form, fn ($query, $form) =>
|
||||
$query->whereHas('additionalEducations', fn ($q) =>
|
||||
$q->where('form_education', FormEducation::fromName($form))
|
||||
)
|
||||
->when($request->category, fn ($query) =>
|
||||
is_array($request->category)
|
||||
? $query->whereIn('slug', $request->category)
|
||||
: $query
|
||||
$query = AdditionalEducationCategory::query()
|
||||
->WithActivePrograms()
|
||||
->where('is_active', true)
|
||||
->when($request->direction, function ($q, $direction) use ($request) {
|
||||
return $q->whereHas('direction', fn($query) => $query->where('slug', $direction))
|
||||
->when($request->form, fn($query, $form) => $query->whereHas('additionalEducations', fn($q) => $q->where('form_education', FormEducation::fromName($form))
|
||||
)
|
||||
->has('additionalEducations')
|
||||
->get()
|
||||
));
|
||||
->when($request->category, fn($query) => is_array($request->category)
|
||||
? $query->whereIn('slug', $request->category)
|
||||
: $query->where('slug', $request->category)
|
||||
)
|
||||
->has('additionalEducations'));
|
||||
});
|
||||
|
||||
return AdditionalEducationCategoryResource::collection($query->get());
|
||||
}
|
||||
);
|
||||
|
||||
@@ -124,7 +120,6 @@ class ClientAdditionalEducationController extends Controller
|
||||
|
||||
$seo = $this->seoPageProvider->getSeoForCurrentPage();
|
||||
|
||||
|
||||
return Inertia::render('Client/Additional-educations/Index', compact(
|
||||
'directionAdditionalEducations',
|
||||
'additionalEducations',
|
||||
@@ -134,6 +129,7 @@ class ClientAdditionalEducationController extends Controller
|
||||
'seo'
|
||||
));
|
||||
}
|
||||
|
||||
public function show(string $slug): \Inertia\Response
|
||||
{
|
||||
$additionalEducationModel = Cache::remember(
|
||||
|
||||
@@ -25,7 +25,7 @@ class ClientPostController extends Controller
|
||||
{
|
||||
public function __construct(readonly SeoPageProvider $seoPageProvider){}
|
||||
|
||||
public function index(Request $request)
|
||||
public function index(Request $request): \Inertia\Response
|
||||
{
|
||||
// Кешируем список тегов
|
||||
$tagIds = Cache::remember('tag_ids', now()->addHours(), function () {
|
||||
@@ -37,12 +37,10 @@ class ClientPostController extends Controller
|
||||
->pluck('tag_id');
|
||||
});
|
||||
|
||||
// Кешируем теги
|
||||
$tags = Cache::remember('tags', now()->addHours(1), function () use ($tagIds) {
|
||||
return \Spatie\Tags\Tag::whereIn('id', $tagIds)->get();
|
||||
});
|
||||
|
||||
// Кешируем посты с учетом фильтров
|
||||
$cacheKey = 'posts_' . md5(serialize($request->all()));
|
||||
$posts = Cache::remember($cacheKey, now()->addHours(1), function () use ($request) {
|
||||
return ClientPostListResource::collection(Post::query()
|
||||
@@ -74,12 +72,10 @@ class ClientPostController extends Controller
|
||||
->withQueryString());
|
||||
});
|
||||
|
||||
// Кешируем категории
|
||||
$categories = Cache::remember('categories', now()->addHours(48), function () {
|
||||
return CategoryResource::collection(Category::has('posts')->get());
|
||||
});
|
||||
|
||||
// Кешируем контент категорий
|
||||
$categoriesContent = [];
|
||||
if ($request->input('category')) {
|
||||
foreach ($request->input('category') as $item) {
|
||||
@@ -133,12 +129,8 @@ class ClientPostController extends Controller
|
||||
return Inertia::render('Client/Posts/Index', compact('filters', 'posts', 'categories', 'tags', 'seo'));
|
||||
}
|
||||
|
||||
public function show(Request $request, $slug)
|
||||
public function show(Request $request, $slug): \Inertia\Response
|
||||
{
|
||||
// Уникальный ключ для кеширования
|
||||
$cacheKey = 'post_' . md5($slug);
|
||||
|
||||
// Пытаемся получить данные из кеша
|
||||
$postData = Cache::remember(
|
||||
CacheKeys::POST_PREFIX->value . $slug,
|
||||
now()->addHours(1),
|
||||
@@ -157,7 +149,7 @@ class ClientPostController extends Controller
|
||||
|
||||
|
||||
// Возвращаем ответ с использованием кешированных данных
|
||||
return Inertia::render('Client/Posts/Show', compact(''));
|
||||
return Inertia::render('Client/Posts/Show', compact('post', 'seo'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user