base commit
This commit is contained in:
51
app/Filament/Widgets/UpcomingLeaveWidget.php
Normal file
51
app/Filament/Widgets/UpcomingLeaveWidget.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Models\Vacation;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class UpcomingLeaveWidget extends TableWidget
|
||||
{
|
||||
protected static ?string $heading = 'Upcoming Approved Leave (14 Days)';
|
||||
|
||||
protected int | string | array $columnSpan = 1;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(
|
||||
Vacation::query()
|
||||
->with('employee')
|
||||
->where('status', ApprovalStatus::Approved)
|
||||
->whereDate('start_date', '>=', now()->toDateString())
|
||||
->whereDate('start_date', '<=', now()->addDays(14)->toDateString())
|
||||
->orderBy('start_date'),
|
||||
)
|
||||
->columns([
|
||||
TextColumn::make('employee.full_name')
|
||||
->label('Employee'),
|
||||
TextColumn::make('start_date')
|
||||
->date(),
|
||||
TextColumn::make('end_date')
|
||||
->date(),
|
||||
TextColumn::make('days')
|
||||
->label('Days'),
|
||||
])
|
||||
->paginated(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder<Vacation>|null
|
||||
*/
|
||||
protected function getTableQuery(): ?Builder
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user