firstcommit

This commit is contained in:
2025-08-17 16:23:14 +05:45
commit 76bf4c0a18
2648 changed files with 362795 additions and 0 deletions

View File

View File

@@ -0,0 +1,71 @@
<?php
namespace Modules\Banner\database\seeders;
use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use Modules\Banner\app\Models\Banner;
use Illuminate\Support\Facades\Storage;
class BannerDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$banners = [
[
'title' => 'Adventure Awaits',
'link' => 'https://jhigucms.com/adventure-awaits',
'ordering' => 1,
'caption' => 'Embark on an exciting journey with us. Discover new places and create lasting memories.',
'image' => '2.jpg'
],
[
'title' =>'Journey of Discovery',
'link' => 'https://jhigucms.com/adventure-awaits',
'ordering' => 2,
'caption' => 'Discover hidden gems and make every moment count on your travels.',
'image' => '1.jpg'
],
];
foreach ($banners as $banner) {
$cmsbanner = Banner::create([
'uuid' => Str::uuid(),
'title' => $banner['title'],
'link' => $banner['link'],
'ordering' => $banner['ordering'],
'caption' => $banner['caption'],
]);
// Add image to the created banner
$this->uploadImageForBanner($banner['image'], $cmsbanner);
}
}
private function uploadImageForBanner(string $imageFileName, $cmsbanner)
{
$seederDirPath = 'banners/';
// Generate a unique filename for the new image
$newFileName = Str::uuid() . '.jpg';
// Storage path for the new image
$storagePath = '/banners/' . $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();
}
}
}