ahinkle
ahinkle
FFilament
Created by ahinkle on 10/8/2024 in #❓┊help
Action with Notification not showing
Dealing with a small issue where notification isn't appearing. I have a header action that launches a job. When I confirm the action, it returns to the index and nothing happens. No indication that it was successfully started. Any ideas?
Action::make('sync_bigcommerce_products')
->label('Sync with BigCommerce')
->icon('heroicon-o-arrow-path')
->requiresConfirmation()
->successNotification(
Notification::make()
->success()
->title('Sync Started')
->body('The sync with BigCommerce has started - this may take a few minutes.')
)
->action(fn () => SyncBigcommerceProductsJob::dispatch())
Action::make('sync_bigcommerce_products')
->label('Sync with BigCommerce')
->icon('heroicon-o-arrow-path')
->requiresConfirmation()
->successNotification(
Notification::make()
->success()
->title('Sync Started')
->body('The sync with BigCommerce has started - this may take a few minutes.')
)
->action(fn () => SyncBigcommerceProductsJob::dispatch())
3 replies
FFilament
Created by ahinkle on 5/3/2024 in #❓┊help
Relationship Manager: Open in same window (non-modal)
Say I have a UserResource and a PostResource. When I add a PostRelationManager, it opens posts in a modal. How can we make it display the full page Post instead of modal? PostRelationManager:
public function table(Table $table): Table
{
return PostResource::table($table);
}
public function table(Table $table): Table
{
return PostResource::table($table);
}
PostResource Actions:
->actions([
Tables\Actions\ActionGroup::make([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
]),
])
->actions([
Tables\Actions\ActionGroup::make([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
]),
])
When on the PostResource, it opens in the same page, but when using the relationship manager, it opens a modal. Been scouring the docs but not seeing it. Thanks!
2 replies
FFilament
Created by ahinkle on 4/26/2024 in #❓┊help
Filament Reserved Keywords?
I have a model called Message when I try to create a message in Filament, admin/messages/create returns a 404. Is messages or message a reserved keyword? Can't seem to pinpoint why this is occuring otherwise.
7 replies
FFilament
Created by ahinkle on 4/22/2024 in #❓┊help
Debugging Import: Multiple types of exceptions occurred
Sometimes when working with Filament imports, I'll see this popup in the log:
Multiple types of exceptions occurred: [TypeError], [Illuminate\Database\QueryException]
Multiple types of exceptions occurred: [TypeError], [Illuminate\Database\QueryException]
This exception isn't super helpful and it doesn't give context into the query or what happened. it's the only thing in the log -- doesn't provide the query statement or anything like that. Any ideas how to debug this?
2 replies
FFilament
Created by ahinkle on 3/15/2024 in #❓┊help
Testing: How to call a table action within a relation manager?
Hi, I have this Action within my CountriesRelationManager:
// CountriesRelationManager.php

public function table(Table $table): Table
{
return $table
// ...
->actions([
// ...
Action::make('moveUp')
->action(function (Action $action) {
$action->getRecord()->moveOrderUp();
}),
]);
// ...
}
// CountriesRelationManager.php

public function table(Table $table): Table
{
return $table
// ...
->actions([
// ...
Action::make('moveUp')
->action(function (Action $action) {
$action->getRecord()->moveOrderUp();
}),
]);
// ...
}
I'm looking to write a test for this custom action:
it('allows moves sort order up on assicated children', function () {
$continent = Continent::factory()
->hasCountries(2)
->create();

livewire(CountriesRelationManager::class, [
'pageClass' => EditContinent::class,
'ownerRecord' => $continent,
])
->callTableColumnAction('moveUp', $continent->countries->last()->id);

expect($continent->countries->first()->fresh()->sort_order)->toBe(2);
expect($continent->countries->last()->fresh()->sort_order)->toBe(1);
});
it('allows moves sort order up on assicated children', function () {
$continent = Continent::factory()
->hasCountries(2)
->create();

livewire(CountriesRelationManager::class, [
'pageClass' => EditContinent::class,
'ownerRecord' => $continent,
])
->callTableColumnAction('moveUp', $continent->countries->last()->id);

expect($continent->countries->first()->fresh()->sort_order)->toBe(2);
expect($continent->countries->last()->fresh()->sort_order)->toBe(1);
});
However, I'm getting the error:
Failed asserting that a table column with name [moveUp] exists on the [App\Filament\Resources\ContinentResource\RelationManagers\CountriesRelationManager] component.
Failed asserting that null is an instance of class Filament\Tables\Columns\Column.
Failed asserting that a table column with name [moveUp] exists on the [App\Filament\Resources\ContinentResource\RelationManagers\CountriesRelationManager] component.
Failed asserting that null is an instance of class Filament\Tables\Columns\Column.
Any ideas here on how to call moveUp ? Much appreciated!
2 replies
FFilament
Created by ahinkle on 2/16/2024 in #❓┊help
Many to Many Associations on Import?
Any ideas on how to use many to many attachment on Imports?
ImportColumn::make('associated_skus')
->label('Associated SKUs')
->requiredMapping()
->rules(['required'])
->fillRecordUsing(function (BigcommerceItem $record, string $value): void {
$associatedSkus = explode(',', $value);
$record->products()->sync($associatedSkus);
}),
ImportColumn::make('associated_skus')
->label('Associated SKUs')
->requiredMapping()
->rules(['required'])
->fillRecordUsing(function (BigcommerceItem $record, string $value): void {
$associatedSkus = explode(',', $value);
$record->products()->sync($associatedSkus);
}),
returns: An attempt was made to evaluate a closure for [Filament\Actions\Imports\ImportColumn], but [$value] was unresolvable.
3 replies
FFilament
Created by ahinkle on 2/5/2024 in #❓┊help
Writing a test to call toggle on ToggleColumn List Resource
Hey everyone! I'm trying to write a test to toggle the is_enabled ToggleColumn on my Resource. I can't seem to find it in the documentation. Any ideas on how to write a test for this?
it('can toggle feature', function () {
$u = tap(User::factory()->create(), fn (User $user) => $user->givePermissionTo('Access Admin'));
$f = Feature::factory()->disabled()->create();

Livewire::actingAs($u)
->test(ListFeatures::class)
->call('toggleFeature', $f->is_enabled, $f->id); // toggle the feature? guessing here.. I have a ToggleColumn

expect($f->fresh()->is_enabled)->toBeTrue();
});
it('can toggle feature', function () {
$u = tap(User::factory()->create(), fn (User $user) => $user->givePermissionTo('Access Admin'));
$f = Feature::factory()->disabled()->create();

Livewire::actingAs($u)
->test(ListFeatures::class)
->call('toggleFeature', $f->is_enabled, $f->id); // toggle the feature? guessing here.. I have a ToggleColumn

expect($f->fresh()->is_enabled)->toBeTrue();
});
5 replies
FFilament
Created by ahinkle on 1/17/2024 in #❓┊help
Set Global Form Input Label as `Str::headline()`?
In all of my inputs, I find myself overriding the label: Billing first name -> Billing First Name Is there way to override the default setting label to always use Str::headline()? Either in a App Service Provider or service container?
TextInput::make('billing_first_name')
->label('Billing First Name')
TextInput::make('billing_first_name')
->label('Billing First Name')
Tried to do something fun like this but no dice:
TextInput::macro('label', function (string $label): static {
return parent::label(Str::headline($label));
});
TextInput::macro('label', function (string $label): static {
return parent::label(Str::headline($label));
});
3 replies
FFilament
Created by ahinkle on 1/2/2024 in #❓┊help
Table Filter, `BooleanConstraint` relationship exists
Hi friends, I'm attempting to add a QueryBuilder filter with a simple bool of if they have any registered warranties or not. Any ideas on how to get the BooleanConstraint with a relationship to exist? For example, I have this column that is working:
IconColumn::make('warranties_exists')
->label('Registered Warranty')
->exists('warranties')
...
IconColumn::make('warranties_exists')
->label('Registered Warranty')
->exists('warranties')
...
Which I'm trying to add to the filter:
BooleanConstraint::make('warranties_exists'),
BooleanConstraint::make('warranties_exists'),
which wants to apply to the current model:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.warranty_exists' in 'where clause'
SELECT count(*) AS aggregate FROM `users` WHERE (`users`.`warranties_exists` = 1)
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.warranty_exists' in 'where clause'
SELECT count(*) AS aggregate FROM `users` WHERE (`users`.`warranties_exists` = 1)
which I add the relationship method, but it wants a titleAttribute attribute. Unfortunately, the titleAttribute is using the value from the boolean which would be 1.
BooleanConstraint::make('warranties_exists')
->relationship(
name: 'warranties',
titleAttribute: 'id',
),

// Any ideas how to get this to work? titleAttribute uses the value of the boolean.
BooleanConstraint::make('warranties_exists')
->relationship(
name: 'warranties',
titleAttribute: 'id',
),

// Any ideas how to get this to work? titleAttribute uses the value of the boolean.
3 replies
FFilament
Created by ahinkle on 9/1/2023 in #❓┊help
Fields(such as a date range) in Charts?
Hey everyone! I'm on V3. Is it possible to add fields such as start and end date on widget charts? I didn't see anything in the docs— perhaps I overlooked it, or this is more of a custom thing? Examples would be awesome! Thanks!
5 replies
FFilament
Created by ahinkle on 8/12/2023 in #❓┊help
Edit/Remove "Create a (resource) to get started." when `canCreate()` is false
3 replies
FFilament
Created by ahinkle on 8/1/2023 in #❓┊help
Unable to locate a class or view for component [filament::input.wrapper].
Hi guys, Is the input wrapper deprecated for v3?
<x-filament::input.wrapper>
//
</x-filament::input.wrapper>
<x-filament::input.wrapper>
//
</x-filament::input.wrapper>
Getting: Unable to locate a class or view for component [filament::input.wrapper]. Can't seem to find the component on v3. Any ideas?
2 replies
FFilament
Created by ahinkle on 7/31/2023 in #❓┊help
Nullable DateTime Filter Value on Table Filter (v3)
Hi there, I have a table with three inputs: With Trashed Created At (from) Created At (to) The filters work but when I don't use the created_at filter, it defaults to null where it throws an exception: Could not parse 'null': Failed to parse time string (null) at position 0 (n): The timezone could not be found in the database The generated URL: admin/users?tableFilters[trashed][value]=1&tableFilters[Created%20At][created_from]=null&tableFilters[Created%20At][created_until]=null This works on v2 but doesn't work on v3. Any ideas? Filter:
$this->form([
DatePicker::make('created_from')->label('Created From'),
DatePicker::make('created_until')->label('Created Until'),
]);

$this->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['created_from'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '>=', $date),
)
->when(
$data['created_until'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '<=', $date),
);
});
$this->form([
DatePicker::make('created_from')->label('Created From'),
DatePicker::make('created_until')->label('Created Until'),
]);

$this->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['created_from'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '>=', $date),
)
->when(
$data['created_until'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '<=', $date),
);
});
5 replies