Files
aroginhealthcare/Modules/Testimonial/database/seeders/TestimonialDatabaseSeeder.php
2025-08-17 16:23:14 +05:45

138 lines
8.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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—its the same as my natural hair. It IS my hair, so it doesnt 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—its the same as my natural hair. It IS my hair, so it doesnt 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—its the same as my natural hair. It IS my hair, so it doesnt 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—its the same as my natural hair. It IS my hair, so it doesnt 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—its the same as my natural hair. It IS my hair, so it doesnt 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—its the same as my natural hair. It IS my hair, so it doesnt 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—its the same as my natural hair. It IS my hair, so it doesnt 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—its the same as my natural hair. It IS my hair, so it doesnt 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();
}
}
}