-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE - Add Users relationship into Roles (#51)
* Add role nagivation group customisation * Add permission nagivation group customisation * Add nagivation_section_group config option * Remove default setting on Guard Remove default setting on Guard because it causes an issue with the datalist being array if it's not selected / typed. * Remove default setting on Guard Remove default setting on Guard because it causes an issue with the datalist being array if it's not selected / typed. * Add team support to RolesResource * Add english language strings for team support * Added Team Model Class linkage * Add dehydrated state to the team_id to allow null when empty since 0 is an integer. * Remove duplicated team_model from merging. * Basic First Pass for adding users to roles, so you can see at the role level. TODO - Condition for teams support if possible. --------- Co-authored-by: Tony Partridge <[email protected]>
- Loading branch information
1 parent
ca28592
commit 4734c9a
Showing
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
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
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
50 changes: 50 additions & 0 deletions
50
src/Resources/RoleResource/RelationManager/UserRelationManager.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,50 @@ | ||
<?php | ||
|
||
namespace Althinect\FilamentSpatieRolesPermissions\Resources\RoleResource\RelationManager; | ||
|
||
use Filament\Forms; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Resources\Form; | ||
use Filament\Resources\RelationManagers\BelongsToManyRelationManager; | ||
use Filament\Resources\Table; | ||
use Filament\Tables; | ||
use Filament\Tables\Columns\TextColumn; | ||
|
||
class UserRelationManager extends BelongsToManyRelationManager | ||
{ | ||
protected static string $relationship = 'users'; | ||
|
||
protected static ?string $recordTitleAttribute = 'name'; | ||
|
||
protected static function getModelLabel(): string | ||
{ | ||
return __('filament-spatie-roles-permissions::filament-spatie.section.users'); | ||
} | ||
|
||
protected static function getPluralModelLabel(): string | ||
{ | ||
return __('filament-spatie-roles-permissions::filament-spatie.section.users'); | ||
} | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
TextInput::make('name') | ||
->label(__('filament-spatie-roles-permissions::filament-spatie.field.name')), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
TextColumn::make('name') | ||
->searchable() | ||
->label(__('filament-spatie-roles-permissions::filament-spatie.field.name')), | ||
]) | ||
->filters([ | ||
// | ||
]); | ||
} | ||
} |