Pre-select filters in table

Hey guys,

I have widget Staff Widget. Depending on the role which user is logged in, I have to create pre-select filter in the table.

So this is StaffWidget.php in widgets folder :

protected function getTableColumns(): array { return [ Tables\Columns\TextColumn::make('name'), Tables\Columns\TextColumn::make('roles.name') ]; }

and this is the code from UserResource.php :

Forms\Components\TextInput::make('name')->required(), Forms\Components\TextInput::make('email')->required(), Forms\Components\Select::make('organisation')->relationship('organisation', 'name'),

Bottom line, If I am logged in as a customer, role "customers" should be pre-selected on the Users overview page.
Thanks in advance!
Was this page helpful?