firstcommit
This commit is contained in:
0
Modules/Testimonial/database/factories/.gitkeep
Normal file
0
Modules/Testimonial/database/factories/.gitkeep
Normal file
0
Modules/Testimonial/database/migrations/.gitkeep
Normal file
0
Modules/Testimonial/database/migrations/.gitkeep
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('testimonials', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid();
|
||||
$table->string('name')->nullable();
|
||||
$table->string('designation')->nullable();
|
||||
$table->integer('ordering');
|
||||
$table->string('statement',1000);
|
||||
$table->string('image')->nullable();
|
||||
$table->string('image_path')->nullable();
|
||||
$table->string('status')->default('active');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('testimonials');
|
||||
}
|
||||
};
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('testimonials', function (Blueprint $table) {
|
||||
$table->string('link', 10000)->nullable()->after('image_path');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('testimonials', function (Blueprint $table) {
|
||||
$table->dropColumn('link');
|
||||
});
|
||||
}
|
||||
};
|
0
Modules/Testimonial/database/seeders/.gitkeep
Normal file
0
Modules/Testimonial/database/seeders/.gitkeep
Normal file
@@ -0,0 +1,137 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user