Frittenfred
Frittenfred
FFilament
Created by Frittenfred on 4/2/2024 in #❓┊help
Filter from Accessor
Hello Together, i'm using Laravel Venture for Workflow Jobs, and i have set in my model a Accessor. That gives me for every row a output if the workflow is running or failed or was canceled as string. in my Table in Filament this works very well and every row has his Data from the Accessor. now i want to implement a filter to the Table where i can filter via the accessor string, but this don't work out until now. this is my Accessor in the Model :
public function getWorkflowStatusAttribute()
{
if ($this->cancelled_at != Null) {
return 'Abgebrochen';
} else if ($this->failedJobs()->isNotEmpty()) {
return 'Fehlgeschlagen';
} else if (!$this->allJobsHaveFinished()) {
return 'Läuft';
} else if ($this->allJobsHaveFinished()) {
return 'Abgeschlossen';
}
}
public function getWorkflowStatusAttribute()
{
if ($this->cancelled_at != Null) {
return 'Abgebrochen';
} else if ($this->failedJobs()->isNotEmpty()) {
return 'Fehlgeschlagen';
} else if (!$this->allJobsHaveFinished()) {
return 'Läuft';
} else if ($this->allJobsHaveFinished()) {
return 'Abgeschlossen';
}
}
any idea how i can filter by the returned Strings ? 🙂 Thanks
6 replies
FFilament
Created by Frittenfred on 3/5/2024 in #❓┊help
how to test a view modal action?
Hello Folks, i'm testing my Laravel Filament application and i want to test if guests can access a view which opens via a modal.

Tables\Actions\ViewAction::make()
->label('')
->slideOver()
->modalWidth(MaxWidth::Medium),

Tables\Actions\ViewAction::make()
->label('')
->slideOver()
->modalWidth(MaxWidth::Medium),
i want to test if a guest or people without permission can access the view modal as Action. i have allready a test to check if the table gets rendered and showed. that is forbidden and redirects, that works. but i would like to test if someone could open only a action and i don't know right how to test a modal action that only works for a administrator. my code at this time :
Livewire::test(ViewAction::class, [
'record' => $user->getRouteKey()
])
->assertForbidden();
Livewire::test(ViewAction::class, [
'record' => $user->getRouteKey()
])
->assertForbidden();
someone a idea ?
6 replies
FFilament
Created by Frittenfred on 2/27/2024 in #❓┊help
handlerecordcreation testing ?
Hello Together, i'm writing tests for the UserResource. i want to test if when i create a user, a password forgotten email has been send. i have in my CreateUser.php a handlerecordcreation wich executes this code : protected function handleRecordCreation(array $data): Model { if ($data['start_password_forgotten']) { $email = ['email' => $data['email']]; unset($data['start_password_forgotten']); $user = static::getModel()::create($data); UserResource::sendPasswordForgottenEmail($email); } else { unset($data['start_password_forgotten']); $user = static::getModel()::create($data); } return $user; } sendPasswordForgottenEmail sends the password via the broker with fortify. in my Test im writing this code to check : public function test_if_created_user_sends_password_forgotten_email() { $this->actingAs(User::factory()->create()->assignRole(UserRoleEnum::ADMINISTRATOR->value)); $user = User::factory()->make(); Mail::fake(); Livewire::test(UserResource\Pages\CreateUser::class) ->fillForm([ 'name' => $user->name, 'email' => $user->email, 'start_password_forgotten' => true, ]) ->call('create'); Mail::assertSentCount(1); } but there is no email been send, even if i add the 'start_password_forgotten' attribute. so that means that the call() method not starts the handleRecordCreation(). is there a other possibility access it and test it ? am i missing something ?
3 replies