Andi
Andi
FFilament
Created by Andi on 8/25/2024 in #❓┊help
pest 403 for List page
Hello I try to write a pest test to test the table.
beforeEach(fn() => asAdmin());

it('can render page', function () {
livewire(ListPermissions::class)
->assertSuccessful();
});
beforeEach(fn() => asAdmin());

it('can render page', function () {
livewire(ListPermissions::class)
->assertSuccessful();
});
asAdmin
function asAdmin(): TestCase
{
$user = User::factory()->create();

test()->seed(PermissionSeeder::class);

$permission = Permission::query()
->firstOrCreate(['name' => '*']);
$user->permissions()->attach($permission);

return test()->actingAs($user);
}
function asAdmin(): TestCase
{
$user = User::factory()->create();

test()->seed(PermissionSeeder::class);

$permission = Permission::query()
->firstOrCreate(['name' => '*']);
$user->permissions()->attach($permission);

return test()->actingAs($user);
}
assertSuccessful fails because of 403. And yes, I do have canAccessPanel in User model, it just returns true. On production I am able to login and access the resource.
6 replies
FFilament
Created by Andi on 8/24/2024 in #❓┊help
MorphToSelect only disable type field
Hello Is there an option to only disable the type field or the id field in MorphToSelect? I didn't find anything in the docs
2 replies
FFilament
Created by Andi on 8/9/2024 in #❓┊help
Managing 3 levels (or more) deep relations.
Hey guys, I was wondering how you would handle this business case in terms of UX. So with 2 levels it's easy. Relation manager on one resource. Now let's say we have Project, Todo and Comment. If you still manage Todos of a Project using a relation manager, you would have to change to the TodoResource when you want to manage Comments of that Todo. It might be a bit bad example, as the chances of an user wanting to manage comments on the projects table isn't very often if even all, but there are other use cases this applies. So my ideas so far were: 1. Just let the user change resources manually via navbar. 2. Make the edit button link to the resource edit page instead of the the relation manager. Then you can also remove the TodoResource from the sidebar (if that makes sense), as it helps to keep the workflow from creating project -> creating todos -> managing comments clear and straightforward. 3. Using a HasManyThrough relationship to manage comments on the project resource Now I'm curious about your approaches to this.
3 replies
FFilament
Created by Andi on 5/16/2024 in #❓┊help
Repeater Soft-Delete
Hey guys, does anybody know if the Repeater Component supports soft deletes? Delete Button makes a delete, but doesn't gives an option to force delete or restore if the record is only soft deleted. Docs don't say anything about it. Maybe I just don't see it, but I think there is no method for that.
13 replies
FFilament
Created by Andi on 4/28/2024 in #❓┊help
Table summary not working for accessors
Hello I try to build a summary for an accessor, which counts an amount of a hasMany relationship.
Tables\Columns\TextColumn::make('totalValue')
->label('Total Value')
->formatStateUsing(fn($state) => number_format($state, 2))
->sortable()
->money('EUR'),
Tables\Columns\TextColumn::make('totalValue')
->label('Total Value')
->formatStateUsing(fn($state) => number_format($state, 2))
->sortable()
->money('EUR'),
this works as expected, but when I add the summary:
->summarize(Tables\Columns\Summarizers\Sum::make()
->label('Total Sum')
->formatStateUsing(fn($state) => number_format($state, 2))
)
->summarize(Tables\Columns\Summarizers\Sum::make()
->label('Total Sum')
->formatStateUsing(fn($state) => number_format($state, 2))
)
this breaks because totalValue doesn't exist as a column.
3 replies
FFilament
Created by Andi on 2/13/2024 in #❓┊help
Import update if exists not working with database driver
Hi guys I'm on Filament v3.2.34, so latest release. When using sync queue driver, the record gets updated, but as soon as I use the database driver, there is always a new record created. This is my code:
public function resolveRecord(): ?Sale
{
return Sale::firstOrNew([
'shop_id' => $this->options['shop_id'],
'sales_date' => $this->data['sales_date'],
]);
}
public function resolveRecord(): ?Sale
{
return Sale::firstOrNew([
'shop_id' => $this->options['shop_id'],
'sales_date' => $this->data['sales_date'],
]);
}
Do you guys know a workaround or is it a bug?
12 replies
FFilament
Created by Andi on 2/12/2024 in #❓┊help
Accessing form data in suffixAction form.
Hi guys I'm currently trying to access data from the parent form in the suffixActions form. Here's my code:
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('part')
->reactive()
->suffixAction(
Action::make('add')
->action(function (array $data, Forms\Get $get) {
$get('part'); // returns correct value
})
->form([
Forms\Components\Select::make('bom')
->live()
->options(function (Forms\Get $get, $state) use () {
$get('part'); // is null
})
])
)
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('part')
->reactive()
->suffixAction(
Action::make('add')
->action(function (array $data, Forms\Get $get) {
$get('part'); // returns correct value
})
->form([
Forms\Components\Select::make('bom')
->live()
->options(function (Forms\Get $get, $state) use () {
$get('part'); // is null
})
])
)
So in action() I receive the correct value, in options I don't. Thanks for your help.
3 replies
FFilament
Created by Andi on 2/1/2024 in #❓┊help
FIlaments Import inside RelationManager
Hi guys I'm looking for a way to import records using a RelationShip manager. So for example PostResource has a CommentsRelationManager. Now I want to import comments into the currently opened post.
7 replies
FFilament
Created by Andi on 11/25/2023 in #❓┊help
FileUpload using polymorphic relationship
Hi I try to use a polymorphic relationship for files, but I can't really figure out, how to save a file to a specific relationship. FileUpload doesn't provide a relationship method as far as I see. So is it only possible to save a file name to a text field as either the name or an array? Thanks for your help.
4 replies