migrate template
This commit is contained in:
60
database/seeders/ProductSeeder.php
Normal file
60
database/seeders/ProductSeeder.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ProductSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$productsByCategory = [
|
||||
'sygyr-eti' => [
|
||||
['name' => 'Ribeye Bifteği', 'price' => 320, 'price_unit' => 'kg', 'description' => 'Ýag damarlary bilen doly marbleli premium ribeye bifteği.', 'availability_status' => 'available', 'sort_order' => 1],
|
||||
['name' => 'Filé Minyon', 'price' => 480, 'price_unit' => 'kg', 'description' => 'Iň ýumşak we inçe süýümli et, aşpezleriň söýgülisi.', 'availability_status' => 'available', 'sort_order' => 2],
|
||||
['name' => 'T-Bone Bifteği', 'price' => 290, 'price_unit' => 'kg', 'description' => 'Iki sany bifteği bir kesimde — strip we filé.', 'availability_status' => 'available', 'sort_order' => 3],
|
||||
['name' => 'Çarşamba Bifteği', 'price' => 220, 'price_unit' => 'kg', 'description' => 'Güýçli tagamy bilen meşhur ýönekeý biftek.', 'availability_status' => 'available', 'sort_order' => 4],
|
||||
],
|
||||
'goyun-eti' => [
|
||||
['name' => 'Goýun Çapraz Bölegi', 'price' => 180, 'price_unit' => 'kg', 'description' => 'Slow-cook üçin amatly, süýji tagamly goýun eti.', 'availability_status' => 'available', 'sort_order' => 1],
|
||||
['name' => 'Goýun Gyrmak', 'price' => 240, 'price_unit' => 'kg', 'description' => 'El bilen gyrdylan inçe goýun eti.', 'availability_status' => 'available', 'sort_order' => 2],
|
||||
['name' => 'Goýun Kelleçe', 'price' => 160, 'price_unit' => 'kg', 'description' => 'Bahasynyň deregine tagamly we ýumşak et.', 'availability_status' => 'out_of_season', 'sort_order' => 3],
|
||||
],
|
||||
'gos' => [
|
||||
['name' => 'Goş Karbonat', 'price' => 200, 'price_unit' => 'kg', 'description' => 'Galyň dilen premium goş filési.', 'availability_status' => 'available', 'sort_order' => 1],
|
||||
['name' => 'Goş Garnide', 'price' => 170, 'price_unit' => 'kg', 'description' => 'Ýumşak ot kaburga bölekleri.', 'availability_status' => 'available', 'sort_order' => 2],
|
||||
['name' => 'Goş Gyrmak', 'price' => 140, 'price_unit' => 'kg', 'description' => 'El bilen taýýarlanan taze goş gyrmak.', 'availability_status' => 'available', 'sort_order' => 3],
|
||||
],
|
||||
'gus-eti' => [
|
||||
['name' => 'Towuk Döşi', 'price' => 110, 'price_unit' => 'kg', 'description' => 'Süýümli we ýagsyz towuk döşi.', 'availability_status' => 'available', 'sort_order' => 1],
|
||||
['name' => 'Hindi Buty', 'price' => 130, 'price_unit' => 'kg', 'description' => 'Tagamly hindi buty, süýji et.', 'availability_status' => 'available', 'sort_order' => 2],
|
||||
['name' => 'Ördek Döşi', 'price' => 260, 'price_unit' => 'kg', 'description' => 'Baý tagamly premium ördek döşi.', 'availability_status' => 'available', 'sort_order' => 3],
|
||||
],
|
||||
'kolbasalar' => [
|
||||
['name' => 'Gyzgyn Merguez', 'price' => 190, 'price_unit' => 'kg', 'description' => 'Demirgazyk Afrika resepti, harissa we zira bilen.', 'availability_status' => 'available', 'sort_order' => 1],
|
||||
['name' => 'Düzgün Sosis', 'price' => 150, 'price_unit' => 'kg', 'description' => 'Adaty resept bilen el bilen taýýarlanan sosis.', 'availability_status' => 'available', 'sort_order' => 2],
|
||||
['name' => 'Brätworst', 'price' => 170, 'price_unit' => 'kg', 'description' => 'Nemes stili premium doňuz sosisi.', 'availability_status' => 'available', 'sort_order' => 3],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($productsByCategory as $categorySlug => $products) {
|
||||
$category = Category::where('slug', $categorySlug)->first();
|
||||
|
||||
if (! $category) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($products as $productData) {
|
||||
Product::create(array_merge($productData, [
|
||||
'category_id' => $category->id,
|
||||
'slug' => Str::slug($productData['name']),
|
||||
'image' => null,
|
||||
'is_active' => true,
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user