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) {
|
||||
|
||||
Reference in New Issue
Block a user