Changes
This commit is contained in:
@@ -22,11 +22,10 @@ class ClientAcademicJournalController extends Controller
|
||||
public function show(string $slug)
|
||||
{
|
||||
$journal = new ClientAcademicJournalListResource(AcademicJournal::query()->where('slug', '=', $slug)->firstOrFail());
|
||||
$journalIssues = JournalIssue::all()
|
||||
->groupBy('year_publication');
|
||||
$journalIssues = JournalIssue::where('academic_journal_id', $journal->id)
|
||||
->groupBy('year_publication')->get();
|
||||
|
||||
$journals = [];
|
||||
$years = JournalIssue::select('year_publication')->distinct()->get();
|
||||
|
||||
foreach ($journalIssues as $year => $journalGroup) {
|
||||
$journals[] = [
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\FormEducation;
|
||||
use App\Http\Resources\ClientEducationalGroupResource;
|
||||
use App\Http\Resources\ScheduleResource;
|
||||
use App\Models\EducationalGroup;
|
||||
@@ -14,22 +15,71 @@ class ClientScheduleController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$educationalGroups = collect();
|
||||
$educationalGroups = ClientEducationalGroupResource::collection(EducationalGroup::query()
|
||||
->has('schedules')
|
||||
->when(request()->input('search'), function ($query, $search) {
|
||||
$query->whereRaw('LOWER(title) like ?', ["%".strtolower($search)."%"]);
|
||||
})
|
||||
->when(request()->input('favorite'), function ($query, $favorite) {
|
||||
$query->whereHas('schedules', function ($query) use ($favorite) {
|
||||
$query->whereIn('id', $favorite);
|
||||
});
|
||||
})
|
||||
->when(request()->input('form'), function ($query, $form) {
|
||||
$query->where('education_form_id', FormEducation::fromName($form)->value);
|
||||
|
||||
if (request()->filled('search')) {
|
||||
$educationalGroups = ClientEducationalGroupResource::collection(EducationalGroup::query()
|
||||
->has('schedules')
|
||||
->when(request()->input('search'), function ($query, $search) {
|
||||
$query->whereRaw('LOWER(title) like ?', ["%".strtolower($search)."%"]);
|
||||
})
|
||||
->with('schedules')
|
||||
->with('faculty')
|
||||
->orderBy('title')
|
||||
->get());
|
||||
})
|
||||
|
||||
->with('schedules')
|
||||
->with('faculty')
|
||||
->orderBy('title')
|
||||
->get());
|
||||
|
||||
$schedulesByFaculty = $educationalGroups->groupBy(function ($group) {
|
||||
return $group->faculty->title; // Предполагаем, что у факультета есть поле 'name'
|
||||
});
|
||||
|
||||
$schedulesByFaculty = $schedulesByFaculty->toArray();
|
||||
|
||||
if ($request->has('favorite') && empty($request->input('favorite'))) {
|
||||
$schedulesByFaculty = [];
|
||||
}
|
||||
$searchRequest = request()->input('search');
|
||||
|
||||
return Inertia::render('Client/Schedules/Index', compact('educationalGroups', 'searchRequest'));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$forms_education = [];
|
||||
foreach (FormEducation::cases() as $case) {
|
||||
$forms_education[$case->name] = $case->getLabel();
|
||||
}
|
||||
|
||||
$filters = [
|
||||
'direction_filter' => [
|
||||
'type' => 'direction',
|
||||
'value' => request()->input('direction'),
|
||||
'param' => 'direction'
|
||||
],
|
||||
'form_education_filter' => [
|
||||
'type' => 'form',
|
||||
'value' => request()->input('form'),
|
||||
'param' => 'form'
|
||||
],
|
||||
'search_filter' => [
|
||||
'type' => 'search',
|
||||
'value' => $request->input('search'),
|
||||
'param' => 'search'
|
||||
],
|
||||
'favorite_filter' => [
|
||||
'type' => 'favorite',
|
||||
'value' => $request->input('favorite'),
|
||||
'param' => 'favorite'
|
||||
]
|
||||
];
|
||||
|
||||
// Возвращаем данные в представление
|
||||
return Inertia::render('Client/Schedules/Index', compact('educationalGroups', 'filters', 'forms_education', 'schedulesByFaculty'));
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
|
||||
@@ -27,6 +27,7 @@ use App\Services\Vicon\EducationalProgram\EducationalProgramService;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
@@ -37,14 +38,32 @@ class MainController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$admissionCampaign = $this->getAdmissionCampaign();
|
||||
$educations = $this->getEducationsData();
|
||||
$sliders = $this->getActiveSliders();
|
||||
$posts = $this->getRecentPosts();
|
||||
$events = $this->getUpcomingEvents();
|
||||
// Кешируем данные на 60 минут (можно изменить время по необходимости)
|
||||
// $admissionCampaign = Cache::remember('admission_campaign', now()->addHour(), function () {
|
||||
// return $this->getAdmissionCampaign();
|
||||
// });
|
||||
|
||||
$educations = Cache::remember('educations_data', now()->addHour(), function () {
|
||||
return $this->getEducationsData();
|
||||
});
|
||||
|
||||
$sliders = Cache::remember('active_sliders', now()->addHour(), function () {
|
||||
return $this->getActiveSliders();
|
||||
});
|
||||
|
||||
$posts = Cache::remember('recent_posts', now()->addHour(), function () {
|
||||
return $this->getRecentPosts();
|
||||
});
|
||||
|
||||
$events = Cache::remember('upcoming_events', now()->addHour(), function () {
|
||||
return $this->getUpcomingEvents();
|
||||
});
|
||||
|
||||
$path = route('index', null, false);
|
||||
$page = Page::where('path', $path)->first();
|
||||
$page = Cache::remember('page_' . $path, now()->addHour(), function () use ($path) {
|
||||
return Page::where('path', $path)->first();
|
||||
});
|
||||
|
||||
$seo = $page->seo ?? null;
|
||||
|
||||
return Inertia::render('Main', compact('posts', 'events', 'sliders', 'educations', 'seo'));
|
||||
@@ -82,11 +101,10 @@ class MainController extends Controller
|
||||
|
||||
private function getActiveSliders()
|
||||
{
|
||||
return ClientMainSliderResource::collection(
|
||||
return (ClientMainSliderResource::collection(
|
||||
MainSlider::where('is_active', true)
|
||||
->orderBy('sort', 'asc')
|
||||
->get()
|
||||
);
|
||||
->get()));
|
||||
}
|
||||
|
||||
private function getRecentPosts()
|
||||
|
||||
Reference in New Issue
Block a user