base commit
This commit is contained in:
11
app/Filament/Resources/SickLeaves/Pages/CreateSickLeave.php
Normal file
11
app/Filament/Resources/SickLeaves/Pages/CreateSickLeave.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SickLeaves\Pages;
|
||||
|
||||
use App\Filament\Resources\SickLeaves\SickLeaveResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSickLeave extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SickLeaveResource::class;
|
||||
}
|
||||
25
app/Filament/Resources/SickLeaves/Pages/EditSickLeave.php
Normal file
25
app/Filament/Resources/SickLeaves/Pages/EditSickLeave.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SickLeaves\Pages;
|
||||
|
||||
use App\Filament\Resources\SickLeaves\SickLeaveResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSickLeave extends EditRecord
|
||||
{
|
||||
protected static string $resource = SickLeaveResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/SickLeaves/Pages/ListSickLeaves.php
Normal file
19
app/Filament/Resources/SickLeaves/Pages/ListSickLeaves.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SickLeaves\Pages;
|
||||
|
||||
use App\Filament\Resources\SickLeaves\SickLeaveResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSickLeaves extends ListRecords
|
||||
{
|
||||
protected static string $resource = SickLeaveResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/SickLeaves/Pages/ViewSickLeave.php
Normal file
19
app/Filament/Resources/SickLeaves/Pages/ViewSickLeave.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SickLeaves\Pages;
|
||||
|
||||
use App\Filament\Resources\SickLeaves\SickLeaveResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewSickLeave extends ViewRecord
|
||||
{
|
||||
protected static string $resource = SickLeaveResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Filament/Resources/SickLeaves/Schemas/SickLeaveForm.php
Normal file
31
app/Filament/Resources/SickLeaves/Schemas/SickLeaveForm.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SickLeaves\Schemas;
|
||||
|
||||
use App\Filament\Support\HrForm;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SickLeaveForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
HrForm::employeeSelect(),
|
||||
HrForm::leaveDatePicker('start_date', 'Start Date'),
|
||||
HrForm::leaveDatePicker('end_date', 'End Date'),
|
||||
HrForm::leaveDaysDisplay(),
|
||||
TextInput::make('medical_institution')
|
||||
->maxLength(255),
|
||||
Textarea::make('reason')
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
HrForm::fileUpload('document_path')
|
||||
->label('Medical Document')
|
||||
->acceptedFileTypes(['application/pdf', 'image/*'])
|
||||
->maxSize(10240),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SickLeaves\Schemas;
|
||||
|
||||
use App\Models\SickLeave;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SickLeaveInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('employee.id')
|
||||
->label('Employee'),
|
||||
TextEntry::make('start_date')
|
||||
->date(),
|
||||
TextEntry::make('end_date')
|
||||
->date(),
|
||||
TextEntry::make('days')
|
||||
->numeric(),
|
||||
TextEntry::make('medical_institution')
|
||||
->placeholder('-'),
|
||||
TextEntry::make('reason')
|
||||
->placeholder('-')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('document_path')
|
||||
->placeholder('-'),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('deleted_at')
|
||||
->dateTime()
|
||||
->visible(fn (SickLeave $record): bool => $record->trashed()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
77
app/Filament/Resources/SickLeaves/SickLeaveResource.php
Normal file
77
app/Filament/Resources/SickLeaves/SickLeaveResource.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\SickLeaves;
|
||||
|
||||
use App\Filament\Resources\SickLeaves\Pages\CreateSickLeave;
|
||||
use App\Filament\Resources\SickLeaves\Pages\EditSickLeave;
|
||||
use App\Filament\Resources\SickLeaves\Pages\ListSickLeaves;
|
||||
use App\Filament\Resources\SickLeaves\Pages\ViewSickLeave;
|
||||
use App\Filament\Resources\SickLeaves\Schemas\SickLeaveForm;
|
||||
use App\Filament\Resources\SickLeaves\Schemas\SickLeaveInfolist;
|
||||
use App\Filament\Resources\SickLeaves\Tables\SickLeavesTable;
|
||||
use App\Models\SickLeave;
|
||||
use BackedEnum;
|
||||
use UnitEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class SickLeaveResource extends Resource
|
||||
{
|
||||
protected static ?string $model = SickLeave::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedHeart;
|
||||
|
||||
protected static string | UnitEnum | null $navigationGroup = 'Leave Management';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'id';
|
||||
|
||||
protected static bool $isGloballySearchable = false;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return SickLeaveForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return SickLeaveInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return SickLeavesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListSickLeaves::route('/'),
|
||||
'create' => CreateSickLeave::route('/create'),
|
||||
'view' => ViewSickLeave::route('/{record}'),
|
||||
'edit' => EditSickLeave::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getRecordRouteBindingEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getRecordRouteBindingEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
72
app/Filament/Resources/SickLeaves/Tables/SickLeavesTable.php
Normal file
72
app/Filament/Resources/SickLeaves/Tables/SickLeavesTable.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SickLeaves\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\RestoreBulkAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class SickLeavesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('employee.full_name')
|
||||
->label('Employee')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('start_date')
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('end_date')
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('days')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('medical_institution')
|
||||
->searchable()
|
||||
->toggleable(),
|
||||
IconColumn::make('document_path')
|
||||
->label('Document')
|
||||
->boolean()
|
||||
->trueIcon('heroicon-o-document-check')
|
||||
->falseIcon('heroicon-o-document')
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make(),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
ForceDeleteBulkAction::make(),
|
||||
RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user