varovas
varovas
FFilament
Created by varovas on 9/3/2024 in #❓┊help
file upload error
No description
16 replies
FFilament
Created by varovas on 8/22/2024 in #❓┊help
Do something with record after save
Hi, somehow I did not find a solution for doing something with a record after it was created/updated. Use case: I want to place a checkbox to a resource form. Then when record was created or updated, I want to check if that checkbox was checked and if it was, I want to create a job operation. Example:
public function afterSaveHook(Model $model, array $data)
{
if (isset($data['is_completed']) {
SendCompletedNotification::dispatch($model);
}
}
public function afterSaveHook(Model $model, array $data)
{
if (isset($data['is_completed']) {
SendCompletedNotification::dispatch($model);
}
}
4 replies
FFilament
Created by varovas on 7/30/2024 in #❓┊help
Eager loaded relationships filter
Hi, does anyone know how make a filter that would filter record's relationships. What I basically need is I want to display all users, but be able to filter how many posts have they posted between 2 dates. Below you can see the code I tries, but somehow it does not work. Or maybe it is not possible that way?
Filter::make('start')
->form([
DatePicker::make('start_date')->label('Start Date'),
])
->query(function ($query, array $data) {
$startDate = Carbon::parse($data['start_date'])->format('Y-m-d');
return $query->with('posts', function ($q) use ($startDate) {
$q->where('date', '>=', $startDate);
});
}),
Filter::make('start')
->form([
DatePicker::make('start_date')->label('Start Date'),
])
->query(function ($query, array $data) {
$startDate = Carbon::parse($data['start_date'])->format('Y-m-d');
return $query->with('posts', function ($q) use ($startDate) {
$q->where('date', '>=', $startDate);
});
}),
14 replies