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.
Get the Source Code:
Only This Example
$9
One-time payment
Full source code for Timesheet Form - Weekly Overview and Week Record Edit
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:
publicstaticfunctiontable(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:
Table display to display one week per row
Custom Edit page that would edit weekly records
Real-time calculations
The FULL tutorial is available after the purchase: in the Readme file of the official
repository you would get invited to.