171 lines
7.2 KiB
PHP
171 lines
7.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Product;
|
|
use App\Models\VendingMachine;
|
|
use App\Models\Slot;
|
|
use App\Models\SlotProduct;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class ProductSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
// Beispiel-Produkte erstellen
|
|
$products = [
|
|
[
|
|
'name' => 'Coca Cola 0,33l',
|
|
'description' => 'Erfrischungsgetränk mit Koffein',
|
|
'price' => 1.50,
|
|
'ingredients' => 'Wasser, Zucker, Kohlensäure, Säuerungsmittel Phosphorsäure, natürliches Aroma, Farbstoff E150d, Koffein',
|
|
'allergens' => 'Keine bekannten Allergene',
|
|
'energy_kj' => 180,
|
|
'energy_kcal' => 42,
|
|
'fat' => 0,
|
|
'saturated_fat' => 0,
|
|
'carbohydrates' => 10.6,
|
|
'sugars' => 10.6,
|
|
'protein' => 0,
|
|
'salt' => 0.01,
|
|
'net_weight' => '330ml',
|
|
'manufacturer' => 'The Coca-Cola Company',
|
|
'storage_conditions' => 'Kühl und trocken lagern'
|
|
],
|
|
[
|
|
'name' => 'Fanta Orange 0,33l',
|
|
'description' => 'Orangenlimonade mit Orangengeschmack',
|
|
'price' => 1.50,
|
|
'ingredients' => 'Wasser, Zucker, Orangensaft aus Orangensaftkonzentrat (4%), Kohlensäure, Säuerungsmittel Citronensäure, natürliches Orangenaroma, Antioxidationsmittel Ascorbinsäure, Stabilisator Pektin, Farbstoff Carotin',
|
|
'allergens' => 'Keine bekannten Allergene',
|
|
'energy_kj' => 192,
|
|
'energy_kcal' => 45,
|
|
'fat' => 0,
|
|
'saturated_fat' => 0,
|
|
'carbohydrates' => 11.0,
|
|
'sugars' => 11.0,
|
|
'protein' => 0,
|
|
'salt' => 0.01,
|
|
'net_weight' => '330ml',
|
|
'manufacturer' => 'The Coca-Cola Company',
|
|
'storage_conditions' => 'Kühl und trocken lagern'
|
|
],
|
|
[
|
|
'name' => 'Sprite 0,33l',
|
|
'description' => 'Erfrischungsgetränk mit Zitronen- und Limettengeschmack',
|
|
'price' => 1.50,
|
|
'ingredients' => 'Wasser, Zucker, Kohlensäure, Säuerungsmittel Citronensäure, natürliches Zitronen- und Limettennaroma, Süßungsmittel Steviol Glykoside',
|
|
'allergens' => 'Keine bekannten Allergene',
|
|
'energy_kj' => 144,
|
|
'energy_kcal' => 34,
|
|
'fat' => 0,
|
|
'saturated_fat' => 0,
|
|
'carbohydrates' => 8.5,
|
|
'sugars' => 8.5,
|
|
'protein' => 0,
|
|
'salt' => 0.01,
|
|
'net_weight' => '330ml',
|
|
'manufacturer' => 'The Coca-Cola Company',
|
|
'storage_conditions' => 'Kühl und trocken lagern'
|
|
],
|
|
[
|
|
'name' => 'Mars Riegel 51g',
|
|
'description' => 'Schokoriegel mit Karamell und Nougat',
|
|
'price' => 1.20,
|
|
'ingredients' => 'Glukosesirup, Zucker, Kakaobutter, Magermilchpulver, Kakaomasse, Laktose und Molkeneiweiß, Palmfett, Milchfett, Salz, Emulgator (Sojalecithin), Eiweiß, Vanilleextrakt',
|
|
'allergens' => 'Enthält Milch und Soja. Kann Spuren von Erdnüssen, Nüssen und Gluten enthalten.',
|
|
'energy_kj' => 1870,
|
|
'energy_kcal' => 449,
|
|
'fat' => 17.0,
|
|
'saturated_fat' => 6.8,
|
|
'carbohydrates' => 68.0,
|
|
'sugars' => 59.0,
|
|
'protein' => 4.1,
|
|
'salt' => 0.24,
|
|
'net_weight' => '51g',
|
|
'manufacturer' => 'Mars Wrigley Confectionery',
|
|
'storage_conditions' => 'Trocken lagern und vor Wärme schützen'
|
|
],
|
|
[
|
|
'name' => 'Snickers 50g',
|
|
'description' => 'Schokoriegel mit Erdnüssen, Karamell und Nougat',
|
|
'price' => 1.20,
|
|
'ingredients' => 'Erdnüsse (19%), Glukosesirup, Zucker, Kakaobutter, Magermilchpulver, Kakaomasse, Laktose und Molkeneiweiß, Palmfett, Milchfett, Salz, Emulgator (Sojalecithin), Eiweiß, Vanilleextrakt',
|
|
'allergens' => 'Enthält Erdnüsse, Milch und Soja. Kann Spuren von anderen Nüssen und Gluten enthalten.',
|
|
'energy_kj' => 2034,
|
|
'energy_kcal' => 488,
|
|
'fat' => 24.0,
|
|
'saturated_fat' => 9.3,
|
|
'carbohydrates' => 56.0,
|
|
'sugars' => 48.0,
|
|
'protein' => 9.0,
|
|
'salt' => 0.32,
|
|
'net_weight' => '50g',
|
|
'manufacturer' => 'Mars Wrigley Confectionery',
|
|
'storage_conditions' => 'Trocken lagern und vor Wärme schützen'
|
|
]
|
|
];
|
|
|
|
foreach ($products as $productData) {
|
|
Product::create($productData);
|
|
}
|
|
|
|
// Beispiel-Snackautomat erstellen
|
|
$vendingMachine = VendingMachine::create([
|
|
'name' => 'Automat Bürogebäude A',
|
|
'location' => 'Erdgeschoss, Eingangsbereich',
|
|
'description' => 'Hauptautomat im Bürogebäude mit Getränken und Snacks',
|
|
'is_active' => true
|
|
]);
|
|
|
|
// Fächer für den Automaten erstellen
|
|
$slots = [
|
|
['slot_number' => '10', 'position' => 'A1'],
|
|
['slot_number' => '12', 'position' => 'A2'],
|
|
['slot_number' => '14', 'position' => 'A3'],
|
|
['slot_number' => '16', 'position' => 'B1'],
|
|
['slot_number' => '18', 'position' => 'B2'],
|
|
['slot_number' => '20', 'position' => 'B3'],
|
|
];
|
|
|
|
foreach ($slots as $slotData) {
|
|
Slot::create([
|
|
'vending_machine_id' => $vendingMachine->id,
|
|
'slot_number' => $slotData['slot_number'],
|
|
'position' => $slotData['position'],
|
|
'capacity' => 10,
|
|
'is_active' => true
|
|
]);
|
|
}
|
|
|
|
// Produkte den Fächern zuordnen
|
|
$slotAssignments = [
|
|
['slot_number' => '10', 'product_name' => 'Coca Cola 0,33l', 'quantity' => 8],
|
|
['slot_number' => '12', 'product_name' => 'Fanta Orange 0,33l', 'quantity' => 6],
|
|
['slot_number' => '14', 'product_name' => 'Sprite 0,33l', 'quantity' => 7],
|
|
['slot_number' => '16', 'product_name' => 'Mars Riegel 51g', 'quantity' => 5],
|
|
['slot_number' => '18', 'product_name' => 'Snickers 50g', 'quantity' => 4],
|
|
];
|
|
|
|
foreach ($slotAssignments as $assignment) {
|
|
$slot = Slot::where('vending_machine_id', $vendingMachine->id)
|
|
->where('slot_number', $assignment['slot_number'])
|
|
->first();
|
|
|
|
$product = Product::where('name', $assignment['product_name'])->first();
|
|
|
|
if ($slot && $product) {
|
|
SlotProduct::create([
|
|
'slot_id' => $slot->id,
|
|
'product_id' => $product->id,
|
|
'quantity' => $assignment['quantity'],
|
|
'current_price' => $product->price
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
}
|