195 lines
7.0 KiB
PHP
195 lines
7.0 KiB
PHP
<?php
|
|
|
|
namespace Modules\Page\database\seeders;
|
|
|
|
use Illuminate\Support\Str;
|
|
use Illuminate\Database\Seeder;
|
|
use Modules\Page\app\Models\Page;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class PageDatabaseSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$this->forHomePage();
|
|
$this->forAboutUsPage();
|
|
$this->forHairTransplantPage();
|
|
$this->forServicePage();
|
|
$this->forTeamMemberPage();
|
|
$this->forBlogPage();
|
|
}
|
|
|
|
/**************************** Seeders For Home Page **********************************/
|
|
private function forHomePage()
|
|
{
|
|
$homePage = Page::create([
|
|
'uuid' => Str::uuid(),
|
|
'title' => 'BEST TECHNOLOGY FOR HAIR TRANSPLANT',
|
|
'slug' => 'homepage',
|
|
'summary' => '',
|
|
'description' => '',
|
|
'code' => 'homepage',
|
|
'display_order' => 1,
|
|
]);
|
|
|
|
$homePage->pageMeta()->create([
|
|
'uuid' => Str::uuid(),
|
|
'meta_title' => 'Title for Home Page',
|
|
'meta_description' => 'Meta Description for Home Page',
|
|
'meta_keywords' => 'keyword1, keyword2, keyword3',
|
|
]);
|
|
|
|
}
|
|
|
|
/**************************** Seeders For AboutUs Page **********************************/
|
|
private function forAboutUsPage()
|
|
{
|
|
$aboutUsPage = Page::create([
|
|
'uuid' => Str::uuid(),
|
|
'title' => 'Arogin Health Care',
|
|
'slug' => 'about-us',
|
|
'summary' => 'Arogin Health Care & Research Centre (P) Ltd is a team of highly qualified medical professionals supported by experienced entrepreneurs. No hesitation, we call ourselves as Present & Future of quality medical services. Our consultants follow the standard evidence based guidelines as almost all of them are graduates from reputed medical institutes.',
|
|
'description' => 'Yes, we are here to serve you the best & fulfill a dream of healthy nation. Our tropical medicine expert Dr. Sanjay Acharya says “there are numerous measures of prevention but due to negligence and lack of awareness, we still suffer from diseases which would have not occurred with few simple measures." We, the team Arogin, with our key mantra “Patient care comes first”, dream not just being a top ranked health care hub but also fulfill the dream of healthy nation where people can trust their own domestic service providers.',
|
|
'code' => 'about_us',
|
|
'display_order' => 2,
|
|
]);
|
|
|
|
//-- Add Image
|
|
$this->uploadImageForPage('p4.jpg', $aboutUsPage);
|
|
|
|
$aboutUsPage->pageMeta()->create([
|
|
'uuid' => Str::uuid(),
|
|
'meta_title' => 'Title for About Page',
|
|
'meta_description' => 'Meta Description for About Page',
|
|
'meta_keywords' => 'keyword1, keyword2, keyword3',
|
|
]);
|
|
|
|
}
|
|
|
|
/**************************** Seeders For Hair Transplant Page **********************************/
|
|
private function forHairTransplantPage()
|
|
{
|
|
$servicePage = Page::create([
|
|
'uuid' => Str::uuid(),
|
|
'title' => 'Hair Transplant',
|
|
'slug' => 'hair-transplant',
|
|
'summary' => 'Summary for Hair Transplant Page ',
|
|
'description' => 'Description for Hair Transplant Page',
|
|
'code' => 'hair_transplant',
|
|
'display_order' => 3,
|
|
]);
|
|
|
|
//-- Add Image
|
|
$this->uploadImageForPage('p3.jpg', $servicePage);
|
|
|
|
$servicePage->pageMeta()->create([
|
|
'uuid' => Str::uuid(),
|
|
'meta_title' => 'Title for Page',
|
|
'meta_description' => 'Meta Description for Page',
|
|
'meta_keywords' => 'keyword1, keyword2, keyword3',
|
|
]);
|
|
|
|
}
|
|
|
|
/**************************** Seeders For Team Member Page **********************************/
|
|
private function forTeamMemberPage()
|
|
{
|
|
$servicePage = Page::create([
|
|
'uuid' => Str::uuid(),
|
|
'title' => 'Doctors & Providers',
|
|
'slug' => 'doctor-provider',
|
|
'summary' => 'Summary for Team Member Page ',
|
|
'description' => 'Description for Team Member Page',
|
|
'code' => 'doctor_provider',
|
|
'display_order' => 4,
|
|
]);
|
|
|
|
//-- Add Image
|
|
$this->uploadImageForPage('p3.jpg', $servicePage);
|
|
|
|
$servicePage->pageMeta()->create([
|
|
'uuid' => Str::uuid(),
|
|
'meta_title' => 'Title for Team Member Page',
|
|
'meta_description' => 'Meta Description for Team Member Page',
|
|
'meta_keywords' => 'keyword1, keyword2, keyword3',
|
|
]);
|
|
|
|
}
|
|
|
|
/**************************** Seeders For Service Page **********************************/
|
|
private function forServicePage()
|
|
{
|
|
$servicePage = Page::create([
|
|
'uuid' => Str::uuid(),
|
|
'title' => 'Service',
|
|
'slug' => 'service-single',
|
|
'summary' => 'Summary for Service Page ',
|
|
'description' => 'Description for Service Page',
|
|
'code' => 'service',
|
|
'display_order' => 5,
|
|
]);
|
|
|
|
//-- Add Image
|
|
$this->uploadImageForPage('p3.jpg', $servicePage);
|
|
|
|
$servicePage->pageMeta()->create([
|
|
'uuid' => Str::uuid(),
|
|
'meta_title' => 'Title for Service Page',
|
|
'meta_description' => 'Meta Description for Service Page',
|
|
'meta_keywords' => 'keyword1, keyword2, keyword3',
|
|
]);
|
|
|
|
}
|
|
|
|
/**************************** Seeders For Blog Page **********************************/
|
|
private function forBlogPage()
|
|
{
|
|
$homePage = Page::create([
|
|
'uuid' => Str::uuid(),
|
|
'title' => 'blog ',
|
|
'slug' => 'blog-single',
|
|
'summary' => 'Summary for Blog Page',
|
|
'description' => 'Description for Blog Page',
|
|
'code' => 'blog',
|
|
'display_order' => 6,
|
|
]);
|
|
|
|
//-- Add Image
|
|
$this->uploadImageForPage('p6.jpg', $homePage);
|
|
|
|
$homePage->pageMeta()->create([
|
|
'uuid' => Str::uuid(),
|
|
'meta_title' => 'Title for Blog Page',
|
|
'meta_description' => 'Meta Description for Blog Page',
|
|
'meta_keywords' => 'keyword1, keyword2, keyword3',
|
|
]);
|
|
|
|
}
|
|
|
|
private function uploadImageForPage(string $imageFileName, $cmsbanner)
|
|
{
|
|
$seederDirPath = 'pages/';
|
|
|
|
// Generate a unique filename for the new image
|
|
$newFileName = Str::uuid() . '.jpg';
|
|
|
|
// Storage path for the new image
|
|
$storagePath = '/pages/' . $newFileName;
|
|
|
|
// Check if the image exists in the seeder_disk
|
|
if (Storage::disk('seeder_disk')->exists($seederDirPath . $imageFileName)) {
|
|
// Copy the image from seeder to public
|
|
$fileContents = Storage::disk('seeder_disk')->get($seederDirPath . $imageFileName);
|
|
|
|
Storage::disk('public_uploads')->put($storagePath, $fileContents);
|
|
|
|
$cmsbanner->image = $newFileName;
|
|
$cmsbanner->image_path = $storagePath;
|
|
$cmsbanner->save();
|
|
}
|
|
}
|
|
}
|