From cc6ab2b3313378ca6feb12cc42f298c49375f3c4 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 3 Nov 2026 11:32:04 +0530 Subject: [PATCH 1/4] Added production calendar migration file --- ...1052_create_production_calendars_table.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 database/migrations/2026_11_02_121052_create_production_calendars_table.php diff --git a/database/migrations/2026_11_02_121052_create_production_calendars_table.php b/database/migrations/2026_11_02_121052_create_production_calendars_table.php new file mode 100644 index 00000000..83153639 --- /dev/null +++ b/database/migrations/2026_11_02_121052_create_production_calendars_table.php @@ -0,0 +1,41 @@ + Date: Tue, 3 Nov 2026 11:32:39 +0530 Subject: [PATCH 2/4] Added production calendar model file --- app/Models/ProductionCalendar.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 app/Models/ProductionCalendar.php diff --git a/app/Models/ProductionCalendar.php b/app/Models/ProductionCalendar.php new file mode 100644 index 00000000..eaefa800 --- /dev/null +++ b/app/Models/ProductionCalendar.php @@ -0,0 +1,28 @@ +belongsTo(Plant::class); + } +} From 277a6b3758da20b790d5e01acbb91a9e6da45c1a Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 3 Nov 2026 11:34:46 +0530 Subject: [PATCH 3/4] Added production calendar resource page --- .../Resources/ProductionCalendarResource.php | 131 ++++++++++++++++++ .../Pages/CreateProductionCalendar.php | 12 ++ .../Pages/EditProductionCalendar.php | 22 +++ .../Pages/ListProductionCalendars.php | 19 +++ .../Pages/ViewProductionCalendar.php | 19 +++ 5 files changed, 203 insertions(+) create mode 100644 app/Filament/Resources/ProductionCalendarResource.php create mode 100644 app/Filament/Resources/ProductionCalendarResource/Pages/CreateProductionCalendar.php create mode 100644 app/Filament/Resources/ProductionCalendarResource/Pages/EditProductionCalendar.php create mode 100644 app/Filament/Resources/ProductionCalendarResource/Pages/ListProductionCalendars.php create mode 100644 app/Filament/Resources/ProductionCalendarResource/Pages/ViewProductionCalendar.php diff --git a/app/Filament/Resources/ProductionCalendarResource.php b/app/Filament/Resources/ProductionCalendarResource.php new file mode 100644 index 00000000..f2a85965 --- /dev/null +++ b/app/Filament/Resources/ProductionCalendarResource.php @@ -0,0 +1,131 @@ +schema([ + Forms\Components\Select::make('plant_id') + ->label('Plant') + ->reactive() + ->relationship('plant', 'name') + ->options(function (callable $get) { + $userHas = Filament::auth()->user()->plant_id; + + return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); + }) + ->required(), + Forms\Components\TextInput::make('working_days') + ->label('Working Days'), + Forms\Components\TextInput::make('leave_dates') + ->label('Leave Dates'), + Forms\Components\Hidden::make('created_by') + ->label('Created By') + ->default(Filament::auth()->user()?->name), + Forms\Components\Hidden::make('updated_by') + ->label('Updated By') + ->default(Filament::auth()->user()?->name), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('No.') + ->label('No.') + ->getStateUsing(function ($record, $livewire, $column, $rowLoop) { + $paginator = $livewire->getTableRecords(); + $perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10; + $currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1; + + return ($currentPage - 1) * $perPage + $rowLoop->iteration; + }), + Tables\Columns\TextColumn::make('plant.name') + ->label('Plant') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('working_days') + ->label('Working Days') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('leave_dates') + ->label('Leave Dates') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('created_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('updated_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('deleted_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + ]) + ->filters([ + Tables\Filters\TrashedFilter::make(), + ]) + ->actions([ + Tables\Actions\ViewAction::make(), + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + Tables\Actions\ForceDeleteBulkAction::make(), + Tables\Actions\RestoreBulkAction::make(), + ]), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListProductionCalendars::route('/'), + 'create' => Pages\CreateProductionCalendar::route('/create'), + 'view' => Pages\ViewProductionCalendar::route('/{record}'), + 'edit' => Pages\EditProductionCalendar::route('/{record}/edit'), + ]; + } + + public static function getEloquentQuery(): Builder + { + return parent::getEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Filament/Resources/ProductionCalendarResource/Pages/CreateProductionCalendar.php b/app/Filament/Resources/ProductionCalendarResource/Pages/CreateProductionCalendar.php new file mode 100644 index 00000000..4b76c064 --- /dev/null +++ b/app/Filament/Resources/ProductionCalendarResource/Pages/CreateProductionCalendar.php @@ -0,0 +1,12 @@ + Date: Tue, 3 Nov 2026 11:35:28 +0530 Subject: [PATCH 4/4] Added production calendar policy file --- app/Policies/ProductionCalendarPolicy.php | 106 ++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 app/Policies/ProductionCalendarPolicy.php diff --git a/app/Policies/ProductionCalendarPolicy.php b/app/Policies/ProductionCalendarPolicy.php new file mode 100644 index 00000000..41809070 --- /dev/null +++ b/app/Policies/ProductionCalendarPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any ProductionCalendar'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, ProductionCalendar $productioncalendar): bool + { + return $user->checkPermissionTo('view ProductionCalendar'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create ProductionCalendar'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, ProductionCalendar $productioncalendar): bool + { + return $user->checkPermissionTo('update ProductionCalendar'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, ProductionCalendar $productioncalendar): bool + { + return $user->checkPermissionTo('delete ProductionCalendar'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any ProductionCalendar'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, ProductionCalendar $productioncalendar): bool + { + return $user->checkPermissionTo('restore ProductionCalendar'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any ProductionCalendar'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, ProductionCalendar $productioncalendar): bool + { + return $user->checkPermissionTo('replicate ProductionCalendar'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder ProductionCalendar'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, ProductionCalendar $productioncalendar): bool + { + return $user->checkPermissionTo('force-delete ProductionCalendar'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any ProductionCalendar'); + } +}