charleswilfriedk
charleswilfriedk
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
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
Hum.. ok and the 2nd solution ?
26 replies
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
Do you get a error message with the first solution ?
26 replies
FFilament
Created by thyk123 on 3/19/2024 in #❓┊help
subtract 2 column table
Hi, you can try this
TextColumn::make('quota')->formatStateUsing(
fn(Model $record) => $record->quota - $record->participant_count)),
TextColumn::make('quota')->formatStateUsing(
fn(Model $record) => $record->quota - $record->participant_count)),
Or append an attribute to your model like this
protected function attribute_name(): Attribute
{
return Attribute::make(
get: fn () => $this->quota - $this->participant_count,
}
protected function attribute_name(): Attribute
{
return Attribute::make(
get: fn () => $this->quota - $this->participant_count,
}
and use it like this
TextColumn::make('attribute_name')
TextColumn::make('attribute_name')
26 replies
FFilament
Created by charleswilfriedk on 3/18/2024 in #❓┊help
Summarize Sum of a calculated field
The relation is named 'products'. In this case i have others attributes in the pivot table so to access them i have to use the 'pivot'. And the table contains the transactions, for each transactions via the 'products' relation i get the products for the transaction then with map i calculate the amount of the transaction.
5 replies
FFilament
Created by Kristijan on 2/27/2024 in #❓┊help
Ordering NavigationGroup inside cluster
I find that NavigationGroup is not working inside a cluster. I can't change the icon either.
3 replies
FFilament
Created by Pandurmonium on 3/8/2024 in #❓┊help
Navigation Parent Items in Clusters
Hi! Tried it and i have the same problem!
3 replies
FFilament
Created by namrata on 9/15/2023 in #❓┊help
Split with label
That will add the label on each line! I don't think that's what we want. Not for me at least.
15 replies
FFilament
Created by charleswilfriedk on 9/25/2023 in #❓┊help
How to send a success notification after a custom action ?
Thx for the help I will look into it
17 replies
FFilament
Created by charleswilfriedk on 9/25/2023 in #❓┊help
How to send a success notification after a custom action ?
But sending the notification directly in the action works!
17 replies
FFilament
Created by charleswilfriedk on 9/25/2023 in #❓┊help
How to send a success notification after a custom action ?
Action::make('reset_user_password')
->action(function (User $record) {
$this->resetPassword($record);
$this->sendSuccessNotification();
})
->requiresConfirmation()
->successNotification(function (Notification $notification): Notification {
return Notification::make()
->success()
->title('User password reset!');
});
Action::make('reset_user_password')
->action(function (User $record) {
$this->resetPassword($record);
$this->sendSuccessNotification();
})
->requiresConfirmation()
->successNotification(function (Notification $notification): Notification {
return Notification::make()
->success()
->title('User password reset!');
});
With this one the sendSuccessNotification is not found.
17 replies
FFilament
Created by charleswilfriedk on 9/25/2023 in #❓┊help
How to send a success notification after a custom action ?
Action::make('reset_user_password')
->action(
fn (User $record) => $this->resetPassword($record)
)
->requiresConfirmation()
->successNotification(
Notification::make()
->success()
->title('User password reset!')
->send(),
);
Action::make('reset_user_password')
->action(
fn (User $record) => $this->resetPassword($record)
)
->requiresConfirmation()
->successNotification(
Notification::make()
->success()
->title('User password reset!')
->send(),
);
17 replies