migrate to gtea from bistbucket
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Restaurant\Database\Seeders;
|
||||
|
||||
use Faker\Factory as Faker;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\Restaurant\Models\Ingredient;
|
||||
use Modules\Restaurant\Models\Supplier;
|
||||
|
||||
class IngredientSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$faker = Faker::create();
|
||||
$restaurantId = 1; // Change or randomize if multi-restaurant setup
|
||||
|
||||
// Try to get existing supplier IDs
|
||||
$supplierIds = Supplier::pluck('id')->toArray();
|
||||
|
||||
$units = [1, 2, 3, 4, 5];
|
||||
$categories = ['Vegetable', 'Meat', 'Dairy', 'Beverage', 'Spices', 'Grains', 'Bakery', 'Seafood', 'Fruits', 'Others'];
|
||||
|
||||
$ingredients = [];
|
||||
|
||||
for ($i = 1; $i <= 50; $i++) {
|
||||
$unit = $faker->randomElement($units);
|
||||
$category = $faker->randomElement($categories);
|
||||
$supplierId = ! empty($supplierIds) ? $faker->randomElement($supplierIds) : null;
|
||||
|
||||
$costPerUnit = $faker->randomFloat(2, 10, 500);
|
||||
$stockQty = $faker->randomFloat(2, 5, 500);
|
||||
$lowStock = $faker->randomFloat(2, 1, 10);
|
||||
|
||||
$ingredients[] = [
|
||||
'restaurant_id' => $restaurantId,
|
||||
'supplier_id' => $supplierId,
|
||||
'name' => ucfirst($faker->word),
|
||||
'unit_id' => $unit,
|
||||
'stock_quantity' => $stockQty,
|
||||
'cost_per_unit' => $costPerUnit,
|
||||
'low_stock_alert' => $lowStock,
|
||||
'last_purchase_price' => $faker->optional()->randomFloat(2, 10, 500),
|
||||
'last_purchase_date' => $faker->optional()->date(),
|
||||
'conversion_factor' => $faker->randomFloat(2, 0.5, 2),
|
||||
'reserved_quantity' => $faker->randomFloat(2, 0, 20),
|
||||
'wastage_quantity' => $faker->randomFloat(2, 0, 10),
|
||||
'category' => $category,
|
||||
'notes' => $faker->optional()->sentence(10),
|
||||
'status' => $faker->randomElement([0, 1]),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
|
||||
Ingredient::insert($ingredients);
|
||||
|
||||
$this->command->info('✅ Seeded 50 ingredients successfully.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user