generated from theradcoza/Laravel-Docker-Dev-Template
feat: add Shift Planning module with full CRUD, attendance, and reporting
- Add shifts, shift_staff, and shift_attendance migrations - Add Shift, ShiftStaff, ShiftAttendance Eloquent models with auditing - Add ShiftService with business logic (create, start, complete, assign staff, mark attendance, reports, timesheets) - Add ShiftResource with list, create, edit, and attendance management pages - Add staff and attendance relation managers - Add standalone pages: ActiveShifts, StaffManagement, ShiftReports, Timesheets - Add dashboard widgets: ShiftOverview stats, TodaysShifts table - Add ShiftPolicy for role-based authorization - Add 10 shift permissions and manager role to RolePermissionSeeder - Update User model with shift relationships - Fix audits table migration with required columns for owen-it/laravel-auditing - Update DatabaseSeeder to create admin user and call RolePermissionSeeder - Switch docker-compose to MariaDB 10.11 for Docker Desktop compatibility
This commit is contained in:
61
src/app/Filament/Pages/StaffManagement.php
Normal file
61
src/app/Filament/Pages/StaffManagement.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\User;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class StaffManagement extends Page implements HasTable
|
||||
{
|
||||
use InteractsWithTable;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-user-group';
|
||||
|
||||
protected static ?string $navigationGroup = 'Shift Management';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static ?string $navigationLabel = 'Staff';
|
||||
|
||||
protected static string $view = 'filament.pages.staff-management';
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(
|
||||
User::query()
|
||||
->withCount([
|
||||
'shifts',
|
||||
'shifts as upcoming_shifts_count' => fn (Builder $q) => $q->where('status', 'planned'),
|
||||
'shifts as active_shifts_count' => fn (Builder $q) => $q->where('status', 'in_progress'),
|
||||
])
|
||||
)
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('shifts_count')
|
||||
->label('Total Shifts')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('upcoming_shifts_count')
|
||||
->label('Upcoming')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('active_shifts_count')
|
||||
->label('Active')
|
||||
->sortable(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\Action::make('viewTimesheet')
|
||||
->label('Timesheet')
|
||||
->icon('heroicon-o-clock')
|
||||
->url(fn (User $record) => Timesheets::getUrl(['staff_id' => $record->id])),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user