Skip to content

Commit

Permalink
Add 'Tanzanie' to list of countries and restrict
Browse files Browse the repository at this point in the history
access for role 2 users
  • Loading branch information
BorisGautier committed Nov 10, 2023
1 parent 9fb92a9 commit e06c332
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/Filament/Resources/OscResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static function form(Form $form): Form
'Cameroun' => 'Cameroun',
'Senegal' => 'Senegal',
'Cote d\'ivoire' => 'Cote d\'ivoire',
'Tanzanie' => 'Tanzanie',
]),
Forms\Components\DatePicker::make('date_fondation'),
Forms\Components\Textarea::make('description'),
Expand Down Expand Up @@ -216,6 +217,12 @@ public static function getEloquentQuery(): Builder
SoftDeletingScope::class,
]);
}
if( auth()->user()->role == 8) {
return parent::getEloquentQuery()->where('pays', 'Tanzanie')
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
Expand Down
1 change: 1 addition & 0 deletions app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static function form(Form $form): Form
'5' => 'User Cameroun',
'6' => 'User Senegal',
'7' => 'User Cote d\'ivoire',
'8' => 'User Tanzanie',
])
->required(),
]);
Expand Down
2 changes: 1 addition & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class User extends Authenticatable implements MustVerifyEmail, FilamentUser

public function canAccessPanel(\Filament\Panel $panel): bool
{
return str_ends_with($this->email, '@francophonie.org') || str_ends_with($this->email, '@ifdd.cm');
return $this->role != 2 ;
}

public function oscs()
Expand Down

0 comments on commit e06c332

Please sign in to comment.