fix bugs in BreadcrumbService and Person page
This commit is contained in:
@@ -34,6 +34,7 @@ class ClientDepartmentController extends Controller
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// Кешируем список активных кафедр факультета
|
||||
$departments = Cache::remember(
|
||||
CacheKeys::DEPARTMENTS_PREFIX->value . 'active_' . $faculty->id,
|
||||
|
||||
@@ -4,15 +4,8 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\CacheKeys;
|
||||
use App\Http\Resources\ClientFullInfoPersonResource;
|
||||
use App\Http\Resources\ClientNavigationResource;
|
||||
use App\Http\Resources\MainSectionResource;
|
||||
use App\Http\Resources\UserDetailResource;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Models\MainSection;
|
||||
use App\Models\User;
|
||||
use App\Models\UserDetail;
|
||||
use App\Services\App\Seo\SeoPageProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Inertia\Inertia;
|
||||
|
||||
@@ -25,7 +18,7 @@ class PersonController extends Controller
|
||||
$cacheKey = CacheKeys::USER_PREFIX->value . md5($slug);
|
||||
|
||||
[$person, $seo] = Cache::remember($cacheKey, now()->addHours(24), function () use ($slug) {
|
||||
$person = User::query()->with(['userDetail', 'departments_work.faculty', 'departments_teach.faculty', 'divisions', 'faculties', 'seo'])
|
||||
$person = User::query()->with(['userDetail', 'departments_work.faculty', 'departments_teach.faculty', 'divisions', 'faculties'])
|
||||
->where('slug', $slug)
|
||||
->firstOrFail();
|
||||
$seo = $this->seoPageProvider->getSeoForModel($person);
|
||||
@@ -35,6 +28,8 @@ class PersonController extends Controller
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
|
||||
return Inertia::render('Client/Persons/Show', compact('person', 'seo'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ class ClientPersonDepartmentPreviewResource extends JsonResource
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'slug' => $this->slug,
|
||||
'academicTitle' => $this->userDetail->academicTitle,
|
||||
'academicTitle' => $this->userDetail->academicTitle ?? null,
|
||||
'contactPhone' => $this->pivot->service_phone,
|
||||
'contactEmail' => $this->pivot->service_email,
|
||||
'cabinet' => $this->pivot->cabinet,
|
||||
'photo' => $this->userDetail->photo,
|
||||
'photo' => $this->userDetail->photo ?? null,
|
||||
'position' => $this->pivot->position,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -19,14 +19,19 @@ class BreadcrumbService
|
||||
// Пытаемся найти index-версию маршрута
|
||||
$indexRouteName = $this->getIndexRouteName($routeName);
|
||||
|
||||
|
||||
if ($indexRouteName === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Используем index-версию, если она существует
|
||||
$finalRouteName = Route::has($indexRouteName) ? $indexRouteName : $routeName;
|
||||
|
||||
// Используем index-версию, если она существует
|
||||
$finalRouteName = Route::has($indexRouteName) ? $indexRouteName : null;
|
||||
|
||||
if ($finalRouteName === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
$path = $this->generatePath($finalRouteName);
|
||||
@@ -72,6 +77,7 @@ class BreadcrumbService
|
||||
|
||||
// Заменяем последнюю часть на index
|
||||
$parts[count($parts) - 1] = 'index';
|
||||
|
||||
return implode('.', $parts);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class SeoPageProvider
|
||||
fn() => Page::where('path', $path)->first()
|
||||
);
|
||||
|
||||
return $page->seo?->toArray(); // Предполагается, что у модели Page есть поле `seo` (JSON или массив)
|
||||
return $page->seo?->toArray();
|
||||
}
|
||||
|
||||
private function getCurrentPath(): string
|
||||
|
||||
Reference in New Issue
Block a user