Arjan
Arjan
FFilament
Created by Arjan on 11/2/2024 in #❓┊help
Change profile route slug?
Is it possible to change the profile route slug? Like it is possible to do this for autentication routes in the panelprovider:
->loginRouteSlug('login')
->registrationRouteSlug('register')
->passwordResetRoutePrefix('password-reset')
->passwordResetRequestRouteSlug('request')
->passwordResetRouteSlug('reset')
->emailVerificationRoutePrefix('email-verification')
->emailVerificationPromptRouteSlug('prompt')
->emailVerificationRouteSlug('verify');
->loginRouteSlug('login')
->registrationRouteSlug('register')
->passwordResetRoutePrefix('password-reset')
->passwordResetRequestRouteSlug('request')
->passwordResetRouteSlug('reset')
->emailVerificationRoutePrefix('email-verification')
->emailVerificationPromptRouteSlug('prompt')
->emailVerificationRouteSlug('verify');
I also want to change route slug for profile from '/profile' to '/account'. Thanks!
8 replies
FFilament
Created by Arjan on 10/31/2024 in #❓┊help
Custom Notification for ExportAction
How do I display a custom notification for an ExportAction? Using the 'normal' way does not work, the ExportAction keeps on displaying the default notification. My code:
ExportAction::make()
->successNotification(
Notification::make()
->success()
->title('Export started....')
->body('Go to My Exports to download the file.'),
)
->exporter(PaymentExporter::class),
ExportAction::make()
->successNotification(
Notification::make()
->success()
->title('Export started....')
->body('Go to My Exports to download the file.'),
)
->exporter(PaymentExporter::class),
Thanks for you help!
3 replies
FFilament
Created by Arjan on 10/29/2024 in #❓┊help
Follow/Unfollow record is not working
I want to toggle follow/unfollow actions for each $record (table row):
Action::make('follow')
->label('Volgen')
->visible(fn(Series $record) => !auth()->user()->series->contains($record))
->color('info')
->icon('heroicon-o-star')
->action(function (Action $action, ListAllSeries $livewire, Series $record, SeriesService $service) {
$service->follow($record);
$action->success();
$livewire->getTableRecords()->fresh();
Notification::make()
->title("{$record->name} gevolgd")
->icon('heroicon-o-star')
->iconColor('success')
->send();
}),
Action::make('unfollow')
->label('Volgend')
->visible(fn(Series $record) => auth()->user()->series->contains($record))
->color('success')
->icon('heroicon-o-star')
->action(function (Action $action, Series $record, SeriesService $service) {
$service->unfollow($record);
Notification::make()
->title("{$record->name} ontvolgd")
->icon('heroicon-o-star')
->iconColor('primary')
->send();
}),
Action::make('follow')
->label('Volgen')
->visible(fn(Series $record) => !auth()->user()->series->contains($record))
->color('info')
->icon('heroicon-o-star')
->action(function (Action $action, ListAllSeries $livewire, Series $record, SeriesService $service) {
$service->follow($record);
$action->success();
$livewire->getTableRecords()->fresh();
Notification::make()
->title("{$record->name} gevolgd")
->icon('heroicon-o-star')
->iconColor('success')
->send();
}),
Action::make('unfollow')
->label('Volgend')
->visible(fn(Series $record) => auth()->user()->series->contains($record))
->color('success')
->icon('heroicon-o-star')
->action(function (Action $action, Series $record, SeriesService $service) {
$service->unfollow($record);
Notification::make()
->title("{$record->name} ontvolgd")
->icon('heroicon-o-star')
->iconColor('primary')
->send();
}),
However, when I click 'follow,' the action gets executed, but the 'follow' action does not get hidden, and the unfollow action does not get shown. I am using
$livewire->getTableRecords()->fresh();
$livewire->getTableRecords()->fresh();
but this does not work. Please help.
6 replies
FFilament
Created by Arjan on 10/24/2024 in #❓┊help
Searchable MorphTo
I want to make a column searchable:
TextColumn::make('model.name')
->url(function (BankAccount $record): string {
if ($record->model instanceof Project) {
return ProjectResource::getUrl('view', ['record' => $record->model]);
} elseif ($record->model instanceof Party) {
return PartyResource::getUrl('view', ['record' => $record->model]);
}
})
->icon(function (BankAccount $record): string {
if ($record->model instanceof Project) {
return ProjectResource::getNavigationIcon();
} elseif ($record->model instanceof Party) {
return PartyResource::getNavigationIcon();
}
})
->sortable(false)
->searchable()
->label('Belongs to'),
TextColumn::make('model.name')
->url(function (BankAccount $record): string {
if ($record->model instanceof Project) {
return ProjectResource::getUrl('view', ['record' => $record->model]);
} elseif ($record->model instanceof Party) {
return PartyResource::getUrl('view', ['record' => $record->model]);
}
})
->icon(function (BankAccount $record): string {
if ($record->model instanceof Project) {
return ProjectResource::getNavigationIcon();
} elseif ($record->model instanceof Party) {
return PartyResource::getNavigationIcon();
}
})
->sortable(false)
->searchable()
->label('Belongs to'),
The model.name is from a relation:
public function model(): MorphTo
{
return $this->morphTo();
}
public function model(): MorphTo
{
return $this->morphTo();
}
But when I do a search I get an error: TypeError PHP 8.2.15 11.15.0 Illegal offset type Please help! Thanks!
5 replies
FFilament
Created by Arjan on 10/19/2024 in #❓┊help
successNotificationTitle for table action is not showing
The successNotificationTitle for my (custom) action is not showing after the action has been successfully executed. Does anyone know why? This is my code:
Tables\Actions\Action::make('Watchlist')
->color('warning')
->icon(MyWatchlistResource::getNavigationIcon())
->successNotificationTitle('Project added to your watchlist')
->action(function (Project $record) {
Watchlist::updateOrCreate([
'project_id' => $record->id,
'user_id' => auth()->user()->id,
]);
}),
Tables\Actions\Action::make('Watchlist')
->color('warning')
->icon(MyWatchlistResource::getNavigationIcon())
->successNotificationTitle('Project added to your watchlist')
->action(function (Project $record) {
Watchlist::updateOrCreate([
'project_id' => $record->id,
'user_id' => auth()->user()->id,
]);
}),
5 replies
FFilament
Created by Arjan on 4/28/2024 in #❓┊help
Current model in RepeatableEntry
How do I get the current model in a RepeatableEntry so I can use it in url()?
5 replies
FFilament
Created by Arjan on 4/14/2024 in #❓┊help
QueryBuilder -> NumberConstraint for Money
Hi, I am storing an amount in cents in the database as integer in field 'gross'. And I am converting cents to dollars using casting:
public function get($model, string $key, $value, array $attributes): float
{
// Transform the integer stored in the database into a float.
return round(floatval($value) / 100, precision: 2);
}

public function set($model, string $key, $value, array $attributes): float
{
// Transform the float into an integer for storage.
return round(floatval($value) * 100);
}
public function get($model, string $key, $value, array $attributes): float
{
// Transform the integer stored in the database into a float.
return round(floatval($value) / 100, precision: 2);
}

public function set($model, string $key, $value, array $attributes): float
{
// Transform the float into an integer for storage.
return round(floatval($value) * 100);
}
So, 100 dollars are saved in the database as 10000 (cents). Now, I want to make a NumberConstraint so the user can filter this integer field 'gross' by providing dollars (NOT cents). Input '100' should be converted to '10000' so the correct rows are filtered from the database. How do I do this??? Thanks for your help.
6 replies
FFilament
Created by Arjan on 4/11/2024 in #❓┊help
Call to a member function getRelationExistenceQuery() on null
I am using this filter:
SelectConstraint::make('parent.metadata.title')
->options(fn() => Asset::whereHas('parent')->with('parent.metadata')->get()->pluck('parent.metadata.title', 'parent.metadata.title'))
->multiple()
->nullable()
->label('Belongs to')
->relationship('parent.metadata', 'title'),


public function parent(): MorphTo
{
return $this->morphTo('parent');
}
SelectConstraint::make('parent.metadata.title')
->options(fn() => Asset::whereHas('parent')->with('parent.metadata')->get()->pluck('parent.metadata.title', 'parent.metadata.title'))
->multiple()
->nullable()
->label('Belongs to')
->relationship('parent.metadata', 'title'),


public function parent(): MorphTo
{
return $this->morphTo('parent');
}
the parent is a morphTo relation from Asset. The loading of options is executed normally. But then when I select an option I get the error 'Call to a member function getRelationExistenceQuery() on null'. Parent morphs now to 2 different models. Strange thing is that if parent only uses (morphs to) 1 model there is NO error and everthing works correctly. PLEASE HELP!
2 replies
FFilament
Created by Arjan on 4/1/2024 in #❓┊help
QueryBuilder is not filtering Numbers correctly
No description
11 replies
FFilament
Created by Arjan on 3/31/2024 in #❓┊help
QueryBuilder with an relationship->counts()
Hi, I am using this column with a count of related Assets (hasMany relationship) in my table: TextColumn::make('assets_count') ->numeric() ->label('Assets') ->counts('assets'), I now want to make a filter for this column using Querybuilder: NumberConstraint::make('assets_count') ->relationship( name: 'assets', titleAttribute: 'id', modifyQueryUsing: fn(Builder $query) => $query->count(), ) ->label("Assets"), However this NumberContraint is not working and throws this error: SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "series" LINE 1: select count() as aggregate from "assets" where "series"."i... ^ SELECT count() AS aggregate FROM "assets" WHERE "series"."id" = "assets"."series_id" Please help! Thanks!
5 replies