From d43ab7b73db25d86cd98c3a13b5e8db83582963b Mon Sep 17 00:00:00 2001 From: Joh Yoshida Date: Wed, 8 Jan 2025 15:47:36 -0800 Subject: [PATCH 01/12] Add CSV import for SelectOptions --- .../Forms/Resources/SelectOptionsResource.php | 13 ++-- .../Imports/SelectOptionsImporter.php | 67 +++++++++++++++++++ 2 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 app/Filament/Imports/SelectOptionsImporter.php diff --git a/app/Filament/Forms/Resources/SelectOptionsResource.php b/app/Filament/Forms/Resources/SelectOptionsResource.php index eb05428..dba87ea 100644 --- a/app/Filament/Forms/Resources/SelectOptionsResource.php +++ b/app/Filament/Forms/Resources/SelectOptionsResource.php @@ -4,12 +4,14 @@ use App\Filament\Forms\Resources\SelectOptionsResource\Pages; use App\Filament\Forms\Resources\SelectOptionsResource\RelationManagers; +use App\Filament\Imports\SelectOptionsImporter; use App\Models\SelectOptions; use Filament\Forms; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; +use Filament\Tables\Actions\ImportAction; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\SoftDeletingScope; @@ -74,12 +76,11 @@ public static function table(Table $table): Table ->bulkActions([ // ]) - ->paginated([ - 10, - 25, - 50, - 100, - ]); + ->headerActions([ + ImportAction::make('Import CSV') + ->importer(SelectOptionsImporter::class) + ]) + ->paginated([10, 25, 50, 100,]); } public static function getRelations(): array diff --git a/app/Filament/Imports/SelectOptionsImporter.php b/app/Filament/Imports/SelectOptionsImporter.php new file mode 100644 index 0000000..4dd6338 --- /dev/null +++ b/app/Filament/Imports/SelectOptionsImporter.php @@ -0,0 +1,67 @@ +rules(['required']) + ->requiredMapping() + ->example('eye_color_brown'), + ImportColumn::make('label') + ->example('Brown'), + ImportColumn::make('value') + ->example('1'), + ImportColumn::make('description') + ->example('This option is used for...'), + // ImportColumn::make('form_fields') + // ->array(',') + // ->guess(['fields', 'elements', 'form_elements']) + // // ->rules(['required', 'exists:form_fields,id']) + // ->requiredMapping() + // ->integer() + // ->example('4,17') + // ->relationship(resolveUsing: function (string $state): ?SelectOptions { + // $formFieldIDs = Str::of($state)->explode(','); + // // dd($formFieldIDs); + // return SelectOptions::query() + // ->whereHas('formFields', function ($query) use ($formFieldIDs) { + // $query->whereIn('id', $formFieldIDs); + // }) + // ->first(); + // }) + ]; + } + + public function resolveRecord(): ?SelectOptions + { + return SelectOptions::firstOrNew([ + // Update existing records, matching them by `$this->data['column_name']` + 'name' => $this->data['name'], + ]); + + return new SelectOptions(); + } + + public static function getCompletedNotificationBody(Import $import): string + { + $body = 'Your select options import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.'; + + if ($failedRowsCount = $import->getFailedRowsCount()) { + $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.'; + } + + return $body; + } +} From dc5365a773b44efd8fb8f1b9a16dfa3cc8440af9 Mon Sep 17 00:00:00 2001 From: Joh Yoshida Date: Wed, 8 Jan 2025 15:49:29 -0800 Subject: [PATCH 02/12] Revert "Add CSV import for SelectOptions" This reverts commit d43ab7b73db25d86cd98c3a13b5e8db83582963b. --- .../Forms/Resources/SelectOptionsResource.php | 13 ++-- .../Imports/SelectOptionsImporter.php | 67 ------------------- 2 files changed, 6 insertions(+), 74 deletions(-) delete mode 100644 app/Filament/Imports/SelectOptionsImporter.php diff --git a/app/Filament/Forms/Resources/SelectOptionsResource.php b/app/Filament/Forms/Resources/SelectOptionsResource.php index dba87ea..eb05428 100644 --- a/app/Filament/Forms/Resources/SelectOptionsResource.php +++ b/app/Filament/Forms/Resources/SelectOptionsResource.php @@ -4,14 +4,12 @@ use App\Filament\Forms\Resources\SelectOptionsResource\Pages; use App\Filament\Forms\Resources\SelectOptionsResource\RelationManagers; -use App\Filament\Imports\SelectOptionsImporter; use App\Models\SelectOptions; use Filament\Forms; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; -use Filament\Tables\Actions\ImportAction; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\SoftDeletingScope; @@ -76,11 +74,12 @@ public static function table(Table $table): Table ->bulkActions([ // ]) - ->headerActions([ - ImportAction::make('Import CSV') - ->importer(SelectOptionsImporter::class) - ]) - ->paginated([10, 25, 50, 100,]); + ->paginated([ + 10, + 25, + 50, + 100, + ]); } public static function getRelations(): array diff --git a/app/Filament/Imports/SelectOptionsImporter.php b/app/Filament/Imports/SelectOptionsImporter.php deleted file mode 100644 index 4dd6338..0000000 --- a/app/Filament/Imports/SelectOptionsImporter.php +++ /dev/null @@ -1,67 +0,0 @@ -rules(['required']) - ->requiredMapping() - ->example('eye_color_brown'), - ImportColumn::make('label') - ->example('Brown'), - ImportColumn::make('value') - ->example('1'), - ImportColumn::make('description') - ->example('This option is used for...'), - // ImportColumn::make('form_fields') - // ->array(',') - // ->guess(['fields', 'elements', 'form_elements']) - // // ->rules(['required', 'exists:form_fields,id']) - // ->requiredMapping() - // ->integer() - // ->example('4,17') - // ->relationship(resolveUsing: function (string $state): ?SelectOptions { - // $formFieldIDs = Str::of($state)->explode(','); - // // dd($formFieldIDs); - // return SelectOptions::query() - // ->whereHas('formFields', function ($query) use ($formFieldIDs) { - // $query->whereIn('id', $formFieldIDs); - // }) - // ->first(); - // }) - ]; - } - - public function resolveRecord(): ?SelectOptions - { - return SelectOptions::firstOrNew([ - // Update existing records, matching them by `$this->data['column_name']` - 'name' => $this->data['name'], - ]); - - return new SelectOptions(); - } - - public static function getCompletedNotificationBody(Import $import): string - { - $body = 'Your select options import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.'; - - if ($failedRowsCount = $import->getFailedRowsCount()) { - $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.'; - } - - return $body; - } -} From 936a9b8cd337dd0bf5eda0bb5de300193d0bcd97 Mon Sep 17 00:00:00 2001 From: Joh Yoshida Date: Wed, 8 Jan 2025 15:53:48 -0800 Subject: [PATCH 03/12] Add CSV import for SelectOptions --- .../Forms/Resources/SelectOptionsResource.php | 6 +++ .../Imports/SelectOptionsImporter.php | 51 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 app/Filament/Imports/SelectOptionsImporter.php diff --git a/app/Filament/Forms/Resources/SelectOptionsResource.php b/app/Filament/Forms/Resources/SelectOptionsResource.php index eb05428..b68a759 100644 --- a/app/Filament/Forms/Resources/SelectOptionsResource.php +++ b/app/Filament/Forms/Resources/SelectOptionsResource.php @@ -4,11 +4,13 @@ use App\Filament\Forms\Resources\SelectOptionsResource\Pages; use App\Filament\Forms\Resources\SelectOptionsResource\RelationManagers; +use App\Filament\Imports\SelectOptionsImporter; use App\Models\SelectOptions; use Filament\Forms; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; +use Filament\Tables\Actions\ImportAction; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\SoftDeletingScope; @@ -71,6 +73,10 @@ public static function table(Table $table): Table Tables\Actions\ViewAction::make(), Tables\Actions\EditAction::make(), ]) + ->headerActions([ + ImportAction::make('Import CSV') + ->importer(SelectOptionsImporter::class) + ]) ->bulkActions([ // ]) diff --git a/app/Filament/Imports/SelectOptionsImporter.php b/app/Filament/Imports/SelectOptionsImporter.php new file mode 100644 index 0000000..bddc6ea --- /dev/null +++ b/app/Filament/Imports/SelectOptionsImporter.php @@ -0,0 +1,51 @@ +requiredMapping() + ->rules(['required']) + ->example('eye_color_brown'), + ImportColumn::make('label') + ->example('Brown'), + ImportColumn::make('value') + ->example('1'), + ImportColumn::make('description') + ->example('This option is used for...'), + ]; + } + + public function resolveRecord(): ?SelectOptions + { + return SelectOptions::firstOrNew([ + // Update existing records, matching them by `$this->data['column_name']` + 'name' => $this->data['name'], + ]); + + return new SelectOptions(); + } + + public static function getCompletedNotificationBody(Import $import): string + { + $body = 'Your select options import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.'; + + if ($failedRowsCount = $import->getFailedRowsCount()) { + $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.'; + } + + return $body; + } +} From 05c898a0bd636b1bcb8d479760242699ba84a153 Mon Sep 17 00:00:00 2001 From: Joh Yoshida Date: Thu, 9 Jan 2025 10:53:51 -0800 Subject: [PATCH 04/12] Changed SelectOptions repeater to a multi-select Removed ability to create new SelectOptions from FormField page in favor of multi-select. Also reorganized fields for better use. --- .../Forms/Resources/FormFieldResource.php | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/app/Filament/Forms/Resources/FormFieldResource.php b/app/Filament/Forms/Resources/FormFieldResource.php index c3208c1..dc1feac 100644 --- a/app/Filament/Forms/Resources/FormFieldResource.php +++ b/app/Filament/Forms/Resources/FormFieldResource.php @@ -43,6 +43,21 @@ public static function form(Form $form): Form ->required(), Forms\Components\TextInput::make('label') ->required(), + Forms\Components\Select::make('data_type_id') + ->relationship('dataType', 'name') + ->required() + ->live(), + Forms\Components\Select::make('selectOptions') + ->label('Select Options') + ->relationship('selectOptions', 'label') + ->multiple() + ->preload() + ->live() + ->visible(function ($get) { + $dataTypeId = $get('data_type_id'); + $dataType = \App\Models\DataType::find($dataTypeId); + return $dataType && in_array($dataType->name, ['radio', 'dropdown']); + }), Forms\Components\Select::make('data_binding_path') ->label('Field data source') ->options(FormDataSource::pluck('name', 'name')), @@ -69,10 +84,6 @@ public static function form(Form $form): Form ->collapsed(), Forms\Components\Textarea::make('help_text') ->columnSpanFull(), - Forms\Components\Select::make('data_type_id') - ->relationship('dataType', 'name') - ->required() - ->live(), Forms\Components\Textarea::make('value') ->label('Field Value') ->visible(function (callable $get) { @@ -87,21 +98,6 @@ public static function form(Form $form): Form ->multiple() ->preload() ->relationship('fieldGroups', 'name'), - Forms\Components\Repeater::make('selectOptions') - ->label('Select Options') - ->relationship('selectOptions') - ->columnSpanFull() - ->visible(function ($get) { - $dataTypeId = $get('data_type_id'); - $dataType = \App\Models\DataType::find($dataTypeId); - return $dataType && in_array($dataType->name, ['radio', 'dropdown']); - }) - ->schema([ - Forms\Components\TextInput::make('name')->required(), - Forms\Components\TextInput::make('label'), - Forms\Components\TextInput::make('value'), - Forms\Components\Textarea::make('description'), - ]), ]); } From 708bfb1e53cbe6e3112b9eb63f614ed13c3e5edd Mon Sep 17 00:00:00 2001 From: Joh Yoshida Date: Thu, 9 Jan 2025 14:18:37 -0800 Subject: [PATCH 05/12] Unique names ignore existing record --- app/Filament/Forms/Resources/FieldGroupResource.php | 2 +- app/Filament/Forms/Resources/FormFieldResource.php | 2 +- app/Filament/Forms/Resources/SelectOptionsResource.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Filament/Forms/Resources/FieldGroupResource.php b/app/Filament/Forms/Resources/FieldGroupResource.php index 076df6d..8f4c179 100644 --- a/app/Filament/Forms/Resources/FieldGroupResource.php +++ b/app/Filament/Forms/Resources/FieldGroupResource.php @@ -26,7 +26,7 @@ public static function form(Form $form): Form return $form ->schema([ TextInput::make('name') - ->unique() + ->unique(ignoreRecord: true) ->required(), TextInput::make('label') ->required(), diff --git a/app/Filament/Forms/Resources/FormFieldResource.php b/app/Filament/Forms/Resources/FormFieldResource.php index e79a85e..63cb3c1 100644 --- a/app/Filament/Forms/Resources/FormFieldResource.php +++ b/app/Filament/Forms/Resources/FormFieldResource.php @@ -41,7 +41,7 @@ public static function form(Form $form): Form return $form ->schema([ Forms\Components\TextInput::make('name') - ->unique() + ->unique(ignoreRecord: true) ->required(), Forms\Components\TextInput::make('label') ->required(), diff --git a/app/Filament/Forms/Resources/SelectOptionsResource.php b/app/Filament/Forms/Resources/SelectOptionsResource.php index 995d5ed..462a6dc 100644 --- a/app/Filament/Forms/Resources/SelectOptionsResource.php +++ b/app/Filament/Forms/Resources/SelectOptionsResource.php @@ -27,7 +27,7 @@ public static function form(Form $form): Form return $form ->schema([ Forms\Components\TextInput::make('name') - ->unique() + ->unique(ignoreRecord: true) ->required(), Forms\Components\TextInput::make('label'), Forms\Components\TextInput::make('value'), From 83c50eff07290f1d41a095996b51a9028966cbaf Mon Sep 17 00:00:00 2001 From: Joh Yoshida Date: Thu, 9 Jan 2025 14:19:18 -0800 Subject: [PATCH 06/12] SelectOptions require a label --- app/Filament/Forms/Resources/SelectOptionsResource.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Filament/Forms/Resources/SelectOptionsResource.php b/app/Filament/Forms/Resources/SelectOptionsResource.php index 462a6dc..d976ce6 100644 --- a/app/Filament/Forms/Resources/SelectOptionsResource.php +++ b/app/Filament/Forms/Resources/SelectOptionsResource.php @@ -29,7 +29,8 @@ public static function form(Form $form): Form Forms\Components\TextInput::make('name') ->unique(ignoreRecord: true) ->required(), - Forms\Components\TextInput::make('label'), + Forms\Components\TextInput::make('label') + ->required(), Forms\Components\TextInput::make('value'), Forms\Components\Textarea::make('description') ->columnSpanFull(), From aefb3bce3a8e9b9a3501d7c7989f09ccf7a0eaba Mon Sep 17 00:00:00 2001 From: Joh Yoshida Date: Thu, 9 Jan 2025 14:39:05 -0800 Subject: [PATCH 07/12] Don't require Label on Field Groups --- app/Filament/Forms/Resources/FieldGroupResource.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Filament/Forms/Resources/FieldGroupResource.php b/app/Filament/Forms/Resources/FieldGroupResource.php index 8f4c179..7f47944 100644 --- a/app/Filament/Forms/Resources/FieldGroupResource.php +++ b/app/Filament/Forms/Resources/FieldGroupResource.php @@ -28,8 +28,7 @@ public static function form(Form $form): Form TextInput::make('name') ->unique(ignoreRecord: true) ->required(), - TextInput::make('label') - ->required(), + TextInput::make('label'), Textarea::make('description') ->columnSpanFull(), Textarea::make('internal_description') From 9f542bc6a2b3402366a050c3bafcfd582a2d559a Mon Sep 17 00:00:00 2001 From: Joh Yoshida Date: Thu, 9 Jan 2025 15:07:20 -0800 Subject: [PATCH 08/12] JSON template handles FormField/SelectOption many-to-many relationship --- app/Helpers/FormTemplateHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Helpers/FormTemplateHelper.php b/app/Helpers/FormTemplateHelper.php index db08456..c13d2c3 100644 --- a/app/Helpers/FormTemplateHelper.php +++ b/app/Helpers/FormTemplateHelper.php @@ -149,7 +149,7 @@ protected static function formatField($fieldInstance, $index) "direction" => "bottom", "size" => "md", "helperText" => "Choose one from the list", - "listItems" => SelectOptions::where('form_field_id', $field->id) + "listItems" => $field->selectOptions() ->get() ->map(function ($selectOption) { return ["text" => $selectOption->label]; @@ -164,7 +164,7 @@ protected static function formatField($fieldInstance, $index) case "radio": return array_merge($base, [ "helperText" => "Choose one option", - "listItems" => SelectOptions::where('form_field_id', $field->id) + "listItems" => $field->selectOptions() ->get() ->map(function ($selectOption) { return ["text" => $selectOption->label]; From d1451cb89f8c40804a8732dfebbe1aabfe291cbf Mon Sep 17 00:00:00 2001 From: JoshuaLarouche <161653341+JoshuaLarouche@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:21:28 -0800 Subject: [PATCH 09/12] added migration, model, and resource files for system messages --- .../Fodig/Resources/SystemMessageResource.php | 114 ++++++++++++++++ .../Pages/CreateSystemMessage.php | 12 ++ .../Pages/EditSystemMessage.php | 20 +++ .../Pages/ListSystemMessages.php | 19 +++ .../Pages/ViewSystemMessage.php | 19 +++ app/Models/ErrorActor.php | 18 +++ app/Models/ErrorDataGroup.php | 18 +++ app/Models/ErrorEntity.php | 18 +++ app/Models/ErrorIntegrationState.php | 18 +++ app/Models/ErrorSource.php | 18 +++ app/Models/SystemMessage.php | 43 ++++++ ...18_233241_create_system_messages_table.php | 80 +++++++++++ database/seeders/ErrorActorSeeder.php | 19 +++ database/seeders/ErrorDataGroupSeeder.php | 18 +++ database/seeders/ErrorEntitySeeder.php | 19 +++ .../seeders/ErrorIntegrationStateSeeder.php | 23 ++++ database/seeders/ErrorSourceSeeder.php | 21 +++ database/seeders/SystemMessageSeeder.php | 22 +++ database/seeders/UsersTableSeeder.php | 125 ++++++++++++++++++ 19 files changed, 644 insertions(+) create mode 100644 app/Filament/Fodig/Resources/SystemMessageResource.php create mode 100644 app/Filament/Fodig/Resources/SystemMessageResource/Pages/CreateSystemMessage.php create mode 100644 app/Filament/Fodig/Resources/SystemMessageResource/Pages/EditSystemMessage.php create mode 100644 app/Filament/Fodig/Resources/SystemMessageResource/Pages/ListSystemMessages.php create mode 100644 app/Filament/Fodig/Resources/SystemMessageResource/Pages/ViewSystemMessage.php create mode 100644 app/Models/ErrorActor.php create mode 100644 app/Models/ErrorDataGroup.php create mode 100644 app/Models/ErrorEntity.php create mode 100644 app/Models/ErrorIntegrationState.php create mode 100644 app/Models/ErrorSource.php create mode 100644 app/Models/SystemMessage.php create mode 100644 database/migrations/2024_12_18_233241_create_system_messages_table.php create mode 100644 database/seeders/ErrorActorSeeder.php create mode 100644 database/seeders/ErrorDataGroupSeeder.php create mode 100644 database/seeders/ErrorEntitySeeder.php create mode 100644 database/seeders/ErrorIntegrationStateSeeder.php create mode 100644 database/seeders/ErrorSourceSeeder.php create mode 100644 database/seeders/SystemMessageSeeder.php create mode 100644 database/seeders/UsersTableSeeder.php diff --git a/app/Filament/Fodig/Resources/SystemMessageResource.php b/app/Filament/Fodig/Resources/SystemMessageResource.php new file mode 100644 index 0000000..69e8114 --- /dev/null +++ b/app/Filament/Fodig/Resources/SystemMessageResource.php @@ -0,0 +1,114 @@ +schema([ + Forms\Components\Textarea::make('error_code') + ->required() + ->columnSpanFull(), + Forms\Components\Textarea::make('error_message') + ->columnSpanFull(), + Forms\Components\Textarea::make('icm_error_solution') + ->columnSpanFull(), + Forms\Components\Textarea::make('explanation') + ->columnSpanFull(), + Forms\Components\Textarea::make('fix') + ->columnSpanFull(), + Forms\Components\TextInput::make('error_entity_id') + ->numeric(), + Forms\Components\TextInput::make('error_data_group_id') + ->numeric(), + Forms\Components\TextInput::make('error_integration_state_id') + ->numeric(), + Forms\Components\TextInput::make('error_actor_id') + ->numeric(), + Forms\Components\TextInput::make('error_source_id') + ->numeric(), + Forms\Components\Toggle::make('service_desk'), + Forms\Components\Toggle::make('limited_data'), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('error_entity_id') + ->numeric() + ->sortable(), + Tables\Columns\TextColumn::make('error_data_group_id') + ->numeric() + ->sortable(), + Tables\Columns\TextColumn::make('error_integration_state_id') + ->numeric() + ->sortable(), + Tables\Columns\TextColumn::make('error_actor_id') + ->numeric() + ->sortable(), + Tables\Columns\TextColumn::make('error_source_id') + ->numeric() + ->sortable(), + Tables\Columns\IconColumn::make('service_desk') + ->boolean(), + Tables\Columns\IconColumn::make('limited_data') + ->boolean(), + Tables\Columns\TextColumn::make('created_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('updated_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + ]) + ->filters([ + // + ]) + ->actions([ + Tables\Actions\ViewAction::make(), + 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\ListSystemMessages::route('/'), + 'create' => Pages\CreateSystemMessage::route('/create'), + 'view' => Pages\ViewSystemMessage::route('/{record}'), + 'edit' => Pages\EditSystemMessage::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Fodig/Resources/SystemMessageResource/Pages/CreateSystemMessage.php b/app/Filament/Fodig/Resources/SystemMessageResource/Pages/CreateSystemMessage.php new file mode 100644 index 0000000..056dc97 --- /dev/null +++ b/app/Filament/Fodig/Resources/SystemMessageResource/Pages/CreateSystemMessage.php @@ -0,0 +1,12 @@ +belongsTo(SystemMessage::class); + } +} diff --git a/app/Models/ErrorDataGroup.php b/app/Models/ErrorDataGroup.php new file mode 100644 index 0000000..266859d --- /dev/null +++ b/app/Models/ErrorDataGroup.php @@ -0,0 +1,18 @@ +belongsTo(SystemMessage::class); + } +} diff --git a/app/Models/ErrorEntity.php b/app/Models/ErrorEntity.php new file mode 100644 index 0000000..89df1f7 --- /dev/null +++ b/app/Models/ErrorEntity.php @@ -0,0 +1,18 @@ +belongsTo(SystemMessage::class); + } +} diff --git a/app/Models/ErrorIntegrationState.php b/app/Models/ErrorIntegrationState.php new file mode 100644 index 0000000..458dbda --- /dev/null +++ b/app/Models/ErrorIntegrationState.php @@ -0,0 +1,18 @@ +belongsTo(SystemMessage::class); + } +} diff --git a/app/Models/ErrorSource.php b/app/Models/ErrorSource.php new file mode 100644 index 0000000..c99482e --- /dev/null +++ b/app/Models/ErrorSource.php @@ -0,0 +1,18 @@ +belongsTo(SystemMessage::class); + } +} diff --git a/app/Models/SystemMessage.php b/app/Models/SystemMessage.php new file mode 100644 index 0000000..429dac7 --- /dev/null +++ b/app/Models/SystemMessage.php @@ -0,0 +1,43 @@ +hasOne(ErrorEntity::class); + } + + public function errorDataGroup(): HasOne + { + return $this->hasOne(ErrorDataGroup::class); + } + + public function errorIntegrationState(): HasOne + { + return $this->hasOne(ErrorIntegrationState::class); + } + + public function errorActor(): HasOne + { + return $this->hasOne(ErrorActor::class); + } + + public function errorSource(): HasOne + { + return $this->hasOne(ErrorSource::class); + } +} diff --git a/database/migrations/2024_12_18_233241_create_system_messages_table.php b/database/migrations/2024_12_18_233241_create_system_messages_table.php new file mode 100644 index 0000000..acd5e5f --- /dev/null +++ b/database/migrations/2024_12_18_233241_create_system_messages_table.php @@ -0,0 +1,80 @@ +id(); + $table->text("name"); + $table->timestamps(); + }); + + // Pivot tables + Schema::create('error_data_groups', function (Blueprint $table) { + $table->id(); + $table->text("name"); + $table->timestamps(); + }); + + // Pivot tables + Schema::create('error_integration_states', function (Blueprint $table) { + $table->id(); + $table->text("name"); + $table->timestamps(); + }); + + // Pivot tables + Schema::create('error_actors', function (Blueprint $table) { + $table->id(); + $table->text("name"); + $table->timestamps(); + }); + + // Pivot tables + Schema::create('error_sources', function (Blueprint $table) { + $table->id(); + $table->text("name"); + $table->timestamps(); + }); + + Schema::create('system_messages', function (Blueprint $table) { + $table->id(); + $table->text("error_code"); + $table->text("error_message")->nullable(); + $table->text("icm_error_solution")->nullable(); + $table->text("explanation")->nullable(); + $table->text("fix")->nullable(); + $table->foreignId('error_entity_id')->nullable()->constrained()->onDelete('cascade'); + $table->foreignId('error_data_group_id')->nullable()->constrained()->onDelete('cascade'); + $table->foreignId('error_integration_state_id')->nullable()->constrained()->onDelete('cascade'); + $table->foreignId('error_actor_id')->nullable()->constrained()->onDelete('cascade'); + $table->foreignId('error_source_id')->nullable()->constrained()->onDelete('cascade'); + $table->boolean("service_desk")->nullable(); + $table->boolean("limited_data")->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('system_messages'); + Schema::dropIfExists('error_entities'); + Schema::dropIfExists('error_data_groups'); + Schema::dropIfExists('error_integration_states'); + Schema::dropIfExists('error_actors'); + Schema::dropIfExists('error_sources'); + } +}; diff --git a/database/seeders/ErrorActorSeeder.php b/database/seeders/ErrorActorSeeder.php new file mode 100644 index 0000000..e26add0 --- /dev/null +++ b/database/seeders/ErrorActorSeeder.php @@ -0,0 +1,19 @@ + 'User']); + ErrorActor::create(['name' => 'System']); + } +} diff --git a/database/seeders/ErrorDataGroupSeeder.php b/database/seeders/ErrorDataGroupSeeder.php new file mode 100644 index 0000000..b3a09bd --- /dev/null +++ b/database/seeders/ErrorDataGroupSeeder.php @@ -0,0 +1,18 @@ + 'Admission'], ['name' => 'BusPassAttachments'], ['name' => 'BusPassRefunds'], ['name' => 'BusPassSticker'], ['name' => 'BusPassTransLink'], ['name' => 'Case Information'], ['name' => 'CaseAddress'], ['name' => 'CaseBenefitPlan'], ['name' => 'CaseBenefitRecalc'], ['name' => 'CaseClientBankInformation'], ['name' => 'CaseContactEligibility'], ['name' => 'CaseExpenses'], ['name' => 'CaselAInformation'], ['name' => 'CaseOrderRecalc'], ['name' => 'CasePlan'], ['name' => 'CasePositiveReport'], ['name' => 'CaseServiceOrder'], ['name' => 'CaseSignalCheque'], ['name' => 'CFMS Case'], ['name' => 'Contact Attachment'], ['name' => 'ContactAboriginal'], ['name' => 'ContactCaseAssets'], ['name' => 'ContactCaselncome'], ['name' => 'ContactCPA'], ['name' => 'ContactImmigration'], ['name' => 'ContactMerge'], ['name' => 'ContactSanctionAdd'], ['name' => 'ContactSanctionResolve'], ['name' => 'ContactTombstone'], ['name' => 'ExtendedHealthCoverage'], ['name' => 'MSPCoverage'], ['name' => 'RequestToCRA'], ['name' => 'SeniorSupplementPayments'],]); + } +} diff --git a/database/seeders/ErrorEntitySeeder.php b/database/seeders/ErrorEntitySeeder.php new file mode 100644 index 0000000..9cb7d5a --- /dev/null +++ b/database/seeders/ErrorEntitySeeder.php @@ -0,0 +1,19 @@ + 'Case']); + ErrorEntity::create(['name' => 'Contact']); + } +} diff --git a/database/seeders/ErrorIntegrationStateSeeder.php b/database/seeders/ErrorIntegrationStateSeeder.php new file mode 100644 index 0000000..0dfa18a --- /dev/null +++ b/database/seeders/ErrorIntegrationStateSeeder.php @@ -0,0 +1,23 @@ + 'Error']); + ErrorIntegrationState::create(['name' => 'Not Integrated']); + ErrorIntegrationState::create(['name' => 'Pending']); + ErrorIntegrationState::create(['name' => 'Processing']); + ErrorIntegrationState::create(['name' => 'Queued']); + ErrorIntegrationState::create(['name' => 'Synced']); + } +} diff --git a/database/seeders/ErrorSourceSeeder.php b/database/seeders/ErrorSourceSeeder.php new file mode 100644 index 0000000..af9868e --- /dev/null +++ b/database/seeders/ErrorSourceSeeder.php @@ -0,0 +1,21 @@ + 'ICM']); + ErrorSource::create(['name' => 'CFMS']); + ErrorSource::create(['name' => 'PBC']); + ErrorSource::create(['name' => 'Successor System']); + } +} diff --git a/database/seeders/SystemMessageSeeder.php b/database/seeders/SystemMessageSeeder.php new file mode 100644 index 0000000..e3c79af --- /dev/null +++ b/database/seeders/SystemMessageSeeder.php @@ -0,0 +1,22 @@ +call([ + ErrorEntitySeeder::class, + ErrorDataGroupSeeder::class, + ErrorIntegrationStateSeeder::class, + ErrorActorSeeder::class, + ErrorSourceSeeder::class, + ]); + } +} diff --git a/database/seeders/UsersTableSeeder.php b/database/seeders/UsersTableSeeder.php new file mode 100644 index 0000000..a39263f --- /dev/null +++ b/database/seeders/UsersTableSeeder.php @@ -0,0 +1,125 @@ +delete(); + + \DB::table('users')->insert(array ( + 0 => + array ( + 'id' => 1, + 'name' => 'Jeremy', + 'email' => 'jeremy.vernon@gov.bc.ca', + 'email_verified_at' => '2024-12-18 23:08:01', + 'password' => '$2y$12$0QQN/Xxb1XIvnkCyLHfife1ch2fU11Tw5k40z.ojSQ9ryvS1nEbeG', + 'remember_token' => NULL, + 'created_at' => '2024-12-18 23:08:01', + 'updated_at' => '2024-12-18 23:08:01', + ), + 1 => + array ( + 'id' => 2, + 'name' => 'Bojan', + 'email' => 'bojan.zimonja@gov.bc.ca', + 'email_verified_at' => '2024-12-18 23:08:01', + 'password' => '$2y$12$ylIh/O1LxLA6q3YPA7Wxzu.hZz.2s6jUxj5my9MjJFdyu29n3/oBq', + 'remember_token' => NULL, + 'created_at' => '2024-12-18 23:08:01', + 'updated_at' => '2024-12-18 23:08:01', + ), + 2 => + array ( + 'id' => 3, + 'name' => 'Will', + 'email' => 'will.kiiskila@gov.bc.ca', + 'email_verified_at' => '2024-12-18 23:08:01', + 'password' => '$2y$12$l7HUDQ53WX9oZtkIkhSbfe9L7yNkovz/ACY178jZnTFQberqQ3/Ci', + 'remember_token' => NULL, + 'created_at' => '2024-12-18 23:08:02', + 'updated_at' => '2024-12-18 23:08:02', + ), + 3 => + array ( + 'id' => 4, + 'name' => 'Tim', + 'email' => 'tim.vanderwekken@gov.bc.ca', + 'email_verified_at' => '2024-12-18 23:08:02', + 'password' => '$2y$12$VingXyVkNSU8ee/cdCr67um/snKtdlu6H49lA2zeGcSB23bb5snRS', + 'remember_token' => NULL, + 'created_at' => '2024-12-18 23:08:02', + 'updated_at' => '2024-12-18 23:08:02', + ), + 4 => + array ( + 'id' => 5, + 'name' => 'Saranya', + 'email' => 'saranya.viswam@gov.bc.ca', + 'email_verified_at' => '2024-12-18 23:08:02', + 'password' => '$2y$12$7lQGWb56UocM7/ALg9bRGO5rqdhlKiF05k7rTNjnSNMUWrpg7gnkC', + 'remember_token' => NULL, + 'created_at' => '2024-12-18 23:08:02', + 'updated_at' => '2024-12-18 23:08:02', + ), + 5 => + array ( + 'id' => 6, + 'name' => 'Bryson', + 'email' => 'bryson.best@gov.bc.ca', + 'email_verified_at' => '2024-12-18 23:08:02', + 'password' => '$2y$12$3oxpvYJJTxTuSCj/1CA.F.Wz0sxFR7qAslSiY017zmbHdzkKef2/q', + 'remember_token' => NULL, + 'created_at' => '2024-12-18 23:08:02', + 'updated_at' => '2024-12-18 23:08:02', + ), + 6 => + array ( + 'id' => 7, + 'name' => 'David', + 'email' => 'david.okulski@gov.bc.ca', + 'email_verified_at' => '2024-12-18 23:08:02', + 'password' => '$2y$12$zweAgtkOmNvtJ2c0MocpGO0Wx7jGgoRT7RjBFfwTmGnqNvMajJNgO', + 'remember_token' => NULL, + 'created_at' => '2024-12-18 23:08:03', + 'updated_at' => '2024-12-18 23:08:03', + ), + 7 => + array ( + 'id' => 8, + 'name' => 'Joh', + 'email' => 'johtaro.yoshida@gov.bc.ca', + 'email_verified_at' => '2024-12-18 23:08:03', + 'password' => '$2y$12$OUQEt2Y9uzvWRdkpzMypz.O9CgLEAdTc5P2wRE6lOTruWkXfBeab.', + 'remember_token' => NULL, + 'created_at' => '2024-12-18 23:08:03', + 'updated_at' => '2024-12-18 23:08:03', + ), + 8 => + array ( + 'id' => 9, + 'name' => 'Josh', + 'email' => 'joshua.larouche@gov.bc.ca', + 'email_verified_at' => '2024-12-18 23:08:03', + 'password' => '$2y$12$SOoK6YjOU0WQl7QpH2mK2euwAUq1s7QFjuHsmQZyukdSKsyHz35li', + 'remember_token' => 'RytjoGJ73UNT5GMZwKw8C2BkrviPpd5oucwxwYl1BdL34Rs352km6QOLOCXN', + 'created_at' => '2024-12-18 23:08:03', + 'updated_at' => '2024-12-18 23:08:03', + ), + )); + + + } +} \ No newline at end of file From b0f41cf86ebb663371126af31f046a6b22664563 Mon Sep 17 00:00:00 2001 From: Will Kiiskila Date: Thu, 9 Jan 2025 20:41:51 -0800 Subject: [PATCH 10/12] fixes to system message setup --- .../Fodig/Resources/SystemMessageResource.php | 102 +++++++++++------- app/Models/ErrorActor.php | 6 +- app/Models/ErrorDataGroup.php | 6 +- app/Models/ErrorEntity.php | 6 +- app/Models/ErrorIntegrationState.php | 6 +- app/Models/ErrorSource.php | 6 +- app/Models/SystemMessage.php | 24 +++-- ...18_233241_create_system_messages_table.php | 2 +- database/seeders/DatabaseSeeder.php | 1 + 9 files changed, 94 insertions(+), 65 deletions(-) diff --git a/app/Filament/Fodig/Resources/SystemMessageResource.php b/app/Filament/Fodig/Resources/SystemMessageResource.php index 69e8114..a6c21f5 100644 --- a/app/Filament/Fodig/Resources/SystemMessageResource.php +++ b/app/Filament/Fodig/Resources/SystemMessageResource.php @@ -6,6 +6,7 @@ use App\Filament\Fodig\Resources\SystemMessageResource\RelationManagers; use App\Models\SystemMessage; use Filament\Forms; +use Filament\Forms\Components\Select; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; @@ -19,6 +20,8 @@ class SystemMessageResource extends Resource protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; + protected static ?string $navigationGroup = 'System Messages'; + public static function form(Form $form): Form { return $form @@ -27,23 +30,25 @@ public static function form(Form $form): Form ->required() ->columnSpanFull(), Forms\Components\Textarea::make('error_message') + ->required() ->columnSpanFull(), Forms\Components\Textarea::make('icm_error_solution') + ->label('ICM error solution') ->columnSpanFull(), Forms\Components\Textarea::make('explanation') ->columnSpanFull(), Forms\Components\Textarea::make('fix') ->columnSpanFull(), - Forms\Components\TextInput::make('error_entity_id') - ->numeric(), - Forms\Components\TextInput::make('error_data_group_id') - ->numeric(), - Forms\Components\TextInput::make('error_integration_state_id') - ->numeric(), - Forms\Components\TextInput::make('error_actor_id') - ->numeric(), - Forms\Components\TextInput::make('error_source_id') - ->numeric(), + Select::make('error_entity_id') + ->relationship('errorEntity', 'name'), + Select::make('error_data_group_id') + ->relationship('errorDataGroup', 'name'), + Select::make('error_integration_state_id') + ->relationship('errorIntegrationState', 'name'), + Select::make('error_actor_id') + ->relationship('errorActor', 'name'), + Select::make('error_source_id') + ->relationship('errorSource', 'name'), Forms\Components\Toggle::make('service_desk'), Forms\Components\Toggle::make('limited_data'), ]); @@ -53,46 +58,67 @@ public static function table(Table $table): Table { return $table ->columns([ - Tables\Columns\TextColumn::make('error_entity_id') - ->numeric() - ->sortable(), - Tables\Columns\TextColumn::make('error_data_group_id') - ->numeric() - ->sortable(), - Tables\Columns\TextColumn::make('error_integration_state_id') - ->numeric() - ->sortable(), - Tables\Columns\TextColumn::make('error_actor_id') - ->numeric() - ->sortable(), - Tables\Columns\TextColumn::make('error_source_id') - ->numeric() - ->sortable(), + Tables\Columns\TextColumn::make('error_code') + ->searchable(), + Tables\Columns\TextColumn::make('errorEntity.name') + ->label('Error Entity') + ->sortable() + ->searchable(), + Tables\Columns\TextColumn::make('errorDataGroup.name') + ->label('Error Data Group') + ->sortable() + ->searchable(), + Tables\Columns\TextColumn::make('errorIntegrationState.name') + ->label('Error Integration State') + ->sortable() + ->searchable(), + Tables\Columns\TextColumn::make('errorActor.name') + ->label('Error Actor') + ->sortable() + ->searchable(), + Tables\Columns\TextColumn::make('errorSource.name') + ->label('Error Source') + ->sortable() + ->searchable(), Tables\Columns\IconColumn::make('service_desk') ->boolean(), Tables\Columns\IconColumn::make('limited_data') ->boolean(), - Tables\Columns\TextColumn::make('created_at') - ->dateTime() - ->sortable() - ->toggleable(isToggledHiddenByDefault: true), - Tables\Columns\TextColumn::make('updated_at') - ->dateTime() - ->sortable() - ->toggleable(isToggledHiddenByDefault: true), ]) ->filters([ - // + Tables\Filters\SelectFilter::make('error_entity_id') + ->label('Error Entity') + ->relationship('errorEntity', 'name'), + Tables\Filters\SelectFilter::make('error_data_group_id') + ->label('Error Data Group') + ->relationship('errorDataGroup', 'name'), + Tables\Filters\SelectFilter::make('error_integration_state_id') + ->label('Error Integration State') + ->relationship('errorIntegrationState', 'name'), + Tables\Filters\SelectFilter::make('error_actor_id') + ->label('Error Actor') + ->relationship('errorActor', 'name'), + Tables\Filters\SelectFilter::make('error_source_id') + ->label('Error Source') + ->relationship('errorSource', 'name'), + Tables\Filters\TernaryFilter::make('service_desk') + ->label('Service Desk'), + Tables\Filters\TernaryFilter::make('limited_data') + ->label('Limited Data'), ]) ->actions([ Tables\Actions\ViewAction::make(), Tables\Actions\EditAction::make(), ]) ->bulkActions([ - Tables\Actions\BulkActionGroup::make([ - Tables\Actions\DeleteBulkAction::make(), - ]), - ]); + // + ]) + ->paginated([ + 10, + 25, + 50, + 100, + ]);; } public static function getRelations(): array diff --git a/app/Models/ErrorActor.php b/app/Models/ErrorActor.php index f2b776b..3c059af 100644 --- a/app/Models/ErrorActor.php +++ b/app/Models/ErrorActor.php @@ -3,7 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasOne; class ErrorActor extends Model { @@ -11,8 +11,8 @@ class ErrorActor extends Model 'name' ]; - public function formField(): BelongsTo + public function systemMessage(): HasOne { - return $this->belongsTo(SystemMessage::class); + return $this->hasOne(SystemMessage::class, 'error_actor_id'); } } diff --git a/app/Models/ErrorDataGroup.php b/app/Models/ErrorDataGroup.php index 266859d..8e68cd4 100644 --- a/app/Models/ErrorDataGroup.php +++ b/app/Models/ErrorDataGroup.php @@ -3,7 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasOne; class ErrorDataGroup extends Model { @@ -11,8 +11,8 @@ class ErrorDataGroup extends Model 'name' ]; - public function formField(): BelongsTo + public function systemMessage(): HasOne { - return $this->belongsTo(SystemMessage::class); + return $this->hasOne(SystemMessage::class, 'error_actor_id'); } } diff --git a/app/Models/ErrorEntity.php b/app/Models/ErrorEntity.php index 89df1f7..ef320d1 100644 --- a/app/Models/ErrorEntity.php +++ b/app/Models/ErrorEntity.php @@ -3,7 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasOne; class ErrorEntity extends Model { @@ -11,8 +11,8 @@ class ErrorEntity extends Model 'name' ]; - public function formField(): BelongsTo + public function systemMessage(): HasOne { - return $this->belongsTo(SystemMessage::class); + return $this->hasOne(SystemMessage::class, 'error_actor_id'); } } diff --git a/app/Models/ErrorIntegrationState.php b/app/Models/ErrorIntegrationState.php index 458dbda..8828bd8 100644 --- a/app/Models/ErrorIntegrationState.php +++ b/app/Models/ErrorIntegrationState.php @@ -3,7 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasOne; class ErrorIntegrationState extends Model { @@ -11,8 +11,8 @@ class ErrorIntegrationState extends Model 'name' ]; - public function formField(): BelongsTo + public function systemMessage(): HasOne { - return $this->belongsTo(SystemMessage::class); + return $this->hasOne(SystemMessage::class, 'error_actor_id'); } } diff --git a/app/Models/ErrorSource.php b/app/Models/ErrorSource.php index c99482e..a1116c7 100644 --- a/app/Models/ErrorSource.php +++ b/app/Models/ErrorSource.php @@ -3,7 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasOne; class ErrorSource extends Model { @@ -11,8 +11,8 @@ class ErrorSource extends Model 'name' ]; - public function formField(): BelongsTo + public function systemMessage(): HasOne { - return $this->belongsTo(SystemMessage::class); + return $this->hasOne(SystemMessage::class, 'error_actor_id'); } } diff --git a/app/Models/SystemMessage.php b/app/Models/SystemMessage.php index 429dac7..3d3810d 100644 --- a/app/Models/SystemMessage.php +++ b/app/Models/SystemMessage.php @@ -4,6 +4,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasOne; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class SystemMessage extends Model { @@ -11,33 +12,34 @@ class SystemMessage extends Model 'error_code', 'error_message', 'icm_error_solution', - 'explanation' . 'fix', + 'explanation', + 'fix', 'service_desk', 'limited_data', ]; - public function errorEntity(): HasOne + public function errorEntity(): BelongsTo { - return $this->hasOne(ErrorEntity::class); + return $this->belongsTo(ErrorEntity::class, 'error_entity_id'); } - public function errorDataGroup(): HasOne + public function errorDataGroup(): BelongsTo { - return $this->hasOne(ErrorDataGroup::class); + return $this->belongsTo(ErrorDataGroup::class, 'error_data_group_id'); } - public function errorIntegrationState(): HasOne + public function errorIntegrationState(): BelongsTo { - return $this->hasOne(ErrorIntegrationState::class); + return $this->belongsTo(ErrorIntegrationState::class, 'error_integration_state_id'); } - public function errorActor(): HasOne + public function errorActor(): BelongsTo { - return $this->hasOne(ErrorActor::class); + return $this->belongsTo(ErrorActor::class, 'error_actor_id'); } - public function errorSource(): HasOne + public function errorSource(): BelongsTo { - return $this->hasOne(ErrorSource::class); + return $this->belongsTo(ErrorSource::class, 'error_source_id'); } } diff --git a/database/migrations/2024_12_18_233241_create_system_messages_table.php b/database/migrations/2024_12_18_233241_create_system_messages_table.php index acd5e5f..dd1f5ed 100644 --- a/database/migrations/2024_12_18_233241_create_system_messages_table.php +++ b/database/migrations/2024_12_18_233241_create_system_messages_table.php @@ -50,7 +50,7 @@ public function up(): void Schema::create('system_messages', function (Blueprint $table) { $table->id(); $table->text("error_code"); - $table->text("error_message")->nullable(); + $table->text("error_message"); $table->text("icm_error_solution")->nullable(); $table->text("explanation")->nullable(); $table->text("fix")->nullable(); diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 2e71b03..00e66aa 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -33,6 +33,7 @@ public function run(): void FormTagSeeder::class, FormSeeder::class, FormDataSourceSeeder::class, + SystemMessageSeeder::class, ]); } } From 06f0584f2dc987971bb6c1041925b7b736bb7a65 Mon Sep 17 00:00:00 2001 From: Will Kiiskila Date: Thu, 9 Jan 2025 20:49:42 -0800 Subject: [PATCH 11/12] fix the select options seeder to many to many --- database/seeders/SelectOptionsSeeder.php | 28 +++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/database/seeders/SelectOptionsSeeder.php b/database/seeders/SelectOptionsSeeder.php index 72f9fc0..705ea84 100644 --- a/database/seeders/SelectOptionsSeeder.php +++ b/database/seeders/SelectOptionsSeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; use App\Models\FormField; use App\Models\SelectOptions; @@ -14,22 +13,21 @@ class SelectOptionsSeeder extends Seeder */ public function run(): void { - $eyeColorFormFieldType = FormField::where('name', 'eye_colour')->first()->id; + $eyeColorFormField = FormField::where('name', 'eye_colour')->first(); - $selectOptions = [ - ['name' => 'eye_colour_brown', 'label' => 'Brown', 'value' =>'1','form_field_id' => $eyeColorFormFieldType], - ['name' => 'eye_colour_black', 'label' => 'Black', 'value' =>'2','form_field_id' => $eyeColorFormFieldType], - ['name' => 'eye_colour_blue', 'label' => 'Blue', 'value' =>'3','form_field_id' => $eyeColorFormFieldType], - ['name' => 'eye_colour_green', 'label' => 'Green', 'value' =>'4','form_field_id' => $eyeColorFormFieldType], - - - ]; + if ($eyeColorFormField) { + $selectOptions = [ + ['name' => 'eye_colour_brown', 'label' => 'Brown', 'value' => '1'], + ['name' => 'eye_colour_black', 'label' => 'Black', 'value' => '2'], + ['name' => 'eye_colour_blue', 'label' => 'Blue', 'value' => '3'], + ['name' => 'eye_colour_green', 'label' => 'Green', 'value' => '4'], + ]; - foreach ($selectOptions as $selectOption) { - SelectOptions::create($selectOption); - } + foreach ($selectOptions as $optionData) { + $selectOption = SelectOptions::create($optionData); + $eyeColorFormField->selectOptions()->attach($selectOption->id); + } + } } - - } From 5ee4d1b8a664b698b109735e8da451bd6e261810 Mon Sep 17 00:00:00 2001 From: Will Kiiskila Date: Thu, 9 Jan 2025 21:25:26 -0800 Subject: [PATCH 12/12] setup api endpoints for system messages --- .../Controllers/SystemMessageController.php | 36 +++++++++++++++++++ app/Http/Resources/SystemMessageResource.php | 29 +++++++++++++++ .../SystemMessageSummaryResource.php | 19 ++++++++++ routes/api.php | 3 ++ routes/system_message_routes.php | 13 +++++++ 5 files changed, 100 insertions(+) create mode 100644 app/Http/Controllers/SystemMessageController.php create mode 100644 app/Http/Resources/SystemMessageResource.php create mode 100644 app/Http/Resources/SystemMessageSummaryResource.php create mode 100644 routes/system_message_routes.php diff --git a/app/Http/Controllers/SystemMessageController.php b/app/Http/Controllers/SystemMessageController.php new file mode 100644 index 0000000..1a74614 --- /dev/null +++ b/app/Http/Controllers/SystemMessageController.php @@ -0,0 +1,36 @@ +has('error_code')) { + $query->where('error_code', $request->input('error_code')); + } + + $systemMessages = $query->select('id', 'error_code', 'error_message', 'error_data_group_id')->get(); + + return SystemMessageSummaryResource::collection($systemMessages); + } + + public function show($id) + { + $systemMessage = SystemMessage::findOrFail($id); + return new SystemMessageResource($systemMessage); + } + + public function getLastUpdated() + { + $lastUpdated = SystemMessage::max('updated_at'); + return response()->json(['last_updated' => $lastUpdated]); + } +} diff --git a/app/Http/Resources/SystemMessageResource.php b/app/Http/Resources/SystemMessageResource.php new file mode 100644 index 0000000..cc02ea8 --- /dev/null +++ b/app/Http/Resources/SystemMessageResource.php @@ -0,0 +1,29 @@ + $this->id, + 'error_code' => $this->error_code, + 'error_message' => $this->error_message, + 'icm_error_solution' => $this->icm_error_solution, + 'explanation' => $this->explanation, + 'fix' => $this->fix, + 'service_desk' => $this->service_desk, + 'limited_data' => $this->limited_data, + 'last_updated' => $this->updated_at, + 'error_entity' => $this->errorEntity->name ?? null, + 'error_data_group' => $this->errorDataGroup->name ?? null, + 'error_integration_state' => $this->errorIntegrationState->name ?? null, + 'error_actor' => $this->errorActor->name ?? null, + 'error_source' => $this->errorSource->name ?? null, + ]; + } +} diff --git a/app/Http/Resources/SystemMessageSummaryResource.php b/app/Http/Resources/SystemMessageSummaryResource.php new file mode 100644 index 0000000..524bbee --- /dev/null +++ b/app/Http/Resources/SystemMessageSummaryResource.php @@ -0,0 +1,19 @@ + $this->id, + 'error_code' => $this->error_code, + 'error_message' => $this->error_message, + 'data_group' => $this->errorDataGroup->name ?? null, + ]; + } +} diff --git a/routes/api.php b/routes/api.php index cbade83..7c7c63b 100644 --- a/routes/api.php +++ b/routes/api.php @@ -9,3 +9,6 @@ // BRE routes require __DIR__ . '/bre_routes.php'; + +// System Message routes +require __DIR__ . '/system_message_routes.php'; diff --git a/routes/system_message_routes.php b/routes/system_message_routes.php new file mode 100644 index 0000000..2b8f33d --- /dev/null +++ b/routes/system_message_routes.php @@ -0,0 +1,13 @@ +middleware(['auth:sanctum', 'ability:admin,fodig']); + +Route::get('/system-messages', [SystemMessageController::class, 'index']) + ->middleware(['auth:sanctum', 'ability:admin,fodig']); + +Route::get('/system-messages/{id}', [SystemMessageController::class, 'show']) + ->middleware(['auth:sanctum', 'ability:admin,fodig']);