javalava6985
javalava6985
FFilament
Created by javalava6985 on 5/21/2024 in #❓┊help
Testting anonymous actions
I have an infolist (ViewProject.php) for my ProjectResource. This just displays a number of sections and groups. Of of those sections contains a number of anonymous actions, like:
Action::make('invite-teacher')
->label('Docent uitnodigen')
->icon('heroicon-m-academic-cap')
->color('darkGreen')
->disabled(function ($record) {
return !isset($record->teacher);
})
->requiresConfirmation()
->action(function ($record) {
$from = Filament::getTenant();
SendTeacherInviteEmail::dispatch($record, $from);
Notification::make('teacher-invited')
->title('Uitnodiging verzonden!')
->success()
->send();
}),
Action::make('invite-teacher')
->label('Docent uitnodigen')
->icon('heroicon-m-academic-cap')
->color('darkGreen')
->disabled(function ($record) {
return !isset($record->teacher);
})
->requiresConfirmation()
->action(function ($record) {
$from = Filament::getTenant();
SendTeacherInviteEmail::dispatch($record, $from);
Notification::make('teacher-invited')
->title('Uitnodiging verzonden!')
->success()
->send();
}),
The action itself works just fine, i just have no idea how to reach this action in a (pest) test. Can someone point me in the right direction or tell me how i can refactor if i need to rewrite my actions.
3 replies
FFilament
Created by javalava6985 on 4/9/2024 in #❓┊help
Costumize AttachAction
I have a relation manager in a Laravel Filament V3 app. It manages the relation between my Project model and my Attendee model. They are connected through a pivot table and a BelongsToMany relationship. When i add the AttachAction in the header i want to be able to search my projects by name but the name is not on the Project model itself. The name is set on a Course model which is connected trough a HasMany / BelongsTo relationship.
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('id')
->columns([
TextColumn::make('course.title')
->label('Cursus')
->sortable(),
TextColumn::make('start_datetime')
->label('Datum')
->date('d-m-Y')
->sortable()
])
->headerActions([
Tables\Actions\AttachAction::make()
->recordSelectSearchColumns(['start_datetime', 'course.title']),
])
->actions([
Tables\Actions\EditAction::make()->slideOver(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('id')
->columns([
TextColumn::make('course.title')
->label('Cursus')
->sortable(),
TextColumn::make('start_datetime')
->label('Datum')
->date('d-m-Y')
->sortable()
])
->headerActions([
Tables\Actions\AttachAction::make()
->recordSelectSearchColumns(['start_datetime', 'course.title']),
])
->actions([
Tables\Actions\EditAction::make()->slideOver(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
}
I've tried to do this. The TextColumn gives the title of the course but the AttachAction does not work: Unknown column 'course.title' in 'where clause'
2 replies
FFilament
Created by javalava6985 on 1/25/2024 in #❓┊help
Advice on user roles
I'm looking for a bit of advice on how to construct my app. I'm starting a new project with laravel filament v3. I have a couple of different user roles but the main are 3 different roles. We have 2 different companies that are seperated from one another but operate in a similar fashion. I have an admin role that should see all the clients, meetings etc. for bith companies. the other 2 roles are from the 2 different companies and they should only be able to see the clients, meetings etc. for their own compay. How would you construct this app? - Option 1: 1 admin panel with multiple user roles; - Option 2: A different panel for each role - Option 3: Implement the multi-tenancy options from filament v3.
1 replies
FFilament
Created by javalava6985 on 1/9/2024 in #❓┊help
Set the state of ->afterStateUpdated inside a test
My page shows some text after the user selects a certain entry form a Select::make(). I use the ->afterStateUpdated method to change the text if a certain condition is met. Does anyone know how i can implement this inside a (Pest) test? The following doesn't work: $livewire = livewire(CreateReport::class) ->set('client_id', $newReport->client->getKey()) ->call('afterStateUpdated', 'client_id'); // Call the afterStateUpdated method if needed I'm in V3.
1 replies
FFilament
Created by javalava6985 on 12/11/2023 in #❓┊help
Testing with Pest keeps giving a 403 response
I'm trying to test my filament (V3) app with pest. I've added the actingAs rule in the setup for TestCase.php as per the documentation. However, when i try to test my ClientResource with the code: it('can render page', function () { $this->get(ClientResource::getUrl('index'))->assertSuccessful(); }); I keep getting a 403 on running the test. Any idea what i'm doing wrong?
1 replies
FFilament
Created by javalava6985 on 4/14/2023 in #❓┊help
Typing in date/timepicker
The date, time & datetimepickers work great but i want to be able to type in the date and/or time instead of just selecting it with my mouse. Can't seem to find how to enable this. Can anyone point me in the right direction?
8 replies