138 lines
8.2 KiB
PHP
138 lines
8.2 KiB
PHP
<?php
|
||
|
||
namespace Modules\Testimonial\database\seeders;
|
||
|
||
use Illuminate\Support\Str;
|
||
use Illuminate\Database\Seeder;
|
||
use Illuminate\Support\Facades\Storage;
|
||
use Modules\Testimonial\app\Models\Testimonial;
|
||
|
||
class TestimonialDatabaseSeeder extends Seeder
|
||
{
|
||
/**
|
||
* Run the database seeds.
|
||
*/
|
||
public function run(): void
|
||
{
|
||
$testimonials = [
|
||
//-- With youtube video link
|
||
[
|
||
'image' => '',
|
||
'name' => 'Paras Khadka',
|
||
'designation' => 'Former Nepali CricketTeam Captain',
|
||
'company' => '',
|
||
'ordering' => 1,
|
||
'statement' => "When I first thought about hair restoration, I thought, ‘is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water?’ So, having gone through this procedure and seeing the results—it’s the same as my natural hair. It IS my hair, so it doesn’t fall out. I would say that Arogin has the most advanced technology on the market right now.",
|
||
'link' => '<iframe width="100%" height="300px" style="border-radius: 12px;" src="https://www.youtube.com/embed/NbFJ8W8L-3s" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'
|
||
],
|
||
[
|
||
'image' => '',
|
||
'name' => 'Paras Khadka',
|
||
'designation' => 'Former Nepali CricketTeam Captain',
|
||
'company' => '',
|
||
'ordering' => 2,
|
||
'statement' => "When I first thought about hair restoration, I thought, ‘is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water?’ So, having gone through this procedure and seeing the results—it’s the same as my natural hair. It IS my hair, so it doesn’t fall out. I would say that Arogin has the most advanced technology on the market right now.",
|
||
'link' => '<iframe width="100%" height="300px" style="border-radius: 12px;" src="https://www.youtube.com/embed/NbFJ8W8L-3s" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'
|
||
],
|
||
[
|
||
'image' => '',
|
||
'name' => 'Paras Khadka',
|
||
'designation' => 'Former Nepali CricketTeam Captain',
|
||
'company' => '',
|
||
'ordering' => 3,
|
||
'statement' => "When I first thought about hair restoration, I thought, ‘is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water?’ So, having gone through this procedure and seeing the results—it’s the same as my natural hair. It IS my hair, so it doesn’t fall out. I would say that Arogin has the most advanced technology on the market right now.",
|
||
'link' => '<iframe width="100%" height="300px" style="border-radius: 12px;" src="https://www.youtube.com/embed/NbFJ8W8L-3s" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'
|
||
],
|
||
[
|
||
'image' => '',
|
||
'name' => 'Paras Khadka',
|
||
'designation' => 'Former Nepali CricketTeam Captain',
|
||
'company' => '',
|
||
'ordering' => 4,
|
||
'statement' => "When I first thought about hair restoration, I thought, ‘is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water?’ So, having gone through this procedure and seeing the results—it’s the same as my natural hair. It IS my hair, so it doesn’t fall out. I would say that Arogin has the most advanced technology on the market right now.",
|
||
'link' => '<iframe width="100%" height="300px" style="border-radius: 12px;" src="https://www.youtube.com/embed/NbFJ8W8L-3s" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'
|
||
],
|
||
|
||
//-- With Image Only
|
||
[
|
||
'image' => 't1.png',
|
||
'name' => 'Rahul Sharma',
|
||
'designation' => '',
|
||
'company' => '',
|
||
'ordering' => 1,
|
||
'statement' => "When I first thought about hair restoration, I thought, ‘is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water?’ So, having gone through this procedure and seeing the results—it’s the same as my natural hair. It IS my hair, so it doesn’t fall out. I would say that Arogin has the most advanced technology on the market right now.",
|
||
'link' => ''
|
||
],
|
||
[
|
||
'image' => 't1.png',
|
||
'name' => 'Rahul Sharma',
|
||
'designation' => '',
|
||
'company' => '',
|
||
'ordering' => 2,
|
||
'statement' => "When I first thought about hair restoration, I thought, ‘is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water?’ So, having gone through this procedure and seeing the results—it’s the same as my natural hair. It IS my hair, so it doesn’t fall out. I would say that Arogin has the most advanced technology on the market right now.",
|
||
'link' => ''
|
||
],
|
||
[
|
||
'image' => 't1.png',
|
||
'name' => 'Rahul Sharma',
|
||
'designation' => '',
|
||
'company' => '',
|
||
'ordering' => 3,
|
||
'statement' => "When I first thought about hair restoration, I thought, ‘is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water?’ So, having gone through this procedure and seeing the results—it’s the same as my natural hair. It IS my hair, so it doesn’t fall out. I would say that Arogin has the most advanced technology on the market right now.",
|
||
'link' => ''
|
||
],
|
||
[
|
||
'image' => 't1.png',
|
||
'name' => 'Rahul Sharma',
|
||
'designation' => '',
|
||
'company' => '',
|
||
'ordering' => 4,
|
||
'statement' => "When I first thought about hair restoration, I thought, ‘is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water?’ So, having gone through this procedure and seeing the results—it’s the same as my natural hair. It IS my hair, so it doesn’t fall out. I would say that Arogin has the most advanced technology on the market right now.",
|
||
'link' => ''
|
||
],
|
||
];
|
||
|
||
|
||
foreach ($testimonials as $testimonial) {
|
||
$cmsTestimonial = Testimonial::create([
|
||
'uuid' => Str::uuid(),
|
||
'name' => $testimonial['name'],
|
||
'designation' => $testimonial['designation'],
|
||
'ordering' => $testimonial['ordering'],
|
||
'statement' => $testimonial['statement'],
|
||
'link' => $testimonial['link'],
|
||
]);
|
||
|
||
if (!empty($testimonial['image'])) {
|
||
// Add image to the created banner
|
||
$this->uploadImageForTestimonial($testimonial['image'], $cmsTestimonial);
|
||
}
|
||
}
|
||
}
|
||
|
||
private function uploadImageForTestimonial(string $imageFileName, $cmsbanner)
|
||
{
|
||
$seederDirPath = 'testimonials/';
|
||
|
||
// Generate a unique filename for the new image
|
||
$newFileName = Str::uuid() . '.jpg';
|
||
|
||
// Storage path for the new image
|
||
$storagePath = '/testimonials/' . $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();
|
||
}
|
||
}
|
||
|
||
|
||
}
|