From d62bf6cd47b303b53aa86bddede1682e5efb3ba4 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 2 Nov 2026 11:18:44 +0530 Subject: [PATCH 1/4] Added courier outward migration file --- ...2_105211_create_courier_outwards_table.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 database/migrations/2026_11_02_105211_create_courier_outwards_table.php diff --git a/database/migrations/2026_11_02_105211_create_courier_outwards_table.php b/database/migrations/2026_11_02_105211_create_courier_outwards_table.php new file mode 100644 index 00000000..09cf66cd --- /dev/null +++ b/database/migrations/2026_11_02_105211_create_courier_outwards_table.php @@ -0,0 +1,46 @@ + Date: Mon, 2 Nov 2026 11:19:24 +0530 Subject: [PATCH 2/4] Added courier outward model file --- app/Models/CourierOutward.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/Models/CourierOutward.php diff --git a/app/Models/CourierOutward.php b/app/Models/CourierOutward.php new file mode 100644 index 00000000..360f4a76 --- /dev/null +++ b/app/Models/CourierOutward.php @@ -0,0 +1,32 @@ +belongsTo(Plant::class); + } +} -- 2.49.1 From c721f45720a1585e44c07873c54d867b6fe96767 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 2 Nov 2026 11:20:41 +0530 Subject: [PATCH 3/4] Added courier outward resource page --- .../Resources/CourierOutwardResource.php | 205 ++++++++++++++++++ .../Pages/CreateCourierOutward.php | 12 + .../Pages/EditCourierOutward.php | 22 ++ .../Pages/ListCourierOutwards.php | 19 ++ .../Pages/ViewCourierOutward.php | 19 ++ 5 files changed, 277 insertions(+) create mode 100644 app/Filament/Resources/CourierOutwardResource.php create mode 100644 app/Filament/Resources/CourierOutwardResource/Pages/CreateCourierOutward.php create mode 100644 app/Filament/Resources/CourierOutwardResource/Pages/EditCourierOutward.php create mode 100644 app/Filament/Resources/CourierOutwardResource/Pages/ListCourierOutwards.php create mode 100644 app/Filament/Resources/CourierOutwardResource/Pages/ViewCourierOutward.php diff --git a/app/Filament/Resources/CourierOutwardResource.php b/app/Filament/Resources/CourierOutwardResource.php new file mode 100644 index 00000000..b1a2397c --- /dev/null +++ b/app/Filament/Resources/CourierOutwardResource.php @@ -0,0 +1,205 @@ +schema([ + Forms\Components\Select::make('plant_id') + ->label('Plant') + ->relationship('plant', 'name') + ->required() + ->reactive() + ->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(); + }) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $plantId = $get('plant_id'); + if (! $plantId) { + $set('cPlantError', 'Please select a plant first.'); + + return; + } else { + $set('cPlantError', null); + } + }) + ->extraAttributes(fn ($get) => [ + 'class' => $get('cPlantError') ? 'border-red-500' : '', + ]) + ->hint(fn ($get) => $get('cPlantError') ? $get('cPlantError') : null) + ->hintColor('danger'), + Forms\Components\DatePicker::make('date') + ->label('Choose Date') + ->default(now()) + ->required(), + Forms\Components\TextInput::make('to_address') + ->label('To Address') + ->required(), + Forms\Components\TextInput::make('cover_material') + ->label('Cover/Material') + ->required(), + Forms\Components\TextInput::make('name_of_sender') + ->label('Name Of Sender') + ->required(), + Forms\Components\TextInput::make('place_pincode') + ->label('Which Place and PinCode') + ->required(), + Forms\Components\TextInput::make('pod_number') + ->label('POD Number') + ->required(), + Forms\Components\TextInput::make('remark') + ->label('Remark'), + 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() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('date') + ->label('Date') + ->alignCenter() + ->searchable() + ->date() + ->sortable(), + Tables\Columns\TextColumn::make('to_address') + ->label('To Address') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('cover_material') + ->label('Cover/Material') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('name_of_sender') + ->label('Name Of Sender') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('place_pincode') + ->label('Which Place Of PinCode') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('pod_number') + ->label('POD Number') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('remark') + ->label('Remark') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('created_at') + ->label('Created At') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('created_by') + ->label('Created By') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('updated_at') + ->label('Updated At') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('updated_by') + ->label('Updated By') + ->alignCenter() + ->searchable() + ->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\ListCourierOutwards::route('/'), + 'create' => Pages\CreateCourierOutward::route('/create'), + 'view' => Pages\ViewCourierOutward::route('/{record}'), + 'edit' => Pages\EditCourierOutward::route('/{record}/edit'), + ]; + } + + public static function getEloquentQuery(): Builder + { + return parent::getEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Filament/Resources/CourierOutwardResource/Pages/CreateCourierOutward.php b/app/Filament/Resources/CourierOutwardResource/Pages/CreateCourierOutward.php new file mode 100644 index 00000000..9a96af3b --- /dev/null +++ b/app/Filament/Resources/CourierOutwardResource/Pages/CreateCourierOutward.php @@ -0,0 +1,12 @@ + Date: Mon, 2 Nov 2026 11:21:27 +0530 Subject: [PATCH 4/4] Added courier outward policy file --- app/Policies/CourierOutwardPolicy.php | 106 ++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 app/Policies/CourierOutwardPolicy.php diff --git a/app/Policies/CourierOutwardPolicy.php b/app/Policies/CourierOutwardPolicy.php new file mode 100644 index 00000000..9831033e --- /dev/null +++ b/app/Policies/CourierOutwardPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any CourierOutward'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, CourierOutward $courieroutward): bool + { + return $user->checkPermissionTo('view CourierOutward'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create CourierOutward'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, CourierOutward $courieroutward): bool + { + return $user->checkPermissionTo('update CourierOutward'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, CourierOutward $courieroutward): bool + { + return $user->checkPermissionTo('delete CourierOutward'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any CourierOutward'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, CourierOutward $courieroutward): bool + { + return $user->checkPermissionTo('restore CourierOutward'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any CourierOutward'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, CourierOutward $courieroutward): bool + { + return $user->checkPermissionTo('replicate CourierOutward'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder CourierOutward'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, CourierOutward $courieroutward): bool + { + return $user->checkPermissionTo('force-delete CourierOutward'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any CourierOutward'); + } +} -- 2.49.1