charleswilfriedk
charleswilfriedk
FFilament
Created by charleswilfriedk on 3/18/2024 in #❓┊help
Summarize Sum of a calculated field
Hi! I'm trying to show the sum of a calculated attribute. I have a Transaction model which has many Products. The pivot table has the quantity and the unit price for the product. So i have the attribute amount which is calculated and appended to the transaction.
protected function amount(): Attribute
{
return Attribute::make(
get: function () {
return $this?->products->map(
fn ($product) => $product->pivot->quantity * $product->pivot->unit_price
)->sum();
},
);
}
protected function amount(): Attribute
{
return Attribute::make(
get: function () {
return $this?->products->map(
fn ($product) => $product->pivot->quantity * $product->pivot->unit_price
)->sum();
},
);
}
I can display the amount on my table with TextColumn('amount'), but when i try to add the summary i get a error that transactions.amount is not a field in the DB. So my question is how do i make it use the eloquent model instead of a DB query?
5 replies
FFilament
Created by charleswilfriedk on 3/11/2024 in #❓┊help
cluster navigation doesn't show on view page
Hi everyone is there a way to keep the cluster navigation visible on view resource page ?
3 replies
FFilament
Created by charleswilfriedk on 9/25/2023 in #❓┊help
How to send a success notification after a custom action ?
Hello, i'm trying to send a notification after a custom action but no notification get fired. My code : Action::make('reset_user_password') ->action( fn (User $record) => $this->resetPassword($record) ) ->requiresConfirmation() ->successNotification( Notification::make() ->success() ->title('User password reset!'), );
17 replies
FFilament
Created by charleswilfriedk on 9/17/2023 in #❓┊help
Display user avatar with ImageColumn
I want to display the avatar for my users. I added HasAvatars to the User model and all but ImageColumn::make('avatar_url') returns nothing. It's supposed to return the generated ui-avatars if the avatar_url is null right ? I'm lost.
10 replies
FFilament
Created by charleswilfriedk on 9/17/2023 in #❓┊help
How to add $record and $ownerRecord in a relation manager notification
Hi everyone! I'm trying to add the record and the owner record name in the success notification on the create action. This is what i tried but it's not working. Notification::make()->success() ->title( fn (RelationManager $livewire, Model $record) => "{$record->name} successfully added to {$livewire->ownerRecord->name}." )
19 replies