Changes
This commit is contained in:
@@ -2,10 +2,19 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\EducationalProgramStatus;
|
||||
use App\Enums\PostStatus;
|
||||
use App\Models\AcademicJournal;
|
||||
use App\Models\AdditionalEducation;
|
||||
use App\Models\Department;
|
||||
use App\Models\Division;
|
||||
use App\Models\EducationalProgram;
|
||||
use App\Models\Event;
|
||||
use App\Models\Faculty;
|
||||
use App\Models\LibraryNews;
|
||||
use App\Models\Page;
|
||||
use App\Models\Post;
|
||||
use App\Models\VirtualExhibition;
|
||||
use Illuminate\Console\Command;
|
||||
use Spatie\Sitemap\Sitemap;
|
||||
use Spatie\Sitemap\Tags\Url;
|
||||
@@ -36,6 +45,14 @@ class GenerateSitemap extends Command
|
||||
$this->generatePages($sitemap);
|
||||
$this->generatePosts($sitemap);
|
||||
$this->generateEvents($sitemap);
|
||||
$this->generateFaculties($sitemap);
|
||||
$this->generateDepartments($sitemap);
|
||||
$this->generateDivisisons($sitemap);
|
||||
$this->generateEducationalPrograms($sitemap);
|
||||
$this->generateAdditionalPrograms($sitemap);
|
||||
$this->generateAcademicJournals($sitemap);
|
||||
$this->generateVirtualExhibitions($sitemap);
|
||||
$this->generateLibraryNews($sitemap);
|
||||
|
||||
$sitemap->writeToFile(public_path('sitemap.xml'));
|
||||
}
|
||||
@@ -63,7 +80,7 @@ class GenerateSitemap extends Command
|
||||
|
||||
$this->addUrlsToSitemap($sitemap, $events, function($event) {
|
||||
return [
|
||||
'path' => "/events/{$event->slug}",
|
||||
'path' => route('client.event.show', $event->slug, false),
|
||||
'lastModificationDate' => $event->updated_at,
|
||||
'priority' => 0.5,
|
||||
];
|
||||
@@ -78,13 +95,140 @@ class GenerateSitemap extends Command
|
||||
|
||||
$this->addUrlsToSitemap($sitemap, $posts, function($post) {
|
||||
return [
|
||||
'path' => "/news/{$post->slug}",
|
||||
'path' => route('client.post.show', $post->slug, false),
|
||||
'lastModificationDate' => $post->updated_at,
|
||||
'priority' => 0.5,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
protected function generateEducationalPrograms(Sitemap $sitemap)
|
||||
{
|
||||
$posts = EducationalProgram::query()
|
||||
->where('status', EducationalProgramStatus::PUBLISHED)
|
||||
->whereHas('admission_plans')
|
||||
->get();
|
||||
|
||||
$this->addUrlsToSitemap($sitemap, $posts, function($program) {
|
||||
return [
|
||||
'path' => route('client.program.show', $program->slug, false),
|
||||
'lastModificationDate' => $program->updated_at,
|
||||
'priority' => 0.5,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
protected function generateAdditionalPrograms(Sitemap $sitemap)
|
||||
{
|
||||
$posts = AdditionalEducation::query()
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
|
||||
$this->addUrlsToSitemap($sitemap, $posts, function($program) {
|
||||
return [
|
||||
'path' => route('client.additionalProgram.show', $program->slug, false),
|
||||
'lastModificationDate' => $program->updated_at,
|
||||
'priority' => 0.5,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
protected function generateFaculties(Sitemap $sitemap)
|
||||
{
|
||||
$posts = Faculty::query()
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
|
||||
$this->addUrlsToSitemap($sitemap, $posts, function($faculty) {
|
||||
return [
|
||||
'path' => route('client.faculty.show', $faculty->slug, false),
|
||||
'lastModificationDate' => $faculty->updated_at,
|
||||
'priority' => 0.5,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
protected function generateDepartments(Sitemap $sitemap)
|
||||
{
|
||||
$posts = Department::query()
|
||||
->with('faculty')
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
|
||||
$this->addUrlsToSitemap($sitemap, $posts, function($department) {
|
||||
return [
|
||||
'path' => route('client.department.show', [
|
||||
'facultySlug' => $department->faculty->slug,
|
||||
'departmentSlug' => $department->slug,
|
||||
], false),
|
||||
'lastModificationDate' => $department->updated_at,
|
||||
'priority' => 0.5,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
protected function generateDivisisons(Sitemap $sitemap)
|
||||
{
|
||||
$posts = Division::query()
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
|
||||
$this->addUrlsToSitemap($sitemap, $posts, function($division) {
|
||||
return [
|
||||
'path' => route('client.division.show', $division->slug, false),
|
||||
'lastModificationDate' => $division->updated_at,
|
||||
'priority' => 0.5,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
protected function generateAcademicJournals(Sitemap $sitemap)
|
||||
{
|
||||
$posts = AcademicJournal::query()
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
|
||||
$this->addUrlsToSitemap($sitemap, $posts, function($journal) {
|
||||
return [
|
||||
'path' => route('client.academicJournal.show', $journal->slug, false),
|
||||
'lastModificationDate' => $journal->updated_at,
|
||||
'priority' => 0.5,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
protected function generateLibraryNews(Sitemap $sitemap)
|
||||
{
|
||||
$posts = LibraryNews::query()
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
|
||||
$this->addUrlsToSitemap($sitemap, $posts, function($journal) {
|
||||
return [
|
||||
'path' => route('client.library.news.show', $journal->slug, false),
|
||||
'lastModificationDate' => $journal->updated_at,
|
||||
'priority' => 0.5,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
protected function generateVirtualExhibitions(Sitemap $sitemap)
|
||||
{
|
||||
$posts = VirtualExhibition::query()
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
|
||||
$this->addUrlsToSitemap($sitemap, $posts, function($exhibition) {
|
||||
return [
|
||||
'path' => route('client.library.exhibition.show', $exhibition->slug, false),
|
||||
'lastModificationDate' => $exhibition->updated_at,
|
||||
'priority' => 0.5,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function addUrlsToSitemap(Sitemap $sitemap, $items, callable $callback)
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateAcademicJournal extends CreateRecord
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
$this->seoData = $this->generateSeo($data);
|
||||
$data['search_data'] = $this->generateSearchData($data['about_program']);
|
||||
$data['search_data'] = $this->generateSearchData($data['main_info']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class EditAcademicJournal extends EditRecord
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
$this->seoData = $this->generateSeo($data);
|
||||
$data['search_data'] = $this->generateSearchData($data['about_program']);
|
||||
$data['search_data'] = $this->generateSearchData($data['main_info']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ class EducationalProgramResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name')->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')->sortable()->searchable(),
|
||||
Tables\Columns\TextColumn::make('code_napr'),
|
||||
Tables\Columns\TextColumn::make('directionStudy.lvl_edu')->limit(30),
|
||||
])
|
||||
|
||||
@@ -3,10 +3,38 @@
|
||||
namespace App\Filament\Resources\UserResource\Pages;
|
||||
|
||||
use App\Filament\Resources\UserResource;
|
||||
use App\Models\User;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
$data['slug'] = $this->generateUniqueSlug($data['name']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function generateUniqueSlug(string $name): string
|
||||
{
|
||||
// Преобразуем имя в slug (например, заменяем пробелы на дефисы и приводим к нижнему регистру)
|
||||
$slug = Str::slug($name);
|
||||
|
||||
// Проверяем, существует ли slug в базе данных
|
||||
$count = 1;
|
||||
$baseSlug = $slug;
|
||||
|
||||
while (User::where('slug', $slug)->exists()) {
|
||||
// Если slug существует, добавляем суффикс
|
||||
$slug = $baseSlug . '-' . $count;
|
||||
$count++;
|
||||
}
|
||||
|
||||
return $slug;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,42 @@
|
||||
namespace App\Filament\Resources\UserResource\Pages;
|
||||
|
||||
use App\Filament\Resources\UserResource;
|
||||
use App\Models\User;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EditUser extends EditRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
$data['slug'] = $this->generateUniqueSlug($data['name']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function generateUniqueSlug(string $name): string
|
||||
{
|
||||
// Преобразуем имя в slug (например, заменяем пробелы на дефисы и приводим к нижнему регистру)
|
||||
$slug = Str::slug($name);
|
||||
|
||||
// Проверяем, существует ли slug в базе данных
|
||||
$count = 1;
|
||||
$baseSlug = $slug;
|
||||
|
||||
while (User::where('slug', $slug)->exists()) {
|
||||
// Если slug существует, добавляем суффикс
|
||||
$slug = $baseSlug . '-' . $count;
|
||||
$count++;
|
||||
}
|
||||
|
||||
return $slug;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -18,9 +18,9 @@ class ClientLibraryNewsController extends Controller
|
||||
return Inertia::render('Client/Library-news/Index', compact('posts'));
|
||||
}
|
||||
|
||||
public function show(string $id)
|
||||
public function show(string $slug)
|
||||
{
|
||||
$post = new ClientLibraryPostListResource(LibraryNews::query()->find($id));
|
||||
$post = new ClientLibraryPostListResource(LibraryNews::query()->where('slug', $slug)->firstOrFail());
|
||||
return Inertia::render('Client/Library-news/Show', compact('post'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,14 +113,15 @@ class ClientProgramController extends Controller
|
||||
|
||||
public function show(string $slug)
|
||||
{
|
||||
$program = new EducationalProgramFullResource(EducationalProgram::query()->where('slug', $slug)->with(['admission_plans', 'directionStudy'])->first());
|
||||
$program = new EducationalProgramFullResource(EducationalProgram::query()->where('slug', $slug)->with(['admission_plans', 'directionStudy'])->firstOrFail());
|
||||
$formsEducational = BudgetEducation::cases();
|
||||
$formsEducational = collect($formsEducational);
|
||||
$formsEdu = $formsEducational->mapWithKeys(function ($formEducational) {
|
||||
return [$formEducational->value => $formEducational->getLabel()];
|
||||
});
|
||||
|
||||
$seo = $this->seo;
|
||||
dd($program);
|
||||
$seo = $program->seo;
|
||||
return Inertia::render('Client/Programs/Show', compact('program', 'formsEdu', 'seo'));
|
||||
}
|
||||
|
||||
@@ -158,41 +159,5 @@ class ClientProgramController extends Controller
|
||||
});
|
||||
}]);
|
||||
}
|
||||
// public function bakalavriat()
|
||||
// {
|
||||
// $naprs = DirectionStudyResource::collection(
|
||||
// DirectionStudy::forBachelorLevel()
|
||||
// ->withActiveAdmissionCampaign()
|
||||
// ->withActivePrograms()
|
||||
// ->get()
|
||||
// );
|
||||
// $campaignName = $this->getAdmissionCampaignName();
|
||||
// return Inertia::render('Client/Programs/Index', compact('naprs', 'campaignName'));
|
||||
// }
|
||||
//
|
||||
// public function spo()
|
||||
// {
|
||||
// $naprs = DirectionStudyResource::collection(
|
||||
// DirectionStudy::forMiddleLevel()
|
||||
// ->withActiveAdmissionCampaign()
|
||||
// ->withActivePrograms()
|
||||
// ->get()
|
||||
// );
|
||||
// $campaignName = $this->getAdmissionCampaignName();
|
||||
// return Inertia::render('Client/Programs/Index', compact('naprs', 'campaignName'));
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public function magistratura()
|
||||
// {
|
||||
// $naprs = DirectionStudyResource::collection(
|
||||
// DirectionStudy::forMasterLevel()
|
||||
// ->withActiveAdmissionCampaign()
|
||||
// ->withActivePrograms()
|
||||
// ->get()
|
||||
// );
|
||||
// $campaignName = $this->getAdmissionCampaignName();
|
||||
// return Inertia::render('Client/Programs/Index', compact('naprs', 'campaignName'));
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ class ClientVirtualExhibitionController extends Controller
|
||||
return Inertia::render('Client/Library-exhibitions/Index', compact('exhibitions'));
|
||||
}
|
||||
|
||||
public function show(string $id)
|
||||
public function show(string $slug)
|
||||
{
|
||||
$exhibition = new ClientVirtualExhibitionListResource(VirtualExhibition::query()->find($id));
|
||||
$exhibition = new ClientVirtualExhibitionListResource(VirtualExhibition::query()->where('slug', $slug)->firstOrFail());
|
||||
return Inertia::render('Client/Library-exhibitions/Show', compact('exhibition'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,8 @@ class GenerateSitemapController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$sitemap = Sitemap::create();
|
||||
|
||||
$this->generatePages($sitemap);
|
||||
$this->generatePosts($sitemap);
|
||||
|
||||
$sitemap->writeToFile(public_path('sitemap.xml'));
|
||||
}
|
||||
|
||||
protected function generatePages(Sitemap $sitemap)
|
||||
|
||||
@@ -43,7 +43,7 @@ class MainController extends Controller
|
||||
|
||||
$path = route('index', null, false);
|
||||
$page = Page::where('path', $path)->first();
|
||||
$seo = $page->seo;
|
||||
$seo = $page->seo ?? null;
|
||||
|
||||
return Inertia::render('Main', compact('posts', 'events', 'sliders', 'educations', 'seo'));
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ class PersonController extends Controller
|
||||
return Inertia::render('Client/Persons/Index', compact('persons', 'filters'));
|
||||
}
|
||||
|
||||
public function show(string $id)
|
||||
public function show(string $slug)
|
||||
{
|
||||
$person = new ClientFullInfoPersonResource(User::query()->with(['userDetail', 'departments_work.faculty', 'departments_teach.faculty', 'divisions', 'faculties'])->where('id', $id)->firstOrFail());
|
||||
$person = new ClientFullInfoPersonResource(User::query()->with(['userDetail', 'departments_work.faculty', 'departments_teach.faculty', 'divisions', 'faculties'])->where('slug', $slug)->firstOrFail());
|
||||
return Inertia::render('Client/Persons/Show', compact('person'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,4 +22,9 @@ class AcademicJournal extends Model
|
||||
{
|
||||
return $this->hasMany(JournalIssue::class);
|
||||
}
|
||||
|
||||
public function seo()
|
||||
{
|
||||
return $this->morphOne(Seo::class, 'seoable');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user