Timesheets are a special table where records are often grouped by the week. Let's re-create that and add a custom form that would edit all weekdays simultaneously.
One-time payment
Sign in with GitHub to buy
Sign in first, then complete your $9 checkout.
30-day money-back guarantee
First, in the table, we only show the weeks. To achieve this, we must modify the table query. To show value in the tables column, we set it as a default value.
NOTICE: Syntax for the table is for MySQL.
app/Filament/Resources/TimesheetResource.php:
public static function table(Table $table): Table{ return $table ->modifyQueryUsing(function (Builder $query) { $query->selectRaw('id, DATE_FORMAT(date, "%Y-%m-%d") as week_start') ->whereRaw('DAYOFWEEK(date) = 2') // Filter for Mondays only ->distinct() ->groupBy('week_start', 'date', 'id'); }) ->columns([ // ...
Next we will work on: