31 lines
1016 B
PHP
31 lines
1016 B
PHP
<?php
|
|
|
|
namespace Modules\Restaurant\Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Modules\Restaurant\Models\Ingredient;
|
|
use Modules\Restaurant\Models\IngredientDamage;
|
|
|
|
class IngredientDamageSeeder extends Seeder
|
|
{
|
|
public function run(): void
|
|
{
|
|
$ingredients = Ingredient::limit(5)->get();
|
|
|
|
foreach ($ingredients as $ingredient) {
|
|
IngredientDamage::create([
|
|
'restaurant_id' => $ingredient->restaurant_id,
|
|
'ingredient_id' => $ingredient->id,
|
|
'batch_no' => 'BATCH-'.rand(100, 999),
|
|
'quantity' => rand(1, 20),
|
|
'unit_cost' => rand(10, 500),
|
|
'total_cost' => rand(10, 500) * rand(1, 20),
|
|
'reason' => ['Spoilage', 'Breakage', 'Expired'][array_rand(['Spoilage', 'Breakage', 'Expired'])],
|
|
'damage_date' => now()->subDays(rand(0, 30)),
|
|
'reported_by' => 1, // Admin/User ID
|
|
'status' => 1,
|
|
]);
|
|
}
|
|
}
|
|
}
|