Timesheet Form - Weekly Overview and Week Record Edit

Filament 4

This project illustrates creating fully customized forms dynamically generated from database values.

01JAAN3J7XNKCM8M5B3VS823CY

Get the Source Code:

How it works

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/Timesheets/Tables/TimesheetsTable.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([
TextColumn::make('week')
->default(function (Timesheet $record) {
return "Week {$record->week_start->format('Y m d')} - {$record->week_start->endOfWeek()->format('Y m d')}";
}),
])
// ...
}

On the week_start, we can use Carbon features because the Model casts it to a date.

The FULL tutorial is available after the purchase: in the Readme file of the official repository you would get invited to.
Get the Source Code: All 113 Premium Examples for $99