-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48c07b2
commit 9fa830b
Showing
12 changed files
with
277 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
app/Filament/Admin/Resources/MenuResource/Pages/CreateMenu.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace App\Filament\Admin\Resources\MenuResource\Pages; | ||
|
||
use Filament\Resources\Pages\CreateRecord; | ||
use App\Filament\Admin\Resources\MenuResource; | ||
|
||
class CreateMenu extends CreateRecord | ||
{ | ||
protected static string $resource = MenuResource::class; | ||
} |
11 changes: 11 additions & 0 deletions
11
app/Filament/Admin/Resources/MenuResource/Pages/EditMenu.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace App\Filament\Admin\Resources\MenuResource\Pages; | ||
|
||
use Filament\Resources\Pages\EditRecord; | ||
use App\Filament\Admin\Resources\MenuResource; | ||
|
||
class EditMenu extends EditRecord | ||
{ | ||
protected static string $resource = MenuResource::class; | ||
} |
11 changes: 11 additions & 0 deletions
11
app/Filament/Admin/Resources/MenuResource/Pages/ListMenus.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace App\Filament\Admin\Resources\MenuResource\Pages; | ||
|
||
use Filament\Resources\Pages\ListRecords; | ||
use App\Filament\Admin\Resources\MenuResource; | ||
|
||
class ListMenus extends ListRecords | ||
{ | ||
protected static string $resource = MenuResource::class; | ||
} |
11 changes: 11 additions & 0 deletions
11
app/Filament/Admin/Resources/SiteSettingsResource/Pages/CreateSiteSettings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace App\Filament\Admin\Resources\SiteSettingsResource\Pages; | ||
|
||
use App\Filament\Admin\Resources\SiteSettingsResource; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateSiteSettings extends CreateRecord | ||
{ | ||
protected static string $resource = SiteSettingsResource::class; | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Admin/Resources/SiteSettingsResource/Pages/EditSiteSettings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Admin\Resources\SiteSettingsResource\Pages; | ||
|
||
use App\Filament\Admin\Resources\SiteSettingsResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditSiteSettings extends EditRecord | ||
{ | ||
protected static string $resource = SiteSettingsResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Admin/Resources/SiteSettingsResource/Pages/ListSiteSettings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Admin\Resources\SiteSettingsResource\Pages; | ||
|
||
use App\Filament\Admin\Resources\SiteSettingsResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListSiteSettings extends ListRecords | ||
{ | ||
protected static string $resource = SiteSettingsResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class Menu extends Model | ||
{ | ||
use HasFactory, SoftDeletes; | ||
|
||
protected $fillable = [ | ||
'name', | ||
'url', | ||
'parent_id', | ||
'order', | ||
]; | ||
|
||
public function parent() | ||
{ | ||
return $this->belongsTo(Menu::class, 'parent_id'); | ||
} | ||
|
||
public function children() | ||
{ | ||
return $this->hasMany(Menu::class, 'parent_id'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Database\Factories; | ||
|
||
use App\Models\Menu; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
class MenuFactory extends Factory | ||
{ | ||
protected $model = Menu::class; | ||
|
||
public function definition() | ||
{ | ||
return [ | ||
'name' => $this->faker->word, | ||
'url' => $this->faker->url, | ||
'order' => $this->faker->numberBetween(1, 10), | ||
]; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
database/migrations/2023_05_25_000000_create_site_settings_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('site_settings', function (Blueprint $table) { | ||
$table->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'); | ||
} | ||
}; |
28 changes: 28 additions & 0 deletions
28
database/migrations/2024_07_24_080000_create_menus_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Schema::create('menus', function (Blueprint $table) { | ||
$table->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'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
use App\Models\Menu; | ||
|
||
class MenuSeeder extends Seeder | ||
{ | ||
public function run() | ||
{ | ||
$menus = [ | ||
[ | ||
'name' => '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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
use App\Models\SiteSettings; | ||
|
||
class SiteSettingsSeeder extends Seeder | ||
{ | ||
public function run() | ||
{ | ||
SiteSettings::create([ | ||
'name' => config('app.name', 'Liberu Real Estate'), | ||
'currency' => '£', | ||
'default_language' => 'en', | ||
'address' => '123 Real Estate St, London, UK', | ||
'country' => 'United Kingdom', | ||
'email' => '[email protected]', | ||
]); | ||
} | ||
} |