From ef23841f9f3592a2346ad46e9a3fb8093e13f583 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Tue, 18 Jul 2023 14:49:12 -0400 Subject: [PATCH 01/20] Fix test namespace Signed-off-by: Kevin Ullyott --- .../Actions/RolesAndPermissions/CreatePermissionsTest.php | 2 +- tests/Feature/Actions/RolesAndPermissions/CreateRolesTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Feature/Actions/RolesAndPermissions/CreatePermissionsTest.php b/tests/Feature/Actions/RolesAndPermissions/CreatePermissionsTest.php index efb1f86225..e1f991796a 100644 --- a/tests/Feature/Actions/RolesAndPermissions/CreatePermissionsTest.php +++ b/tests/Feature/Actions/RolesAndPermissions/CreatePermissionsTest.php @@ -1,6 +1,6 @@ Date: Tue, 18 Jul 2023 15:13:40 -0400 Subject: [PATCH 02/20] Comment out broken routes Signed-off-by: Kevin Ullyott --- resources/views/components/sidebar.blade.php | 48 ++++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/resources/views/components/sidebar.blade.php b/resources/views/components/sidebar.blade.php index 653d6c929d..fed539a81c 100644 --- a/resources/views/components/sidebar.blade.php +++ b/resources/views/components/sidebar.blade.php @@ -622,30 +622,30 @@ class="{{ request()->is('admin/users*') ? 'sidebar-nav-active' : 'sidebar-nav' } @endcan - @can('permission_access') -
  • - - - - {{ trans('cruds.permission.title') }} - -
  • - @endcan - @can('role_access') -
  • - - - - {{ trans('cruds.role.title') }} - -
  • - @endcan +{{-- @can('permission_access')--}} +{{--
  • --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- {{ trans('cruds.permission.title') }}--}} +{{-- --}} +{{--
  • --}} +{{-- @endcan--}} +{{-- @can('role_access')--}} +{{--
  • --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- {{ trans('cruds.role.title') }}--}} +{{-- --}} +{{--
  • --}} +{{-- @endcan--}} @can('user_alert_access')
  • Date: Thu, 20 Jul 2023 15:01:14 -0500 Subject: [PATCH 03/20] Work on Cases Signed-off-by: Kevin Ullyott --- app/Filament/Resources/CaseItemResource.php | 66 +++++++++++++++++++ .../CaseItemResource/Pages/CreateCaseItem.php | 12 ++++ .../CaseItemResource/Pages/EditCaseItem.php | 19 ++++++ .../CaseItemResource/Pages/ListCaseItems.php | 19 ++++++ .../CaseItemResource/Pages/ViewCaseItem.php | 17 +++++ database/seeders/CaseItemSeeder.php | 16 +++++ database/seeders/DatabaseSeeder.php | 1 + 7 files changed, 150 insertions(+) create mode 100644 app/Filament/Resources/CaseItemResource.php create mode 100644 app/Filament/Resources/CaseItemResource/Pages/CreateCaseItem.php create mode 100644 app/Filament/Resources/CaseItemResource/Pages/EditCaseItem.php create mode 100644 app/Filament/Resources/CaseItemResource/Pages/ListCaseItems.php create mode 100644 app/Filament/Resources/CaseItemResource/Pages/ViewCaseItem.php create mode 100644 database/seeders/CaseItemSeeder.php diff --git a/app/Filament/Resources/CaseItemResource.php b/app/Filament/Resources/CaseItemResource.php new file mode 100644 index 0000000000..a3ec337532 --- /dev/null +++ b/app/Filament/Resources/CaseItemResource.php @@ -0,0 +1,66 @@ +schema([ + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('casenumber') + ->label('Case #') + ->searchable(), + Tables\Columns\TextColumn::make('status_id') + ->label('Status'), + ]) + ->filters([ + ]) + ->actions([ + Tables\Actions\ViewAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + ]), + ]); + } + + public static function getRelations(): array + { + return [ + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListCaseItems::route('/'), + 'create' => Pages\CreateCaseItem::route('/create'), + 'view' => Pages\ViewCaseItem::route('/{record}'), + 'edit' => Pages\EditCaseItem::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Resources/CaseItemResource/Pages/CreateCaseItem.php b/app/Filament/Resources/CaseItemResource/Pages/CreateCaseItem.php new file mode 100644 index 0000000000..084831b627 --- /dev/null +++ b/app/Filament/Resources/CaseItemResource/Pages/CreateCaseItem.php @@ -0,0 +1,12 @@ +count(30) + ->create(); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 7e08fe3480..abaaf66745 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -14,6 +14,7 @@ public function run(): void $this->call([ UsersTableSeeder::class, + CaseItemSeeder::class, StudentSeeder::class, ]); } From c433816d130d5c36cb781c8c598e38ac510da4c4 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Sun, 23 Jul 2023 12:39:33 -0400 Subject: [PATCH 04/20] Add documentation for local redshift db setup --- docs/local-setup.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/local-setup.md b/docs/local-setup.md index 5e35eaf0cf..5b1d241b21 100644 --- a/docs/local-setup.md +++ b/docs/local-setup.md @@ -65,6 +65,7 @@ Finally, we will set up the application by running the following commands: ```bash sail artisan key:generate sail artisan migrate +sail artisan migrate --database=sis --path=database/migrations/sis sail artisan db:seed sail npm install sail npm run dev From 2b19b71b860c309fde9805ce232193bedb06af0b Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Sun, 23 Jul 2023 12:41:58 -0400 Subject: [PATCH 05/20] Replace bcrypt call with Hash Signed-off-by: Kevin Ullyott --- database/seeders/UsersTableSeeder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/seeders/UsersTableSeeder.php b/database/seeders/UsersTableSeeder.php index 089db4ea6f..a4767f8923 100644 --- a/database/seeders/UsersTableSeeder.php +++ b/database/seeders/UsersTableSeeder.php @@ -15,7 +15,7 @@ public function run(): void $superAdmin = User::factory()->create([ 'name' => 'Super Admin', 'email' => 'superadmin@assist.com', - 'password' => bcrypt('password'), + 'password' => Hash::make('password'), ]); $superAdminRoles = Role::superAdmin()->get(); From ed8a5b9cb0ef444a6cb5a92a4d03ef6a921c418d Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Sun, 23 Jul 2023 13:06:30 -0400 Subject: [PATCH 06/20] Start work on CaseItemPriority Signed-off-by: Kevin Ullyott --- app/Models/CaseItemPriority.php | 7 ++++--- .../factories/CaseItemPriorityFactory.php | 20 ++++++++++++++++++ ...0011_create_case_item_priorities_table.php | 5 +++-- database/seeders/CaseItemPrioritySeeder.php | 21 +++++++++++++++++++ database/seeders/DatabaseSeeder.php | 1 + 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 database/factories/CaseItemPriorityFactory.php create mode 100644 database/seeders/CaseItemPrioritySeeder.php diff --git a/app/Models/CaseItemPriority.php b/app/Models/CaseItemPriority.php index 59a665dac4..0a1d38dbe0 100644 --- a/app/Models/CaseItemPriority.php +++ b/app/Models/CaseItemPriority.php @@ -16,17 +16,18 @@ class CaseItemPriority extends BaseModel use SoftDeletes; protected $fillable = [ - 'priority', + 'name', + 'order', ]; public $orderable = [ 'id', - 'priority', + 'order', ]; public $filterable = [ 'id', - 'priority', + 'order', ]; protected $dates = [ diff --git a/database/factories/CaseItemPriorityFactory.php b/database/factories/CaseItemPriorityFactory.php new file mode 100644 index 0000000000..287151ca29 --- /dev/null +++ b/database/factories/CaseItemPriorityFactory.php @@ -0,0 +1,20 @@ + + */ +class CaseItemPriorityFactory extends Factory +{ + public function definition(): array + { + return [ + 'name' => $this->faker->name, + 'order' => $this->faker->randomNumber(1), + ]; + } +} diff --git a/database/migrations/2023_03_06_000011_create_case_item_priorities_table.php b/database/migrations/2023_03_06_000011_create_case_item_priorities_table.php index e51f94a0d4..661e0c604b 100644 --- a/database/migrations/2023_03_06_000011_create_case_item_priorities_table.php +++ b/database/migrations/2023_03_06_000011_create_case_item_priorities_table.php @@ -6,11 +6,12 @@ class CreateCaseItemPrioritiesTable extends Migration { - public function up() + public function up(): void { Schema::create('case_item_priorities', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('priority'); + $table->string('name'); + $table->integer('order'); $table->timestamps(); $table->softDeletes(); }); diff --git a/database/seeders/CaseItemPrioritySeeder.php b/database/seeders/CaseItemPrioritySeeder.php new file mode 100644 index 0000000000..d03989cfa0 --- /dev/null +++ b/database/seeders/CaseItemPrioritySeeder.php @@ -0,0 +1,21 @@ +count(3) + ->sequence( + ['name' => 'High', 'order' => 1], + ['name' => 'Medium', 'order' => 2], + ['name' => 'Low', 'order' => 3], + ) + ->create(); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index abaaf66745..de582d8d4d 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -14,6 +14,7 @@ public function run(): void $this->call([ UsersTableSeeder::class, + CaseItemPrioritySeeder::class, CaseItemSeeder::class, StudentSeeder::class, ]); From 405e43b1dc35f117df52c851baee99277b7bb62e Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Sun, 23 Jul 2023 16:23:48 -0400 Subject: [PATCH 07/20] Improve CaseItemPriority and its relation to CaseItem Signed-off-by: Kevin Ullyott --- app/Models/CaseItem.php | 11 ++++--- app/Models/CaseItemPriority.php | 10 +++---- database/factories/CaseItemFactory.php | 20 +++++++++++++ .../factories/CaseItemPriorityFactory.php | 30 +++++++++++++++++++ 4 files changed, 60 insertions(+), 11 deletions(-) diff --git a/app/Models/CaseItem.php b/app/Models/CaseItem.php index bc8f718e3d..563966e041 100644 --- a/app/Models/CaseItem.php +++ b/app/Models/CaseItem.php @@ -21,12 +21,6 @@ class CaseItem extends BaseModel 'casenumber', ]; - protected $dates = [ - 'created_at', - 'updated_at', - 'deleted_at', - ]; - public $orderable = [ 'id', 'casenumber', @@ -71,16 +65,19 @@ public function respondent(): MorphTo ); } + // TODO public function institution(): BelongsTo { return $this->belongsTo(Institution::class); } + // TODO public function state(): BelongsTo { return $this->belongsTo(CaseItemStatus::class); } + // TODO public function type(): BelongsTo { return $this->belongsTo(CaseItemType::class); @@ -91,11 +88,13 @@ public function priority(): BelongsTo return $this->belongsTo(CaseItemPriority::class); } + // TODO public function assignedTo(): BelongsTo { return $this->belongsTo(User::class); } + // TODO public function createdBy(): BelongsTo { return $this->belongsTo(User::class); diff --git a/app/Models/CaseItemPriority.php b/app/Models/CaseItemPriority.php index 0a1d38dbe0..5132c94c0e 100644 --- a/app/Models/CaseItemPriority.php +++ b/app/Models/CaseItemPriority.php @@ -6,6 +6,7 @@ use DateTimeInterface; use App\Support\HasAdvancedFilter; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Database\Eloquent\Relations\HasMany; /** * @mixin IdeHelperCaseItemPriority @@ -30,11 +31,10 @@ class CaseItemPriority extends BaseModel 'order', ]; - protected $dates = [ - 'created_at', - 'updated_at', - 'deleted_at', - ]; + public function caseItems(): HasMany + { + return $this->hasMany(CaseItem::class); + } public function getCreatedAtAttribute($value) { diff --git a/database/factories/CaseItemFactory.php b/database/factories/CaseItemFactory.php index 5411dee5e5..b9e4a696a1 100644 --- a/database/factories/CaseItemFactory.php +++ b/database/factories/CaseItemFactory.php @@ -4,6 +4,7 @@ use App\Models\Student; use App\Models\CaseItem; +use App\Models\CaseItemPriority; use Illuminate\Database\Eloquent\Factories\Factory; /** @@ -27,4 +28,23 @@ public function definition(): array 'created_by_id' => $this->faker->randomNumber(9), ]; } + + public function configure(): static + { + return $this->afterMaking(function (CaseItem $case) { + })->afterCreating(function (CaseItem $case) { + $this->generatePriority($case); + }); + } + + protected function generatePriority(CaseItem $case): void + { + $priority = CaseItemPriority::inRandomOrder()->first(); + + if (! $priority) { + $priority = CaseItemPriority::factory()->state('high')->create(); + } + + $case->priority()->associate($priority)->save(); + } } diff --git a/database/factories/CaseItemPriorityFactory.php b/database/factories/CaseItemPriorityFactory.php index 287151ca29..c0370f7f4c 100644 --- a/database/factories/CaseItemPriorityFactory.php +++ b/database/factories/CaseItemPriorityFactory.php @@ -17,4 +17,34 @@ public function definition(): array 'order' => $this->faker->randomNumber(1), ]; } + + public function high(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'name' => 'High', + 'order' => 1, + ]; + }); + } + + public function medium(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'name' => 'Medium', + 'order' => 2, + ]; + }); + } + + public function low(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'name' => 'Low', + 'order' => 3, + ]; + }); + } } From 6dad602782569d7456a7be397dd1fa523307689c Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Sun, 23 Jul 2023 16:36:34 -0400 Subject: [PATCH 08/20] Adding the CaseItemPriorityResource Signed-off-by: Kevin Ullyott --- .../Resources/CaseItemPriorityResource.php | 78 +++++++++++++++++++ .../Pages/CreateCaseItemPriority.php | 12 +++ .../Pages/EditCaseItemPriority.php | 20 +++++ .../Pages/ListCaseItemPriorities.php | 19 +++++ .../Pages/ViewCaseItemPriority.php | 19 +++++ 5 files changed, 148 insertions(+) create mode 100644 app/Filament/Resources/CaseItemPriorityResource.php create mode 100644 app/Filament/Resources/CaseItemPriorityResource/Pages/CreateCaseItemPriority.php create mode 100644 app/Filament/Resources/CaseItemPriorityResource/Pages/EditCaseItemPriority.php create mode 100644 app/Filament/Resources/CaseItemPriorityResource/Pages/ListCaseItemPriorities.php create mode 100644 app/Filament/Resources/CaseItemPriorityResource/Pages/ViewCaseItemPriority.php diff --git a/app/Filament/Resources/CaseItemPriorityResource.php b/app/Filament/Resources/CaseItemPriorityResource.php new file mode 100644 index 0000000000..4f3c667797 --- /dev/null +++ b/app/Filament/Resources/CaseItemPriorityResource.php @@ -0,0 +1,78 @@ +schema([ + TextInput::make('name') + ->label('Name') + ->required(), + TextInput::make('order') + ->numeric() + ->label('Priority Order') + ->required(), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('name') + ->label('Name') + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('order') + ->label('Priority Order') + ->sortable(), + ]) + ->defaultSort('order') + ->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\ListCaseItemPriorities::route('/'), + 'create' => Pages\CreateCaseItemPriority::route('/create'), + 'view' => Pages\ViewCaseItemPriority::route('/{record}'), + 'edit' => Pages\EditCaseItemPriority::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Resources/CaseItemPriorityResource/Pages/CreateCaseItemPriority.php b/app/Filament/Resources/CaseItemPriorityResource/Pages/CreateCaseItemPriority.php new file mode 100644 index 0000000000..5e65858547 --- /dev/null +++ b/app/Filament/Resources/CaseItemPriorityResource/Pages/CreateCaseItemPriority.php @@ -0,0 +1,12 @@ + Date: Mon, 24 Jul 2023 09:30:54 -0400 Subject: [PATCH 09/20] Composer require eloquent-power-joins Signed-off-by: Kevin Ullyott --- composer.json | 1 + composer.lock | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0b364ac1ac..fa5dee230e 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ "ext-pdo": "*", "filament/filament": "^3.0", "guzzlehttp/guzzle": "^7.2", + "kirschbaum-development/eloquent-power-joins": "^2.7", "laravel/framework": "^10.0", "laravel/sanctum": "^3.2", "laravel/tinker": "^2.8", diff --git a/composer.lock b/composer.lock index 8f4775760e..cd8fb2450b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "07981d38d2e551b7257fcba68ead7706", + "content-hash": "15072df36140056f11de4589073d8f3f", "packages": [ { "name": "aws/aws-crt-php", From a5dfd4d1836c572b34342da65e5cd836074c5b1f Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 24 Jul 2023 09:31:10 -0400 Subject: [PATCH 10/20] Add filters and sorting based on Priority Signed-off-by: Kevin Ullyott --- app/Filament/Resources/CaseItemResource.php | 9 +++++++++ app/Models/CaseItem.php | 2 ++ 2 files changed, 11 insertions(+) diff --git a/app/Filament/Resources/CaseItemResource.php b/app/Filament/Resources/CaseItemResource.php index a3ec337532..5ba58ef2a3 100644 --- a/app/Filament/Resources/CaseItemResource.php +++ b/app/Filament/Resources/CaseItemResource.php @@ -7,6 +7,7 @@ use Filament\Forms\Form; use Filament\Tables\Table; use Filament\Resources\Resource; +use Illuminate\Database\Eloquent\Builder; use App\Filament\Resources\CaseItemResource\Pages; class CaseItemResource extends Resource @@ -33,10 +34,18 @@ public static function table(Table $table): Table Tables\Columns\TextColumn::make('casenumber') ->label('Case #') ->searchable(), + Tables\Columns\TextColumn::make('priority.name') + ->label('Priority') + ->sortable(query: function (Builder $query, string $direction): Builder { + return $query->orderByPowerJoins('priority.order', $direction); + }), Tables\Columns\TextColumn::make('status_id') ->label('Status'), ]) ->filters([ + Tables\Filters\SelectFilter::make('priority') + ->relationship('priority', 'name') + ->multiple(), ]) ->actions([ Tables\Actions\ViewAction::make(), diff --git a/app/Models/CaseItem.php b/app/Models/CaseItem.php index 563966e041..8215bd99d5 100644 --- a/app/Models/CaseItem.php +++ b/app/Models/CaseItem.php @@ -5,6 +5,7 @@ use Carbon\Carbon; use DateTimeInterface; use App\Support\HasAdvancedFilter; +use Kirschbaum\PowerJoins\PowerJoins; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -16,6 +17,7 @@ class CaseItem extends BaseModel { use HasAdvancedFilter; use SoftDeletes; + use PowerJoins; public static $search = [ 'casenumber', From 00170f6d3cdb1574b1c296c548c61fc28f3c9ee0 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 24 Jul 2023 09:53:05 -0400 Subject: [PATCH 11/20] Setup reordering for CaseItemPriority Signed-off-by: Kevin Ullyott --- app/Filament/Resources/CaseItemPriorityResource.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/CaseItemPriorityResource.php b/app/Filament/Resources/CaseItemPriorityResource.php index 4f3c667797..85395834c5 100644 --- a/app/Filament/Resources/CaseItemPriorityResource.php +++ b/app/Filament/Resources/CaseItemPriorityResource.php @@ -30,7 +30,8 @@ public static function form(Form $form): Form TextInput::make('order') ->numeric() ->label('Priority Order') - ->required(), + ->required() + ->disabledOn('edit'), ]); } @@ -57,7 +58,8 @@ public static function table(Table $table): Table Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), - ]); + ]) + ->reorderable('order'); } public static function getRelations(): array From ffab1e540f4edb54f19a207ea095c558a6ec30e1 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 24 Jul 2023 10:24:40 -0400 Subject: [PATCH 12/20] Setup date serialization for all dates Signed-off-by: Kevin Ullyott --- app/Models/CaseItem.php | 20 ++------------------ app/Models/CaseItemPriority.php | 20 ++------------------ 2 files changed, 4 insertions(+), 36 deletions(-) diff --git a/app/Models/CaseItem.php b/app/Models/CaseItem.php index 8215bd99d5..fafe72fef1 100644 --- a/app/Models/CaseItem.php +++ b/app/Models/CaseItem.php @@ -2,7 +2,6 @@ namespace App\Models; -use Carbon\Carbon; use DateTimeInterface; use App\Support\HasAdvancedFilter; use Kirschbaum\PowerJoins\PowerJoins; @@ -102,23 +101,8 @@ public function createdBy(): BelongsTo return $this->belongsTo(User::class); } - public function getCreatedAtAttribute($value) + protected function serializeDate(DateTimeInterface $date): string { - return $value ? Carbon::createFromFormat('Y-m-d H:i:s', $value)->format(config('project.datetime_format')) : null; - } - - public function getUpdatedAtAttribute($value) - { - return $value ? Carbon::createFromFormat('Y-m-d H:i:s', $value)->format(config('project.datetime_format')) : null; - } - - public function getDeletedAtAttribute($value) - { - return $value ? Carbon::createFromFormat('Y-m-d H:i:s', $value)->format(config('project.datetime_format')) : null; - } - - protected function serializeDate(DateTimeInterface $date) - { - return $date->format('Y-m-d H:i:s'); + return $date->format(config('project.datetime_format') ?? 'Y-m-d H:i:s'); } } diff --git a/app/Models/CaseItemPriority.php b/app/Models/CaseItemPriority.php index 5132c94c0e..db05423eae 100644 --- a/app/Models/CaseItemPriority.php +++ b/app/Models/CaseItemPriority.php @@ -2,7 +2,6 @@ namespace App\Models; -use Carbon\Carbon; use DateTimeInterface; use App\Support\HasAdvancedFilter; use Illuminate\Database\Eloquent\SoftDeletes; @@ -36,23 +35,8 @@ public function caseItems(): HasMany return $this->hasMany(CaseItem::class); } - public function getCreatedAtAttribute($value) + protected function serializeDate(DateTimeInterface $date): string { - return $value ? Carbon::createFromFormat('Y-m-d H:i:s', $value)->format(config('project.datetime_format')) : null; - } - - public function getUpdatedAtAttribute($value) - { - return $value ? Carbon::createFromFormat('Y-m-d H:i:s', $value)->format(config('project.datetime_format')) : null; - } - - public function getDeletedAtAttribute($value) - { - return $value ? Carbon::createFromFormat('Y-m-d H:i:s', $value)->format(config('project.datetime_format')) : null; - } - - protected function serializeDate(DateTimeInterface $date) - { - return $date->format('Y-m-d H:i:s'); + return $date->format(config('project.datetime_format') ?? 'Y-m-d H:i:s'); } } From 40a3642f9e5a6b25f9b4d3a96225d3b61e0e106f Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 24 Jul 2023 12:10:59 -0400 Subject: [PATCH 13/20] Setup case status Signed-off-by: Kevin Ullyott --- app/Enums/ColumnColorOptions.php | 18 +++++ app/Filament/Resources/CaseItemResource.php | 9 ++- .../Resources/CaseItemStatusResource.php | 81 +++++++++++++++++++ .../Pages/CreateCaseItemStatus.php | 12 +++ .../Pages/EditCaseItemStatus.php | 19 +++++ .../Pages/ListCaseItemStatuses.php | 19 +++++ app/Models/CaseItem.php | 1 - app/Models/CaseItemStatus.php | 30 ++----- database/factories/CaseItemFactory.php | 13 +++ database/factories/CaseItemStatusFactory.php | 51 ++++++++++++ ...000009_create_case_item_statuses_table.php | 5 +- database/seeders/CaseItemStatusSeeder.php | 24 ++++++ database/seeders/DatabaseSeeder.php | 1 + 13 files changed, 255 insertions(+), 28 deletions(-) create mode 100644 app/Enums/ColumnColorOptions.php create mode 100644 app/Filament/Resources/CaseItemStatusResource.php create mode 100644 app/Filament/Resources/CaseItemStatusResource/Pages/CreateCaseItemStatus.php create mode 100644 app/Filament/Resources/CaseItemStatusResource/Pages/EditCaseItemStatus.php create mode 100644 app/Filament/Resources/CaseItemStatusResource/Pages/ListCaseItemStatuses.php create mode 100644 database/factories/CaseItemStatusFactory.php create mode 100644 database/seeders/CaseItemStatusSeeder.php diff --git a/app/Enums/ColumnColorOptions.php b/app/Enums/ColumnColorOptions.php new file mode 100644 index 0000000000..ffc3b66164 --- /dev/null +++ b/app/Enums/ColumnColorOptions.php @@ -0,0 +1,18 @@ +sortable(query: function (Builder $query, string $direction): Builder { return $query->orderByPowerJoins('priority.order', $direction); }), - Tables\Columns\TextColumn::make('status_id') - ->label('Status'), + Tables\Columns\TextColumn::make('state.name') + ->label('Status') + ->badge() + ->color(fn (CaseItem $caseItem) => $caseItem->state->color), ]) ->filters([ Tables\Filters\SelectFilter::make('priority') ->relationship('priority', 'name') ->multiple(), + Tables\Filters\SelectFilter::make('state') + ->relationship('state', 'name') + ->multiple(), ]) ->actions([ Tables\Actions\ViewAction::make(), diff --git a/app/Filament/Resources/CaseItemStatusResource.php b/app/Filament/Resources/CaseItemStatusResource.php new file mode 100644 index 0000000000..71cf86413a --- /dev/null +++ b/app/Filament/Resources/CaseItemStatusResource.php @@ -0,0 +1,81 @@ +schema([ + TextInput::make('name') + ->label('Name') + ->translateLabel() + ->required(), + Select::make('color') + ->label('Color') + ->translateLabel() + ->options(ColumnColorOptions::class) + ->required() + ->enum(ColumnColorOptions::class), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('name') + ->label('Name') + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('color') + ->label('Color') + ->badge() + ->color(fn (CaseItemStatus $caseItemStatus) => $caseItemStatus->color), + ]) + ->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\ListCaseItemStatuses::route('/'), + 'create' => Pages\CreateCaseItemStatus::route('/create'), + 'edit' => Pages\EditCaseItemStatus::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Resources/CaseItemStatusResource/Pages/CreateCaseItemStatus.php b/app/Filament/Resources/CaseItemStatusResource/Pages/CreateCaseItemStatus.php new file mode 100644 index 0000000000..7866faefb2 --- /dev/null +++ b/app/Filament/Resources/CaseItemStatusResource/Pages/CreateCaseItemStatus.php @@ -0,0 +1,12 @@ +belongsTo(Institution::class); } - // TODO public function state(): BelongsTo { return $this->belongsTo(CaseItemStatus::class); diff --git a/app/Models/CaseItemStatus.php b/app/Models/CaseItemStatus.php index 8ab16273b9..eed45c92e1 100644 --- a/app/Models/CaseItemStatus.php +++ b/app/Models/CaseItemStatus.php @@ -2,7 +2,6 @@ namespace App\Models; -use Carbon\Carbon; use DateTimeInterface; use App\Support\HasAdvancedFilter; use Illuminate\Database\Eloquent\SoftDeletes; @@ -16,42 +15,27 @@ class CaseItemStatus extends BaseModel use SoftDeletes; protected $fillable = [ - 'status', + 'name', + 'color', ]; public $orderable = [ 'id', - 'status', + 'name', ]; public $filterable = [ 'id', - 'status', + 'name', ]; - protected $dates = [ - 'created_at', - 'updated_at', - 'deleted_at', - ]; - - public function getCreatedAtAttribute($value) - { - return $value ? Carbon::createFromFormat('Y-m-d H:i:s', $value)->format(config('project.datetime_format')) : null; - } - - public function getUpdatedAtAttribute($value) - { - return $value ? Carbon::createFromFormat('Y-m-d H:i:s', $value)->format(config('project.datetime_format')) : null; - } - - public function getDeletedAtAttribute($value) + public function caseItems() { - return $value ? Carbon::createFromFormat('Y-m-d H:i:s', $value)->format(config('project.datetime_format')) : null; + return $this->hasMany(CaseItem::class); } protected function serializeDate(DateTimeInterface $date) { - return $date->format('Y-m-d H:i:s'); + return $date->format(config('project.datetime_format') ?? 'Y-m-d H:i:s'); } } diff --git a/database/factories/CaseItemFactory.php b/database/factories/CaseItemFactory.php index b9e4a696a1..701f2868c4 100644 --- a/database/factories/CaseItemFactory.php +++ b/database/factories/CaseItemFactory.php @@ -4,6 +4,7 @@ use App\Models\Student; use App\Models\CaseItem; +use App\Models\CaseItemStatus; use App\Models\CaseItemPriority; use Illuminate\Database\Eloquent\Factories\Factory; @@ -34,6 +35,7 @@ public function configure(): static return $this->afterMaking(function (CaseItem $case) { })->afterCreating(function (CaseItem $case) { $this->generatePriority($case); + $this->generateStatus($case); }); } @@ -47,4 +49,15 @@ protected function generatePriority(CaseItem $case): void $case->priority()->associate($priority)->save(); } + + protected function generateStatus(CaseItem $case): void + { + $priority = CaseItemStatus::inRandomOrder()->first(); + + if (! $priority) { + $priority = CaseItemStatus::factory()->state('open')->create(); + } + + $case->state()->associate($priority)->save(); + } } diff --git a/database/factories/CaseItemStatusFactory.php b/database/factories/CaseItemStatusFactory.php new file mode 100644 index 0000000000..ae9eb71968 --- /dev/null +++ b/database/factories/CaseItemStatusFactory.php @@ -0,0 +1,51 @@ + + */ +class CaseItemStatusFactory extends Factory +{ + public function definition(): array + { + return [ + 'name' => $this->faker->word, + 'color' => $this->faker->randomElement(ColumnColorOptions::cases())->value, + ]; + } + + public function open(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'name' => 'Open', + 'color' => ColumnColorOptions::SUCCESS->value, + ]; + }); + } + + public function in_progress(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'name' => 'In Progress', + 'color' => ColumnColorOptions::INFO->value, + ]; + }); + } + + public function closed(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'name' => 'Closed', + 'color' => ColumnColorOptions::WARNING->value, + ]; + }); + } +} diff --git a/database/migrations/2023_03_06_000009_create_case_item_statuses_table.php b/database/migrations/2023_03_06_000009_create_case_item_statuses_table.php index 2af97769fd..1dbb24d69c 100644 --- a/database/migrations/2023_03_06_000009_create_case_item_statuses_table.php +++ b/database/migrations/2023_03_06_000009_create_case_item_statuses_table.php @@ -6,11 +6,12 @@ class CreateCaseItemStatusesTable extends Migration { - public function up() + public function up(): void { Schema::create('case_item_statuses', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('status'); + $table->string('name'); + $table->string('color'); $table->timestamps(); $table->softDeletes(); }); diff --git a/database/seeders/CaseItemStatusSeeder.php b/database/seeders/CaseItemStatusSeeder.php new file mode 100644 index 0000000000..9e1eb3404f --- /dev/null +++ b/database/seeders/CaseItemStatusSeeder.php @@ -0,0 +1,24 @@ +open() + ->create(); + + CaseItemStatus::factory() + ->in_progress() + ->create(); + + CaseItemStatus::factory() + ->closed() + ->create(); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index de582d8d4d..7450d12681 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -15,6 +15,7 @@ public function run(): void $this->call([ UsersTableSeeder::class, CaseItemPrioritySeeder::class, + CaseItemStatusSeeder::class, CaseItemSeeder::class, StudentSeeder::class, ]); From 5c34e1e902a2f48b5be43c6a29d25ace2b80e045 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 24 Jul 2023 13:45:46 -0400 Subject: [PATCH 14/20] Adjustments to keep access to old tables Signed-off-by: Kevin Ullyott --- app/Http/Livewire/CaseItem/Edit.php | 4 ++-- app/Http/Livewire/CaseItem/Index.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Livewire/CaseItem/Edit.php b/app/Http/Livewire/CaseItem/Edit.php index e2e55595b0..0b668cba57 100644 --- a/app/Http/Livewire/CaseItem/Edit.php +++ b/app/Http/Livewire/CaseItem/Edit.php @@ -91,9 +91,9 @@ protected function initListsForFields(): void { $this->listsForFields['student'] = RecordStudentItem::pluck('full', 'id')->toArray(); $this->listsForFields['institution'] = Institution::pluck('name', 'id')->toArray(); - $this->listsForFields['state'] = CaseItemStatus::pluck('status', 'id')->toArray(); + $this->listsForFields['state'] = CaseItemStatus::pluck('name', 'id')->toArray(); $this->listsForFields['type'] = CaseItemType::pluck('type', 'id')->toArray(); - $this->listsForFields['priority'] = CaseItemPriority::pluck('priority', 'id')->toArray(); + $this->listsForFields['priority'] = CaseItemPriority::pluck('name', 'id')->toArray(); $this->listsForFields['assigned_to'] = User::pluck('name', 'id')->toArray(); } } diff --git a/app/Http/Livewire/CaseItem/Index.php b/app/Http/Livewire/CaseItem/Index.php index ce7ee57d58..0951e9f696 100644 --- a/app/Http/Livewire/CaseItem/Index.php +++ b/app/Http/Livewire/CaseItem/Index.php @@ -69,7 +69,7 @@ public function mount() public function render() { - $query = CaseItem::with(['respondent', 'institution', 'state', 'type', 'priority', 'assignedTo', 'createdBy'])->advancedFilter([ + $query = CaseItem::with(['institution', 'state', 'type', 'priority', 'assignedTo', 'createdBy'])->advancedFilter([ 's' => $this->search ?: null, 'order_column' => $this->sortBy, 'order_direction' => $this->sortDirection, From ccb4d9b4bae2fb95cf2fe0d0e65d291401f0a7a3 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 24 Jul 2023 17:58:05 -0400 Subject: [PATCH 15/20] Work on the CaseItem edit form Signed-off-by: Kevin Ullyott --- app/Filament/Resources/CaseItemResource.php | 33 +++++++++++++++++++ .../CaseItemResource/Pages/EditCaseItem.php | 2 +- app/Models/Student.php | 7 +--- database/factories/CaseItemFactory.php | 8 +++-- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/app/Filament/Resources/CaseItemResource.php b/app/Filament/Resources/CaseItemResource.php index 5385d17de6..545e3804db 100644 --- a/app/Filament/Resources/CaseItemResource.php +++ b/app/Filament/Resources/CaseItemResource.php @@ -3,11 +3,16 @@ namespace App\Filament\Resources; use Filament\Tables; +use App\Models\Student; use App\Models\CaseItem; use Filament\Forms\Form; use Filament\Tables\Table; +use App\Models\CaseItemStatus; use Filament\Resources\Resource; +use Filament\Forms\Components\Select; +use Filament\Forms\Components\TextInput; use Illuminate\Database\Eloquent\Builder; +use Filament\Forms\Components\MorphToSelect; use App\Filament\Resources\CaseItemResource\Pages; class CaseItemResource extends Resource @@ -24,6 +29,33 @@ public static function form(Form $form): Form { return $form ->schema([ + TextInput::make('casenumber') + ->label('Case #') + ->required() + ->disabledOn('edit'), + MorphToSelect::make('respondent') + ->types([ + MorphToSelect\Type::make(Student::class) + ->getOptionLabelFromRecordUsing(fn (Student $student): string => "{$student->first_name} {$student->middle_name} {$student->last_name}") + ->titleAttribute('first_name'), + ]) + ->searchable() + ->label('Respondent'), + // TODO: Institution + Select::make('state') + ->options(CaseItemStatus::all()->pluck('name', 'id')) + ->relationship('state', 'name') + ->label('State') + ->required(), + // TODO: Type + Select::make('priority') + ->relationship( + relationshipName: 'priority', + titleAttribute: 'name', + modifyOptionsQueryUsing: fn (Builder $query) => $query->orderBy('order'), + ) + ->label('Priority') + ->required(), ]); } @@ -54,6 +86,7 @@ public static function table(Table $table): Table ]) ->actions([ Tables\Actions\ViewAction::make(), + Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ diff --git a/app/Filament/Resources/CaseItemResource/Pages/EditCaseItem.php b/app/Filament/Resources/CaseItemResource/Pages/EditCaseItem.php index 091e2acc06..7298f127e7 100644 --- a/app/Filament/Resources/CaseItemResource/Pages/EditCaseItem.php +++ b/app/Filament/Resources/CaseItemResource/Pages/EditCaseItem.php @@ -2,9 +2,9 @@ namespace App\Filament\Resources\CaseItemResource\Pages; -use App\Filament\Resources\CaseItemResource; use Filament\Actions; use Filament\Resources\Pages\EditRecord; +use App\Filament\Resources\CaseItemResource; class EditCaseItem extends EditRecord { diff --git a/app/Models/Student.php b/app/Models/Student.php index f22515bf9a..81922df91e 100644 --- a/app/Models/Student.php +++ b/app/Models/Student.php @@ -13,7 +13,7 @@ class Student extends Model { use HasFactory; - protected $primaryKey = null; + protected $primaryKey = 'student_id'; public $incrementing = false; @@ -27,9 +27,4 @@ public function cases(): MorphMany localKey: 'student_id' ); } - - public function mcWhereHas($relation, $callback = null, $operator = '>=', $count = 1) - { - // TODO: Create a whereHas and other methods that work with the different database connections - } } diff --git a/database/factories/CaseItemFactory.php b/database/factories/CaseItemFactory.php index 701f2868c4..823ef9d318 100644 --- a/database/factories/CaseItemFactory.php +++ b/database/factories/CaseItemFactory.php @@ -17,8 +17,10 @@ public function definition(): array { return [ 'casenumber' => $this->faker->randomNumber(9), - 'respondent_type' => 'App\Models\Student', 'respondent_id' => Student::factory(), + 'respondent_type' => function (array $attributes) { + return Student::find($attributes['respondent_id'])->getMorphClass(); + }, 'close_details' => $this->faker->sentence(), 'res_details' => $this->faker->sentence(), 'institution_id' => $this->faker->randomNumber(9), @@ -44,7 +46,7 @@ protected function generatePriority(CaseItem $case): void $priority = CaseItemPriority::inRandomOrder()->first(); if (! $priority) { - $priority = CaseItemPriority::factory()->state('high')->create(); + $priority = CaseItemPriority::factory()->high()->create(); } $case->priority()->associate($priority)->save(); @@ -55,7 +57,7 @@ protected function generateStatus(CaseItem $case): void $priority = CaseItemStatus::inRandomOrder()->first(); if (! $priority) { - $priority = CaseItemStatus::factory()->state('open')->create(); + $priority = CaseItemStatus::factory()->open()->create(); } $case->state()->associate($priority)->save(); From cbe6f210e0f58b3e033c1c29d96529a0e49c23fe Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 24 Jul 2023 18:21:36 -0400 Subject: [PATCH 16/20] Add more columns to the form Signed-off-by: Kevin Ullyott --- app/Filament/Resources/CaseItemResource.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/CaseItemResource.php b/app/Filament/Resources/CaseItemResource.php index 545e3804db..0420c2bcca 100644 --- a/app/Filament/Resources/CaseItemResource.php +++ b/app/Filament/Resources/CaseItemResource.php @@ -10,6 +10,7 @@ use App\Models\CaseItemStatus; use Filament\Resources\Resource; use Filament\Forms\Components\Select; +use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Illuminate\Database\Eloquent\Builder; use Filament\Forms\Components\MorphToSelect; @@ -41,13 +42,13 @@ public static function form(Form $form): Form ]) ->searchable() ->label('Respondent'), - // TODO: Institution + // TODO: Add Institution input Select::make('state') ->options(CaseItemStatus::all()->pluck('name', 'id')) ->relationship('state', 'name') ->label('State') ->required(), - // TODO: Type + // TODO: Add Type input Select::make('priority') ->relationship( relationshipName: 'priority', @@ -56,6 +57,20 @@ public static function form(Form $form): Form ) ->label('Priority') ->required(), + Select::make('assignedTo') + ->relationship( + relationshipName: 'assignedTo', + titleAttribute: 'name', + ) + ->label('Assigned To') + ->required() + ->searchable(['name', 'email']), + Textarea::make('close_details') + ->label('Close Details/Description') + ->nullable(), + Textarea::make('res_details') + ->label('Internal Case Details') + ->nullable(), ]); } From b2ec70d2dfc55b457f90dae3d35110c3297ad026 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 24 Jul 2023 18:42:55 -0400 Subject: [PATCH 17/20] Remove todo Signed-off-by: Kevin Ullyott --- app/Models/CaseItem.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Models/CaseItem.php b/app/Models/CaseItem.php index cad193c07c..d52cc89e3d 100644 --- a/app/Models/CaseItem.php +++ b/app/Models/CaseItem.php @@ -88,7 +88,6 @@ public function priority(): BelongsTo return $this->belongsTo(CaseItemPriority::class); } - // TODO public function assignedTo(): BelongsTo { return $this->belongsTo(User::class); From 7626751841a1a91b31cb35da297aa608855178e2 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 24 Jul 2023 18:43:43 -0400 Subject: [PATCH 18/20] Linting Signed-off-by: Kevin Ullyott --- .../Pages/CreateCaseItemPriority.php | 3 +- .../Pages/EditCaseItemPriority.php | 2 +- .../Pages/ListCaseItemPriorities.php | 2 +- .../Pages/ViewCaseItemPriority.php | 2 +- .../CaseItemResource/Pages/CreateCaseItem.php | 3 +- .../CaseItemResource/Pages/ListCaseItems.php | 2 +- .../Pages/CreateCaseItemStatus.php | 3 +- .../Pages/EditCaseItemStatus.php | 2 +- .../Pages/ListCaseItemStatuses.php | 2 +- resources/views/components/sidebar.blade.php | 48 +++++++++---------- 10 files changed, 33 insertions(+), 36 deletions(-) diff --git a/app/Filament/Resources/CaseItemPriorityResource/Pages/CreateCaseItemPriority.php b/app/Filament/Resources/CaseItemPriorityResource/Pages/CreateCaseItemPriority.php index 5e65858547..0e5abb3ad6 100644 --- a/app/Filament/Resources/CaseItemPriorityResource/Pages/CreateCaseItemPriority.php +++ b/app/Filament/Resources/CaseItemPriorityResource/Pages/CreateCaseItemPriority.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\CaseItemPriorityResource\Pages; -use App\Filament\Resources\CaseItemPriorityResource; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; +use App\Filament\Resources\CaseItemPriorityResource; class CreateCaseItemPriority extends CreateRecord { diff --git a/app/Filament/Resources/CaseItemPriorityResource/Pages/EditCaseItemPriority.php b/app/Filament/Resources/CaseItemPriorityResource/Pages/EditCaseItemPriority.php index d0ae6ae60a..8fc1546785 100644 --- a/app/Filament/Resources/CaseItemPriorityResource/Pages/EditCaseItemPriority.php +++ b/app/Filament/Resources/CaseItemPriorityResource/Pages/EditCaseItemPriority.php @@ -2,9 +2,9 @@ namespace App\Filament\Resources\CaseItemPriorityResource\Pages; -use App\Filament\Resources\CaseItemPriorityResource; use Filament\Actions; use Filament\Resources\Pages\EditRecord; +use App\Filament\Resources\CaseItemPriorityResource; class EditCaseItemPriority extends EditRecord { diff --git a/app/Filament/Resources/CaseItemPriorityResource/Pages/ListCaseItemPriorities.php b/app/Filament/Resources/CaseItemPriorityResource/Pages/ListCaseItemPriorities.php index a862af9e98..59d885dfc7 100644 --- a/app/Filament/Resources/CaseItemPriorityResource/Pages/ListCaseItemPriorities.php +++ b/app/Filament/Resources/CaseItemPriorityResource/Pages/ListCaseItemPriorities.php @@ -2,9 +2,9 @@ namespace App\Filament\Resources\CaseItemPriorityResource\Pages; -use App\Filament\Resources\CaseItemPriorityResource; use Filament\Actions; use Filament\Resources\Pages\ListRecords; +use App\Filament\Resources\CaseItemPriorityResource; class ListCaseItemPriorities extends ListRecords { diff --git a/app/Filament/Resources/CaseItemPriorityResource/Pages/ViewCaseItemPriority.php b/app/Filament/Resources/CaseItemPriorityResource/Pages/ViewCaseItemPriority.php index 56bde0cf80..85986e2b08 100644 --- a/app/Filament/Resources/CaseItemPriorityResource/Pages/ViewCaseItemPriority.php +++ b/app/Filament/Resources/CaseItemPriorityResource/Pages/ViewCaseItemPriority.php @@ -2,9 +2,9 @@ namespace App\Filament\Resources\CaseItemPriorityResource\Pages; -use App\Filament\Resources\CaseItemPriorityResource; use Filament\Actions; use Filament\Resources\Pages\ViewRecord; +use App\Filament\Resources\CaseItemPriorityResource; class ViewCaseItemPriority extends ViewRecord { diff --git a/app/Filament/Resources/CaseItemResource/Pages/CreateCaseItem.php b/app/Filament/Resources/CaseItemResource/Pages/CreateCaseItem.php index 084831b627..66b4d5d0ad 100644 --- a/app/Filament/Resources/CaseItemResource/Pages/CreateCaseItem.php +++ b/app/Filament/Resources/CaseItemResource/Pages/CreateCaseItem.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\CaseItemResource\Pages; -use App\Filament\Resources\CaseItemResource; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; +use App\Filament\Resources\CaseItemResource; class CreateCaseItem extends CreateRecord { diff --git a/app/Filament/Resources/CaseItemResource/Pages/ListCaseItems.php b/app/Filament/Resources/CaseItemResource/Pages/ListCaseItems.php index 4ae460e137..9da7da2759 100644 --- a/app/Filament/Resources/CaseItemResource/Pages/ListCaseItems.php +++ b/app/Filament/Resources/CaseItemResource/Pages/ListCaseItems.php @@ -2,9 +2,9 @@ namespace App\Filament\Resources\CaseItemResource\Pages; -use App\Filament\Resources\CaseItemResource; use Filament\Actions; use Filament\Resources\Pages\ListRecords; +use App\Filament\Resources\CaseItemResource; class ListCaseItems extends ListRecords { diff --git a/app/Filament/Resources/CaseItemStatusResource/Pages/CreateCaseItemStatus.php b/app/Filament/Resources/CaseItemStatusResource/Pages/CreateCaseItemStatus.php index 7866faefb2..762e4feee5 100644 --- a/app/Filament/Resources/CaseItemStatusResource/Pages/CreateCaseItemStatus.php +++ b/app/Filament/Resources/CaseItemStatusResource/Pages/CreateCaseItemStatus.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\CaseItemStatusResource\Pages; -use App\Filament\Resources\CaseItemStatusResource; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; +use App\Filament\Resources\CaseItemStatusResource; class CreateCaseItemStatus extends CreateRecord { diff --git a/app/Filament/Resources/CaseItemStatusResource/Pages/EditCaseItemStatus.php b/app/Filament/Resources/CaseItemStatusResource/Pages/EditCaseItemStatus.php index fc7766718d..1e53d1a73a 100644 --- a/app/Filament/Resources/CaseItemStatusResource/Pages/EditCaseItemStatus.php +++ b/app/Filament/Resources/CaseItemStatusResource/Pages/EditCaseItemStatus.php @@ -2,9 +2,9 @@ namespace App\Filament\Resources\CaseItemStatusResource\Pages; -use App\Filament\Resources\CaseItemStatusResource; use Filament\Actions; use Filament\Resources\Pages\EditRecord; +use App\Filament\Resources\CaseItemStatusResource; class EditCaseItemStatus extends EditRecord { diff --git a/app/Filament/Resources/CaseItemStatusResource/Pages/ListCaseItemStatuses.php b/app/Filament/Resources/CaseItemStatusResource/Pages/ListCaseItemStatuses.php index 295a883995..d32b817547 100644 --- a/app/Filament/Resources/CaseItemStatusResource/Pages/ListCaseItemStatuses.php +++ b/app/Filament/Resources/CaseItemStatusResource/Pages/ListCaseItemStatuses.php @@ -2,9 +2,9 @@ namespace App\Filament\Resources\CaseItemStatusResource\Pages; -use App\Filament\Resources\CaseItemStatusResource; use Filament\Actions; use Filament\Resources\Pages\ListRecords; +use App\Filament\Resources\CaseItemStatusResource; class ListCaseItemStatuses extends ListRecords { diff --git a/resources/views/components/sidebar.blade.php b/resources/views/components/sidebar.blade.php index fed539a81c..8ac324acd7 100644 --- a/resources/views/components/sidebar.blade.php +++ b/resources/views/components/sidebar.blade.php @@ -622,30 +622,30 @@ class="{{ request()->is('admin/users*') ? 'sidebar-nav-active' : 'sidebar-nav' }
  • @endcan -{{-- @can('permission_access')--}} -{{--
  • --}} -{{-- --}} -{{-- --}} -{{-- --}} -{{-- {{ trans('cruds.permission.title') }}--}} -{{-- --}} -{{--
  • --}} -{{-- @endcan--}} -{{-- @can('role_access')--}} -{{--
  • --}} -{{-- --}} -{{-- --}} -{{-- --}} -{{-- {{ trans('cruds.role.title') }}--}} -{{-- --}} -{{--
  • --}} -{{-- @endcan--}} + {{-- @can('permission_access') --}} + {{--
  • --}} + {{-- --}} + {{-- --}} + {{-- --}} + {{-- {{ trans('cruds.permission.title') }} --}} + {{-- --}} + {{--
  • --}} + {{-- @endcan --}} + {{-- @can('role_access') --}} + {{--
  • --}} + {{-- --}} + {{-- --}} + {{-- --}} + {{-- {{ trans('cruds.role.title') }} --}} + {{-- --}} + {{--
  • --}} + {{-- @endcan --}} @can('user_alert_access')
  • Date: Tue, 25 Jul 2023 11:41:30 -0400 Subject: [PATCH 19/20] Setup relation between cases and instiution Signed-off-by: Kevin Ullyott --- app/Models/CaseItem.php | 3 +-- database/factories/CaseItemFactory.php | 10 ++++++---- database/factories/InstitutionFactory.php | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 database/factories/InstitutionFactory.php diff --git a/app/Models/CaseItem.php b/app/Models/CaseItem.php index d52cc89e3d..87aee37390 100644 --- a/app/Models/CaseItem.php +++ b/app/Models/CaseItem.php @@ -66,7 +66,6 @@ public function respondent(): MorphTo ); } - // TODO public function institution(): BelongsTo { return $this->belongsTo(Institution::class); @@ -93,7 +92,7 @@ public function assignedTo(): BelongsTo return $this->belongsTo(User::class); } - // TODO + // TODO: Figure this out and whether or not it can just be handled via auditing public function createdBy(): BelongsTo { return $this->belongsTo(User::class); diff --git a/database/factories/CaseItemFactory.php b/database/factories/CaseItemFactory.php index 823ef9d318..741cbc2588 100644 --- a/database/factories/CaseItemFactory.php +++ b/database/factories/CaseItemFactory.php @@ -2,8 +2,10 @@ namespace Database\Factories; +use App\Models\User; use App\Models\Student; use App\Models\CaseItem; +use App\Models\Institution; use App\Models\CaseItemStatus; use App\Models\CaseItemPriority; use Illuminate\Database\Eloquent\Factories\Factory; @@ -23,11 +25,11 @@ public function definition(): array }, 'close_details' => $this->faker->sentence(), 'res_details' => $this->faker->sentence(), - 'institution_id' => $this->faker->randomNumber(9), - 'state_id' => $this->faker->randomNumber(9), + 'institution_id' => Institution::factory(), + 'state_id' => CaseItemStatus::factory(), 'type_id' => $this->faker->randomNumber(9), - 'priority_id' => $this->faker->randomNumber(9), - 'assigned_to_id' => $this->faker->randomNumber(9), + 'priority_id' => CaseItemPriority::factory(), + 'assigned_to_id' => User::factory(), 'created_by_id' => $this->faker->randomNumber(9), ]; } diff --git a/database/factories/InstitutionFactory.php b/database/factories/InstitutionFactory.php new file mode 100644 index 0000000000..46b065b416 --- /dev/null +++ b/database/factories/InstitutionFactory.php @@ -0,0 +1,21 @@ + + */ +class InstitutionFactory extends Factory +{ + public function definition(): array + { + return [ + 'code' => $this->faker->word(), + 'name' => $this->faker->company(), + 'description' => $this->faker->text(), + ]; + } +} From e5757cfae0d9b8e9bfa6ec3bf6eaf6fee3bf8ed6 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Tue, 25 Jul 2023 11:46:58 -0400 Subject: [PATCH 20/20] pluck first rather than calling all Signed-off-by: Kevin Ullyott --- app/Filament/Resources/CaseItemResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Filament/Resources/CaseItemResource.php b/app/Filament/Resources/CaseItemResource.php index 0420c2bcca..95a26d525b 100644 --- a/app/Filament/Resources/CaseItemResource.php +++ b/app/Filament/Resources/CaseItemResource.php @@ -44,7 +44,7 @@ public static function form(Form $form): Form ->label('Respondent'), // TODO: Add Institution input Select::make('state') - ->options(CaseItemStatus::all()->pluck('name', 'id')) + ->options(CaseItemStatus::pluck('name', 'id')) ->relationship('state', 'name') ->label('State') ->required(),