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

@@ -0,0 +1,32 @@
<?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('transformations', function (Blueprint $table) {
$table->id();
$table->string('before')->nullable();
$table->string('after')->nullable();
$table->string('name')->nullable();
$table->string('grade')->nullable();
$table->string('graft')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('transformations');
}
};

View File

@@ -0,0 +1,109 @@
<?php
namespace Modules\Transformation\database\seeders;
use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Storage;
use Modules\Transformation\app\Models\Transformation;
class TransformationDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$transformations = [
[
'name' => 'Jane Smith',
'grade' => '05',
'graft' => '3,000',
'before' => 'before.png',
'after' => 'after.png',
],
[
'name' => 'Alex Johnson',
'grade' => '04',
'graft' => '2,800',
'before' => 'before.png',
'after' => 'after.png',
],
[
'name' => 'Emily Brown',
'grade' => '06',
'graft' => '3,200',
'before' => 'before.png',
'after' => 'after.png',
],
[
'name' => 'Michael Davis',
'grade' => '02',
'graft' => '2,200',
'before' => 'before.png',
'after' => 'after.png',
],
];
foreach ($transformations as $transformation) {
$transformationData = Transformation::create([
'name' => $transformation['name'],
'grade' => $transformation['grade'],
'graft' => $transformation['graft'],
]);
// Add image to the created banner
$this->uploadImageForBeforeTransformation($transformation['before'], $transformationData);
$this->uploadImageForAfterTransformation($transformation['after'], $transformationData);
}
}
//-- Upload Before transformation
private function uploadImageForBeforeTransformation(string $imageFileName, $transformation)
{
$seederDirPath = 'transformations/';
// Generate a unique filename for the new image
$newFileName = Str::uuid() . '.jpg';
// Storage path for the new image
$storagePath = '/transformations/' . $newFileName;
// $storagePath = $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);
$transformation->before = $newFileName;
$transformation->save();
}
}
//-- Upload After transformation
private function uploadImageForAfterTransformation(string $imageFileName, $transformation)
{
$seederDirPath = 'transformations/';
// Generate a unique filename for the new image
$newFileName = Str::uuid() . '.jpg';
// Storage path for the new image
$storagePath = '/transformations/' . $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);
$transformation->after = $newFileName;
$transformation->save();
}
}
}