This commit is contained in:
2026-05-09 01:18:51 +02:00
parent 7116ee4619
commit 959970c150
132 changed files with 21310 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Storage;
class ProductImportSeeder extends Seeder
{
public function run(): void
{
$categories = ['Electronics', 'Clothing', 'Home & Garden', 'Sports', 'Books', 'Toys', 'Food', 'Health'];
$csv = "sku,name,description,price,stock_quantity,category\n";
for ($i = 1; $i <= 500; $i++) {
$sku = 'SKU-' . str_pad((string) $i, 5, '0', STR_PAD_LEFT);
$name = 'Product ' . $i;
$description = 'Description for product ' . $i . '. This is a sample product for the Temporal import demo.';
$price = round(mt_rand(100, 99999) / 100, 2);
$stock = mt_rand(0, 1000);
$category = $categories[array_rand($categories)];
$csv .= "{$sku},{$name},\"{$description}\",{$price},{$stock},{$category}\n";
}
$dir = storage_path('app/imports');
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
file_put_contents(storage_path('app/imports/products.csv'), $csv);
$this->command->info('Generated 500-row products.csv at storage/app/imports/products.csv');
}
}