<?php
 namespace Database\Seeders; use App\Models\Menu; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\DB; class MenuSeeder extends Seeder { public function run(): void { DB::transaction(function () { $header = Menu::firstOrCreate( ['brand_id' => null, 'slug' => 'header_primary'], ['name' => 'Header — Ana Menü', 'is_active' => true] ); $items = [ ['link_type' => 'route', 'link_target' => ['route' => 'store.index'], 'icon' => 'fas fa-home', 'label' => ['tr' => 'Ana Sayfa', 'en' => 'Home']], ['link_type' => 'route', 'link_target' => ['route' => 'store.products.index'], 'icon' => 'fas fa-box', 'label' => ['tr' => 'Ürünler', 'en' => 'Products']], ['link_type' => 'route', 'link_target' => ['route' => 'store.contact'], 'icon' => 'fas fa-envelope', 'label' => ['tr' => 'İletişim', 'en' => 'Contact']], ['link_type' => 'route', 'link_target' => ['route' => 'store.faq'], 'icon' => 'fas fa-question-circle', 'label' => ['tr' => 'SSS', 'en' => 'FAQ']], ]; foreach ($items as $idx => $data) { $existing = $header->items()->where('link_type', $data['link_type']) ->where('link_target->route', $data['link_target']['route']) ->first(); $item = $existing ?? $header->items()->create([ 'link_type' => $data['link_type'], 'link_target' => $data['link_target'], 'icon' => $data['icon'], 'sort_order' => $idx, ]); foreach ($data['label'] as $locale => $value) { $item->setTranslation('label', $locale, $value); } } Menu::firstOrCreate( ['brand_id' => null, 'slug' => 'footer_primary'], ['name' => 'Footer — Ana Menü', 'is_active' => true] ); }); } } 