From ec1840177d0aecc4515034d09b5d4ff72dc942a8 Mon Sep 17 00:00:00 2001 From: raza9798 Date: Thu, 29 Aug 2024 02:39:52 +0530 Subject: [PATCH 1/3] seeders configured --- database/seeders/DatabaseSeeder.php | 10 +++--- database/seeders/RolesSeeder.php | 10 +++--- database/seeders/SiteSettingsSeeder.php | 12 +++++-- database/seeders/TeamSeeder.php | 23 ++++++++++++ database/seeders/UserSeeder.php | 47 +++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 database/seeders/TeamSeeder.php create mode 100644 database/seeders/UserSeeder.php diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index ae436a07..0b856e54 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -13,11 +13,11 @@ class DatabaseSeeder extends Seeder */ public function run(): void { - // User::factory(10)->withPersonalTeam()->create(); - - User::factory()->withPersonalTeam()->create([ - 'name' => 'Test User', - 'email' => 'test@example.com', + $this->call([ + MenuSeeder::class, + RolesSeeder::class, + TeamSeeder::class, + UserSeeder::class, ]); } } diff --git a/database/seeders/RolesSeeder.php b/database/seeders/RolesSeeder.php index 16fa0e4c..fa272c6d 100644 --- a/database/seeders/RolesSeeder.php +++ b/database/seeders/RolesSeeder.php @@ -13,12 +13,12 @@ class RolesSeeder extends Seeder */ public function run(): void { - $adminRole = Role::firstOrCreate(['name' => 'admin']); + $roles = ['admin', 'staff', 'client', 'free']; $permissions = Permission::where('guard_name', 'web')->pluck('id')->toArray(); - $adminRole->syncPermissions($permissions); - $freeRole = Role::firstOrCreate(['name' => 'free']); - $freePermissions = Permission::where('guard_name', 'web')->pluck('id')->toArray(); - $freeRole->syncPermissions($freePermissions); + foreach ($roles as $roleName) { + $role = Role::firstOrCreate(['name' => $roleName]); + $role->syncPermissions($permissions); + } } } diff --git a/database/seeders/SiteSettingsSeeder.php b/database/seeders/SiteSettingsSeeder.php index dca08597..af415f0e 100644 --- a/database/seeders/SiteSettingsSeeder.php +++ b/database/seeders/SiteSettingsSeeder.php @@ -10,12 +10,20 @@ class SiteSettingsSeeder extends Seeder public function run() { SiteSettings::create([ - 'name' => config('app.name', 'Liberu Real Estate'), + 'name' => config('app.name', 'Liberu '), 'currency' => '£', 'default_language' => 'en', - 'address' => '123 Real Estate St, London, UK', + 'address' => '123 St, London, UK', 'country' => 'United Kingdom', 'email' => 'info@liberurealestate.com', + 'phone_01' => '+44 123 456 7890', + 'phone_02' => '+44 123 456 7890', + 'phone_03' => '+44 123 456 7890', + 'phone_04' => '+44 123 456 7890', + 'facebook' => 'https://facebook.com/liberusoftware', + 'twitter' => 'https://twitter.com/liberusoftware', + 'github' => 'https://Github.com/liberusoftware', + 'youtube' => 'https://YouTube.com/@liberusoftware', ]); } } \ No newline at end of file diff --git a/database/seeders/TeamSeeder.php b/database/seeders/TeamSeeder.php new file mode 100644 index 00000000..f3078d65 --- /dev/null +++ b/database/seeders/TeamSeeder.php @@ -0,0 +1,23 @@ + 1, + 'name' => 'default', + 'personal_team' => false, + 'user_id' => 1, + ]); + } +} diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php new file mode 100644 index 00000000..28e64244 --- /dev/null +++ b/database/seeders/UserSeeder.php @@ -0,0 +1,47 @@ + 'Admin User', + 'email' => 'admin@example.com', + 'password' => Hash::make('password'), + 'email_verified_at' => now(), + ]); + $adminUser->assignRole('admin'); + + $staffUser = User::create([ + 'name' => 'Staff User', + 'email' => 'staff@example.com', + 'password' => Hash::make('password'), + 'email_verified_at' => now(), + ]); + $staffUser->assignRole('staff'); + + // Create teams for admin and staff users + $this->createTeamForUser($adminUser); + $this->createTeamForUser($staffUser); + } + + private function createTeamForUser($user) + { + $team = Team::first(); + $team->users()->attach($user); + + $user->current_team_id = 1; + $user->save(); + } +} From d558eb2c7e4845d90fbcd8fbacd1e0865f133a90 Mon Sep 17 00:00:00 2001 From: raza9798 Date: Thu, 29 Aug 2024 02:51:06 +0530 Subject: [PATCH 2/3] login fix and site helper fix --- ...5_25_000000_create_site_settings_table.php | 22 ++++++++++++++----- database/seeders/DatabaseSeeder.php | 1 + routes/web.php | 4 ++-- 3 files changed, 19 insertions(+), 8 deletions(-) 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 index ccded418..b7c2adca 100644 --- a/database/migrations/2023_05_25_000000_create_site_settings_table.php +++ b/database/migrations/2023_05_25_000000_create_site_settings_table.php @@ -10,12 +10,22 @@ 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->string('name')->nullable(); + $table->string('currency')->nullable(); + $table->string('default_language')->nullable(); + $table->text('address')->nullable(); + $table->string('country')->nullable(); + $table->string('email')->nullable(); + $table->string('phone_01')->nullable(); + $table->string('phone_02')->nullable(); + $table->string('phone_03')->nullable(); + $table->string('phone_04')->nullable(); + $table->string('facebook')->nullable(); + $table->string('twitter')->nullable(); + $table->string('github')->nullable(); + $table->string('youtube')->nullable(); + $table->decimal('sales_commission_percentage', 5, 2)->default(1.00); + $table->decimal('lettings_commission_percentage', 5, 2)->default(8.00); $table->timestamps(); }); } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 0b856e54..0d117644 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -14,6 +14,7 @@ class DatabaseSeeder extends Seeder public function run(): void { $this->call([ + SiteSettingsSeeder::class, MenuSeeder::class, RolesSeeder::class, TeamSeeder::class, diff --git a/routes/web.php b/routes/web.php index ea79e27a..5de5c635 100644 --- a/routes/web.php +++ b/routes/web.php @@ -17,9 +17,9 @@ Route::get('/', fn () => view('welcome')); -Route::redirect('/login', '/app/login')->name('login'); +// Route::redirect('/login', '/app/login')->name('login'); -Route::redirect('/register', '/app/register')->name('register'); +// Route::redirect('/register', '/app/register')->name('register'); Route::redirect('/dashboard', '/app')->name('dashboard'); From 321da52194383fee7eca8a65ed942873bccd4698 Mon Sep 17 00:00:00 2001 From: raza9798 Date: Thu, 29 Aug 2024 02:52:29 +0530 Subject: [PATCH 3/3] user resources created --- app/Filament/App/Resources/UserResource.php | 64 +++++++++++++++++++ .../UserResource/Pages/CreateUser.php | 12 ++++ .../Resources/UserResource/Pages/EditUser.php | 19 ++++++ .../UserResource/Pages/ListUsers.php | 19 ++++++ 4 files changed, 114 insertions(+) create mode 100644 app/Filament/App/Resources/UserResource.php create mode 100644 app/Filament/App/Resources/UserResource/Pages/CreateUser.php create mode 100644 app/Filament/App/Resources/UserResource/Pages/EditUser.php create mode 100644 app/Filament/App/Resources/UserResource/Pages/ListUsers.php diff --git a/app/Filament/App/Resources/UserResource.php b/app/Filament/App/Resources/UserResource.php new file mode 100644 index 00000000..558676ff --- /dev/null +++ b/app/Filament/App/Resources/UserResource.php @@ -0,0 +1,64 @@ +schema([ + // + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + // + ]) + ->filters([ + // + ]) + ->actions([ + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + ]), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListUsers::route('/'), + 'create' => Pages\CreateUser::route('/create'), + 'edit' => Pages\EditUser::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/App/Resources/UserResource/Pages/CreateUser.php b/app/Filament/App/Resources/UserResource/Pages/CreateUser.php new file mode 100644 index 00000000..88a03250 --- /dev/null +++ b/app/Filament/App/Resources/UserResource/Pages/CreateUser.php @@ -0,0 +1,12 @@ +