mirror of
https://github.com/openclassify/openclassify.git
synced 2026-04-14 11:12:09 -05:00
- Complete rewrite using Laravel 12 framework - Modular architecture with nwidart/laravel-modules v11 - Modules: Category, Listing, Location, Profile - 8 top-level categories with 33 subcategories seeded - 6 sample listings seeded - 5 countries, 13 cities, districts seeded - Multi-language support: en, tr, ar, zh, es, fr, de, pt, ru, ja - Auth scaffolding via Laravel Breeze - Partner dashboard for user listing management - Tailwind CSS via CDN for styling - SQLite database for development - RTL support for Arabic locale Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
37 lines
1.8 KiB
PHP
37 lines
1.8 KiB
PHP
<?php
|
|
namespace Modules\Category\Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Modules\Category\Models\Category;
|
|
use Illuminate\Support\Str;
|
|
|
|
class CategorySeeder extends Seeder
|
|
{
|
|
public function run(): void
|
|
{
|
|
$categories = [
|
|
['name' => 'Electronics', 'icon' => '📱', 'children' => ['Mobile Phones', 'Laptops & Computers', 'Tablets', 'Cameras', 'Audio']],
|
|
['name' => 'Vehicles', 'icon' => '🚗', 'children' => ['Cars', 'Motorcycles', 'Trucks', 'Boats']],
|
|
['name' => 'Real Estate', 'icon' => '🏠', 'children' => ['Apartments for Rent', 'Houses for Sale', 'Commercial', 'Land']],
|
|
['name' => 'Furniture', 'icon' => '🛋️', 'children' => ['Sofas', 'Beds', 'Tables', 'Wardrobes']],
|
|
['name' => 'Fashion', 'icon' => '👗', 'children' => ['Women', 'Men', 'Kids', 'Accessories']],
|
|
['name' => 'Jobs', 'icon' => '💼', 'children' => ['IT & Technology', 'Marketing', 'Sales', 'Education']],
|
|
['name' => 'Services', 'icon' => '🔧', 'children' => ['Home Repair', 'Tutoring', 'Design', 'Cleaning']],
|
|
['name' => 'Sports & Hobbies', 'icon' => '⚽', 'children' => ['Sports Equipment', 'Musical Instruments', 'Books', 'Games']],
|
|
];
|
|
|
|
foreach ($categories as $catData) {
|
|
$parent = Category::firstOrCreate(
|
|
['slug' => Str::slug($catData['name'])],
|
|
['name' => $catData['name'], 'icon' => $catData['icon'] ?? null, 'level' => 0, 'is_active' => true]
|
|
);
|
|
foreach ($catData['children'] as $childName) {
|
|
Category::firstOrCreate(
|
|
['slug' => Str::slug($childName)],
|
|
['name' => $childName, 'parent_id' => $parent->id, 'level' => 1, 'is_active' => true]
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|