From e65e9be650ac33753c638034eab132bf410e1d8f Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Tue, 22 Oct 2024 16:46:20 +0500 Subject: [PATCH] add nova resources --- .../Resources/IncomingLetterResource.php | 67 +++++++++++++++++++ .../Pages/CreateIncomingLetter.php | 12 ++++ .../Pages/EditIncomingLetter.php | 19 ++++++ .../Pages/ListIncomingLetters.php | 19 ++++++ .../Resources/OutgoingLetterResource.php | 67 +++++++++++++++++++ .../Pages/CreateOutgoingLetter.php | 12 ++++ .../Pages/EditOutgoingLetter.php | 19 ++++++ .../Pages/ListOutgoingLetters.php | 19 ++++++ .../Controllers/IncomingLetterController.php | 49 ++++++++++++++ ...2_152424_create_incoming_letters_table.php | 28 ++++++++ .../IncomingLetter/IncomingLetterModule.php | 48 +++++++++++++ .../IncomingLetter/Models/IncomingLetter.php | 11 +++ .../Repositories/IncomingLetterRepository.php | 10 +++ .../Controllers/OutgoingLetterController.php | 49 ++++++++++++++ ...2_152500_create_outgoing_letters_table.php | 28 ++++++++ .../OutgoingLetter/Models/OutgoingLetter.php | 11 +++ .../OutgoingLetter/OutgoingLetterModule.php | 48 +++++++++++++ .../Repositories/OutgoingLetterRepository.php | 10 +++ 18 files changed, 526 insertions(+) create mode 100644 app/Filament/Resources/IncomingLetterResource.php create mode 100644 app/Filament/Resources/IncomingLetterResource/Pages/CreateIncomingLetter.php create mode 100644 app/Filament/Resources/IncomingLetterResource/Pages/EditIncomingLetter.php create mode 100644 app/Filament/Resources/IncomingLetterResource/Pages/ListIncomingLetters.php create mode 100644 app/Filament/Resources/OutgoingLetterResource.php create mode 100644 app/Filament/Resources/OutgoingLetterResource/Pages/CreateOutgoingLetter.php create mode 100644 app/Filament/Resources/OutgoingLetterResource/Pages/EditOutgoingLetter.php create mode 100644 app/Filament/Resources/OutgoingLetterResource/Pages/ListOutgoingLetters.php create mode 100644 app/Modules/IncomingLetter/Controllers/IncomingLetterController.php create mode 100644 app/Modules/IncomingLetter/Database/Migrations/2024_10_22_152424_create_incoming_letters_table.php create mode 100644 app/Modules/IncomingLetter/IncomingLetterModule.php create mode 100644 app/Modules/IncomingLetter/Models/IncomingLetter.php create mode 100644 app/Modules/IncomingLetter/Repositories/IncomingLetterRepository.php create mode 100644 app/Modules/OutgoingLetter/Controllers/OutgoingLetterController.php create mode 100644 app/Modules/OutgoingLetter/Database/Migrations/2024_10_22_152500_create_outgoing_letters_table.php create mode 100644 app/Modules/OutgoingLetter/Models/OutgoingLetter.php create mode 100644 app/Modules/OutgoingLetter/OutgoingLetterModule.php create mode 100644 app/Modules/OutgoingLetter/Repositories/OutgoingLetterRepository.php diff --git a/app/Filament/Resources/IncomingLetterResource.php b/app/Filament/Resources/IncomingLetterResource.php new file mode 100644 index 0000000..64e8a78 --- /dev/null +++ b/app/Filament/Resources/IncomingLetterResource.php @@ -0,0 +1,67 @@ +schema([ + TextInput::make('number') + ->required(), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('number'), + ]) + ->filters([ + // + ]) + ->actions([ + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + ]), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListIncomingLetters::route('/'), + 'create' => Pages\CreateIncomingLetter::route('/create'), + 'edit' => Pages\EditIncomingLetter::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Resources/IncomingLetterResource/Pages/CreateIncomingLetter.php b/app/Filament/Resources/IncomingLetterResource/Pages/CreateIncomingLetter.php new file mode 100644 index 0000000..8aba75e --- /dev/null +++ b/app/Filament/Resources/IncomingLetterResource/Pages/CreateIncomingLetter.php @@ -0,0 +1,12 @@ +schema([ + TextInput::make('number') + ->required() + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('number') + ]) + ->filters([ + // + ]) + ->actions([ + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + ]), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListOutgoingLetters::route('/'), + 'create' => Pages\CreateOutgoingLetter::route('/create'), + 'edit' => Pages\EditOutgoingLetter::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Resources/OutgoingLetterResource/Pages/CreateOutgoingLetter.php b/app/Filament/Resources/OutgoingLetterResource/Pages/CreateOutgoingLetter.php new file mode 100644 index 0000000..a8ba817 --- /dev/null +++ b/app/Filament/Resources/OutgoingLetterResource/Pages/CreateOutgoingLetter.php @@ -0,0 +1,12 @@ +id(); + $table->string('number')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('incoming_letters'); + } +}; diff --git a/app/Modules/IncomingLetter/IncomingLetterModule.php b/app/Modules/IncomingLetter/IncomingLetterModule.php new file mode 100644 index 0000000..e712109 --- /dev/null +++ b/app/Modules/IncomingLetter/IncomingLetterModule.php @@ -0,0 +1,48 @@ +enabled; + } + + /** + * Disable module + */ + public function disable(): void + { + $this->enabled = false; + } + + /** + * Enable module + */ + public function enable(): void + { + $this->enabled = true; + } + + /** + * Check if module has a filament resource + */ + public function hasFilamentResource(): bool + { + return true; + } +} diff --git a/app/Modules/IncomingLetter/Models/IncomingLetter.php b/app/Modules/IncomingLetter/Models/IncomingLetter.php new file mode 100644 index 0000000..de249ae --- /dev/null +++ b/app/Modules/IncomingLetter/Models/IncomingLetter.php @@ -0,0 +1,11 @@ +id(); + $table->string('number')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('outgoing_letters'); + } +}; diff --git a/app/Modules/OutgoingLetter/Models/OutgoingLetter.php b/app/Modules/OutgoingLetter/Models/OutgoingLetter.php new file mode 100644 index 0000000..d6b350e --- /dev/null +++ b/app/Modules/OutgoingLetter/Models/OutgoingLetter.php @@ -0,0 +1,11 @@ +enabled; + } + + /** + * Disable module + */ + public function disable(): void + { + $this->enabled = false; + } + + /** + * Enable module + */ + public function enable(): void + { + $this->enabled = true; + } + + /** + * Check if module has a filament resource + */ + public function hasFilamentResource(): bool + { + return true; + } +} diff --git a/app/Modules/OutgoingLetter/Repositories/OutgoingLetterRepository.php b/app/Modules/OutgoingLetter/Repositories/OutgoingLetterRepository.php new file mode 100644 index 0000000..f360c87 --- /dev/null +++ b/app/Modules/OutgoingLetter/Repositories/OutgoingLetterRepository.php @@ -0,0 +1,10 @@ +