diff --git a/app/Filament/Admin/Resources/MenuResource/Pages/CreateMenu.php b/app/Filament/Admin/Resources/MenuResource/Pages/CreateMenu.php new file mode 100644 index 00000000..bfaaf2b1 --- /dev/null +++ b/app/Filament/Admin/Resources/MenuResource/Pages/CreateMenu.php @@ -0,0 +1,11 @@ +belongsTo(Menu::class, 'parent_id'); + } + + public function children() + { + return $this->hasMany(Menu::class, 'parent_id'); + } +} diff --git a/database/factories/MenuFactory.php b/database/factories/MenuFactory.php new file mode 100644 index 00000000..12a7280d --- /dev/null +++ b/database/factories/MenuFactory.php @@ -0,0 +1,20 @@ + $this->faker->word, + 'url' => $this->faker->url, + 'order' => $this->faker->numberBetween(1, 10), + ]; + } +} \ No newline at end of file diff --git a/database/migrations/2023_05_25_000000_create_site_settings_table.php b/database/migrations/2023_05_25_000000_create_site_settings_table.php new file mode 100644 index 00000000..ccded418 --- /dev/null +++ b/database/migrations/2023_05_25_000000_create_site_settings_table.php @@ -0,0 +1,27 @@ +id(); + $table->string('name'); + $table->string('currency'); + $table->string('default_language'); + $table->text('address'); + $table->string('country'); + $table->string('email'); + $table->timestamps(); + }); + } + + public function down() + { + Schema::dropIfExists('site_settings'); + } +}; \ No newline at end of file diff --git a/database/migrations/2024_07_24_080000_create_menus_table.php b/database/migrations/2024_07_24_080000_create_menus_table.php new file mode 100644 index 00000000..1bf2841f --- /dev/null +++ b/database/migrations/2024_07_24_080000_create_menus_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->string('url'); + $table->unsignedBigInteger('parent_id')->nullable(); + $table->integer('order')->default(0); + $table->timestamps(); + $table->softDeletes(); + + $table->foreign('parent_id')->references('id')->on('menus')->onDelete('cascade'); + }); + } + + public function down(): void + { + Schema::dropIfExists('menus'); + } +}; \ No newline at end of file diff --git a/database/seeders/MenuSeeder.php b/database/seeders/MenuSeeder.php new file mode 100644 index 00000000..06af3683 --- /dev/null +++ b/database/seeders/MenuSeeder.php @@ -0,0 +1,71 @@ + 'Home', + 'url' => '/', + 'order' => 1 + ], + [ + 'name' => 'Properties', + 'url' => '/properties', + 'order' => 2, + 'children' => [ + ['name' => 'For Sale', 'url' => '/properties/for-sale', 'order' => 1], + ['name' => 'For Rent', 'url' => '/properties/for-rent', 'order' => 2], + ] + ], + [ + 'name' => 'Services', + 'url' => '/services', + 'order' => 3, + 'children' => [ + ['name' => 'Buying', 'url' => '/services/buying', 'order' => 1], + ['name' => 'Selling', 'url' => '/services/selling', 'order' => 2], + ['name' => 'Renting', 'url' => '/services/renting', 'order' => 3], + ] + ], + [ + 'name' => 'About', + 'url' => '/about', + 'order' => 4 + ], + [ + 'name' => 'Contact', + 'url' => '/contact', + 'order' => 5 + ], + [ + 'name' => 'Calculators', + 'url' => '/calculators', + 'order' => 6 + ], + ]; + + foreach ($menus as $menuData) { + $this->createMenu($menuData); + } + } + + private function createMenu($menuData, $parentId = null) + { + $children = $menuData['children'] ?? []; + unset($menuData['children']); + + $menuData['parent_id'] = $parentId; + $menu = Menu::create($menuData); + + foreach ($children as $childData) { + $this->createMenu($childData, $menu->id); + } + } +} \ No newline at end of file diff --git a/database/seeders/SiteSettingsSeeder.php b/database/seeders/SiteSettingsSeeder.php new file mode 100644 index 00000000..dca08597 --- /dev/null +++ b/database/seeders/SiteSettingsSeeder.php @@ -0,0 +1,21 @@ + config('app.name', 'Liberu Real Estate'), + 'currency' => '£', + 'default_language' => 'en', + 'address' => '123 Real Estate St, London, UK', + 'country' => 'United Kingdom', + 'email' => 'info@liberurealestate.com', + ]); + } +} \ No newline at end of file