Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADVAPP-209]: Refactor priorities so they are related to types rather than service requests #439

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Filters\SelectFilter;
use Illuminate\Database\Eloquent\Builder;
use App\Filament\Resources\RelationManagers\RelationManager;
use AdvisingApp\ServiceManagement\Models\ServiceRequestPriority;
use AdvisingApp\ServiceManagement\Filament\Resources\ServiceRequestResource\Pages\ViewServiceRequest;
use AdvisingApp\ServiceManagement\Filament\Resources\ServiceRequestResource\Pages\CreateServiceRequest;

Expand Down Expand Up @@ -84,7 +86,8 @@ public function table(Table $table): Table
])
->filters([
SelectFilter::make('priority')
->relationship('priority', 'name')
->relationship('priority', 'name', fn (Builder $query) => $query->with('type'))
->getOptionLabelFromRecordUsing(fn (ServiceRequestPriority $record) => "{$record->type->name} - {$record->name}")
->multiple()
->preload(),
SelectFilter::make('status')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
use AdvisingApp\StudentDataModel\Models\Student;
use Illuminate\Database\Eloquent\Factories\Factory;
use AdvisingApp\ServiceManagement\Models\ServiceRequest;
use AdvisingApp\ServiceManagement\Models\ServiceRequestType;
use AdvisingApp\ServiceManagement\Models\ServiceRequestStatus;
use AdvisingApp\ServiceManagement\Models\ServiceRequestPriority;

Expand All @@ -61,7 +60,6 @@ public function definition(): array
'res_details' => $this->faker->sentence(),
'division_id' => Division::inRandomOrder()->first()?->id ?? Division::factory(),
'status_id' => ServiceRequestStatus::inRandomOrder()->first() ?? ServiceRequestStatus::factory(),
'type_id' => ServiceRequestType::inRandomOrder()->first() ?? ServiceRequestType::factory(),
'priority_id' => ServiceRequestPriority::inRandomOrder()->first() ?? ServiceRequestPriority::factory(),
'created_by_id' => User::factory(),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
namespace AdvisingApp\ServiceManagement\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use AdvisingApp\ServiceManagement\Models\ServiceRequestType;
use AdvisingApp\ServiceManagement\Models\ServiceRequestPriority;

/**
Expand All @@ -49,6 +50,7 @@ public function definition(): array
return [
'name' => $this->faker->name,
'order' => $this->faker->randomNumber(1),
'type_id' => ServiceRequestType::factory(),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function up(): void
$table->uuid('id')->primary();
$table->string('name');
$table->integer('order');
$table->foreignUuid('type_id')->constrained('service_request_types')->cascadeOnDelete();
$table->timestamps();
$table->softDeletes();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function up(): void

$table->foreignUuid('division_id')->nullable()->constrained('divisions');
$table->foreignUuid('status_id')->nullable()->constrained('service_request_statuses');
$table->foreignUuid('type_id')->nullable()->constrained('service_request_types');
$table->foreignUuid('priority_id')->nullable()->constrained('service_request_priorities');
$table->foreignUuid('created_by_id')->nullable()->constrained('users');

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public function run(): void
['name' => 'Tutoring'],
['name' => 'Veterans'],
]
);
)
->each(function (ServiceRequestType $type) {
$type->priorities()->createMany(
[
['name' => 'High', 'order' => 1],
['name' => 'Medium', 'order' => 2],
['name' => 'Low', 'order' => 3],
]
);
});
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading