charleswilfriedk
charleswilfriedk
FFilament
Created by charleswilfriedk on 12/20/2024 in #❓┊help
Notification send before observer creating function is executed
i get it thx
25 replies
FFilament
Created by charleswilfriedk on 12/20/2024 in #❓┊help
Notification send before observer creating function is executed
Ok i think i will put the logic for the rental_number in the mutateFormDataUsing
25 replies
FFilament
Created by charleswilfriedk on 12/20/2024 in #❓┊help
Notification send before observer creating function is executed
I know that but the event is fired by the action right ?
25 replies
FFilament
Created by charleswilfriedk on 12/20/2024 in #❓┊help
Notification send before observer creating function is executed
Buit-in in Filament resource
25 replies
FFilament
Created by charleswilfriedk on 12/20/2024 in #❓┊help
Notification send before observer creating function is executed
The notification is send on the action success
25 replies
FFilament
Created by charleswilfriedk on 12/20/2024 in #❓┊help
Notification send before observer creating function is executed
Ok i will try to better explain it
25 replies
FFilament
Created by charleswilfriedk on 12/20/2024 in #❓┊help
Notification send before observer creating function is executed
On the create action yes
25 replies
FFilament
Created by charleswilfriedk on 12/20/2024 in #❓┊help
Notification send before observer creating function is executed
The notification is send in the Filament resource
25 replies
FFilament
Created by charleswilfriedk on 12/20/2024 in #❓┊help
Notification send before observer creating function is executed
Notification::make() ->success() ->icon('heroicon-m-link') ->title(('filament-resources.notification.rental.update-car-driver.title')) ->body(('filament-resources.notification.rental.update-car-driver.success', ['rental' => $record->rental_number])) ->send() ->sendToDatabase(User::getNotifiableFor(RentalPermissions::NOTIFIED_UPDATED->value), isEventDispatched: true);
25 replies
FFilament
Created by charleswilfriedk on 12/20/2024 in #❓┊help
Notification send before observer creating function is executed
I'm trying to include that rental_number in the notification. It works everywhere else but not on the create action
25 replies
FFilament
Created by charleswilfriedk on 12/20/2024 in #❓┊help
Notification send before observer creating function is executed
public function creating(Rental $rental): void { .... $rental->rental_number = 'NKH-' . now()->format('Y') . mb_str_pad((string) $rental->order, 5, '0', STR_PAD_LEFT); }
25 replies
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
Ok good! Happy to help.
26 replies
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
the count() at the end only works if the return type of $record->participants is a collection
26 replies
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
yes that's the best practice for hasMany and belongsToMany relationships
26 replies
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
TextColumn::make('participants')->formatStateUsing(fn(ClassChoice $record) => $record->participants->count()),
TextColumn::make('participants')->formatStateUsing(fn(ClassChoice $record) => $record->participants->count()),
Only works if the relation name is correct
26 replies
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
Ok first the relationship type is hasMany so change the name to 'participants'
26 replies
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
Don't worry about this! I rely on help from the discord from time to time too
26 replies
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
I think that i should be 'participants' if the relationship is hasMany or belongsToMany. Try this :
TextColumn::make('participants')->formatStateUsing(fn(Model $record) => $record->participants->count()),
TextColumn::make('participants')->formatStateUsing(fn(Model $record) => $record->participants->count()),
26 replies
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
Ok i see where the problem is!
26 replies
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
For the first solution i tried something similar and it should be working. Can you verify that this works correctly :
TextColumn::make('quota')->formatStateUsing(fn(Model $record) => $record->quota),
TextColumn::make('participant_count')->formatStateUsing(fn(Model $record) => $record->participant_count),
TextColumn::make('quota')->formatStateUsing(fn(Model $record) => $record->quota),
TextColumn::make('participant_count')->formatStateUsing(fn(Model $record) => $record->participant_count),
26 replies