diff --git a/app-modules/interaction/src/Models/Interaction.php b/app-modules/interaction/src/Models/Interaction.php index bebcda9b9f..55e1a3f5b8 100644 --- a/app-modules/interaction/src/Models/Interaction.php +++ b/app-modules/interaction/src/Models/Interaction.php @@ -46,6 +46,7 @@ use AdvisingApp\Campaign\Models\CampaignAction; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use AdvisingApp\ServiceManagement\Models\ServiceRequest; use AdvisingApp\Notification\Models\Contracts\Subscribable; use AdvisingApp\StudentDataModel\Models\Contracts\Educatable; use AdvisingApp\Audit\Models\Concerns\Auditable as AuditableTrait; @@ -172,7 +173,15 @@ public static function executeFromCampaignAction(CampaignAction $action): bool|s protected static function booted(): void { static::addGlobalScope('licensed', function (Builder $builder) { - $builder->tap(new LicensedToEducatable('interactable')); + $builder + ->tap(new LicensedToEducatable('interactable')) + ->where(fn (Builder $builder) => $builder + ->where('interactable_type', '!=', app(ServiceRequest::class)->getMorphClass()) + ->orWhereDoesntHaveMorph( + 'interactable', + ServiceRequest::class, + fn (Builder $builder) => $builder->tap(new LicensedToEducatable('respondent')), + )); }); } } diff --git a/app-modules/interaction/src/Policies/InteractionCampaignPolicy.php b/app-modules/interaction/src/Policies/InteractionCampaignPolicy.php index 9b0b2e793d..947b72740f 100644 --- a/app-modules/interaction/src/Policies/InteractionCampaignPolicy.php +++ b/app-modules/interaction/src/Policies/InteractionCampaignPolicy.php @@ -38,10 +38,21 @@ use App\Models\Authenticatable; use Illuminate\Auth\Access\Response; +use AdvisingApp\Prospect\Models\Prospect; +use AdvisingApp\StudentDataModel\Models\Student; use AdvisingApp\Interaction\Models\InteractionCampaign; class InteractionCampaignPolicy { + public function before(Authenticatable $authenticatable): ?Response + { + if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) { + return Response::deny('You are not licensed for the Retention or Recruitment CRM.'); + } + + return null; + } + public function viewAny(Authenticatable $authenticatable): Response { return $authenticatable->canOrElse( diff --git a/app-modules/interaction/src/Policies/InteractionDriverPolicy.php b/app-modules/interaction/src/Policies/InteractionDriverPolicy.php index 7231df8b82..a2661bcc8c 100644 --- a/app-modules/interaction/src/Policies/InteractionDriverPolicy.php +++ b/app-modules/interaction/src/Policies/InteractionDriverPolicy.php @@ -38,10 +38,21 @@ use App\Models\Authenticatable; use Illuminate\Auth\Access\Response; +use AdvisingApp\Prospect\Models\Prospect; +use AdvisingApp\StudentDataModel\Models\Student; use AdvisingApp\Interaction\Models\InteractionDriver; class InteractionDriverPolicy { + public function before(Authenticatable $authenticatable): ?Response + { + if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) { + return Response::deny('You are not licensed for the Retention or Recruitment CRM.'); + } + + return null; + } + public function viewAny(Authenticatable $authenticatable): Response { return $authenticatable->canOrElse( diff --git a/app-modules/interaction/src/Policies/InteractionOutcomePolicy.php b/app-modules/interaction/src/Policies/InteractionOutcomePolicy.php index 7d69ce4953..6331303a3f 100644 --- a/app-modules/interaction/src/Policies/InteractionOutcomePolicy.php +++ b/app-modules/interaction/src/Policies/InteractionOutcomePolicy.php @@ -38,10 +38,21 @@ use App\Models\Authenticatable; use Illuminate\Auth\Access\Response; +use AdvisingApp\Prospect\Models\Prospect; +use AdvisingApp\StudentDataModel\Models\Student; use AdvisingApp\Interaction\Models\InteractionOutcome; class InteractionOutcomePolicy { + public function before(Authenticatable $authenticatable): ?Response + { + if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) { + return Response::deny('You are not licensed for the Retention or Recruitment CRM.'); + } + + return null; + } + public function viewAny(Authenticatable $authenticatable): Response { return $authenticatable->canOrElse( diff --git a/app-modules/interaction/src/Policies/InteractionPolicy.php b/app-modules/interaction/src/Policies/InteractionPolicy.php index f21f5ffd0c..272778827c 100644 --- a/app-modules/interaction/src/Policies/InteractionPolicy.php +++ b/app-modules/interaction/src/Policies/InteractionPolicy.php @@ -38,11 +38,21 @@ use App\Models\Authenticatable; use Illuminate\Auth\Access\Response; +use AdvisingApp\Prospect\Models\Prospect; use AdvisingApp\Interaction\Models\Interaction; -use AdvisingApp\StudentDataModel\Models\Contracts\Educatable; +use AdvisingApp\StudentDataModel\Models\Student; class InteractionPolicy { + public function before(Authenticatable $authenticatable): ?Response + { + if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) { + return Response::deny('You are not licensed for the Retention or Recruitment CRM.'); + } + + return null; + } + public function viewAny(Authenticatable $authenticatable): Response { return $authenticatable->canOrElse( @@ -53,10 +63,7 @@ public function viewAny(Authenticatable $authenticatable): Response public function view(Authenticatable $authenticatable, Interaction $interaction): Response { - if ( - ($interaction->interactable instanceof Educatable) && - (! $authenticatable->hasLicense($interaction->interactable->getLicenseType())) - ) { + if (! $authenticatable->can('view', $interaction->interactable)) { return Response::deny('You do not have permission to view this interaction.'); } @@ -76,10 +83,7 @@ public function create(Authenticatable $authenticatable): Response public function update(Authenticatable $authenticatable, Interaction $interaction): Response { - if ( - ($interaction->interactable instanceof Educatable) && - (! $authenticatable->hasLicense($interaction->interactable->getLicenseType())) - ) { + if (! $authenticatable->can('view', $interaction->interactable)) { return Response::deny('You do not have permission to update this interaction.'); } @@ -91,10 +95,7 @@ public function update(Authenticatable $authenticatable, Interaction $interactio public function delete(Authenticatable $authenticatable, Interaction $interaction): Response { - if ( - ($interaction->interactable instanceof Educatable) && - (! $authenticatable->hasLicense($interaction->interactable->getLicenseType())) - ) { + if (! $authenticatable->can('view', $interaction->interactable)) { return Response::deny('You do not have permission to delete this interaction.'); } @@ -106,10 +107,7 @@ public function delete(Authenticatable $authenticatable, Interaction $interactio public function restore(Authenticatable $authenticatable, Interaction $interaction): Response { - if ( - ($interaction->interactable instanceof Educatable) && - (! $authenticatable->hasLicense($interaction->interactable->getLicenseType())) - ) { + if (! $authenticatable->can('view', $interaction->interactable)) { return Response::deny('You do not have permission to restore this interaction.'); } @@ -121,10 +119,7 @@ public function restore(Authenticatable $authenticatable, Interaction $interacti public function forceDelete(Authenticatable $authenticatable, Interaction $interaction): Response { - if ( - ($interaction->interactable instanceof Educatable) && - (! $authenticatable->hasLicense($interaction->interactable->getLicenseType())) - ) { + if (! $authenticatable->can('view', $interaction->interactable)) { return Response::deny('You do not have permission to permanently delete this interaction.'); } diff --git a/app-modules/interaction/src/Policies/InteractionRelationPolicy.php b/app-modules/interaction/src/Policies/InteractionRelationPolicy.php index 2fe6426d47..db6dc259d0 100644 --- a/app-modules/interaction/src/Policies/InteractionRelationPolicy.php +++ b/app-modules/interaction/src/Policies/InteractionRelationPolicy.php @@ -38,10 +38,21 @@ use App\Models\Authenticatable; use Illuminate\Auth\Access\Response; +use AdvisingApp\Prospect\Models\Prospect; +use AdvisingApp\StudentDataModel\Models\Student; use AdvisingApp\Interaction\Models\InteractionRelation; class InteractionRelationPolicy { + public function before(Authenticatable $authenticatable): ?Response + { + if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) { + return Response::deny('You are not licensed for the Retention or Recruitment CRM.'); + } + + return null; + } + public function viewAny(Authenticatable $authenticatable): Response { return $authenticatable->canOrElse( diff --git a/app-modules/interaction/src/Policies/InteractionStatusPolicy.php b/app-modules/interaction/src/Policies/InteractionStatusPolicy.php index 0c1b753fb9..cd38aafa8c 100644 --- a/app-modules/interaction/src/Policies/InteractionStatusPolicy.php +++ b/app-modules/interaction/src/Policies/InteractionStatusPolicy.php @@ -38,10 +38,21 @@ use App\Models\Authenticatable; use Illuminate\Auth\Access\Response; +use AdvisingApp\Prospect\Models\Prospect; +use AdvisingApp\StudentDataModel\Models\Student; use AdvisingApp\Interaction\Models\InteractionStatus; class InteractionStatusPolicy { + public function before(Authenticatable $authenticatable): ?Response + { + if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) { + return Response::deny('You are not licensed for the Retention or Recruitment CRM.'); + } + + return null; + } + public function viewAny(Authenticatable $authenticatable): Response { return $authenticatable->canOrElse( diff --git a/app-modules/interaction/src/Policies/InteractionTypePolicy.php b/app-modules/interaction/src/Policies/InteractionTypePolicy.php index 95a4f3a5d0..8da54f2ad4 100644 --- a/app-modules/interaction/src/Policies/InteractionTypePolicy.php +++ b/app-modules/interaction/src/Policies/InteractionTypePolicy.php @@ -38,10 +38,21 @@ use App\Models\Authenticatable; use Illuminate\Auth\Access\Response; +use AdvisingApp\Prospect\Models\Prospect; +use AdvisingApp\StudentDataModel\Models\Student; use AdvisingApp\Interaction\Models\InteractionType; class InteractionTypePolicy { + public function before(Authenticatable $authenticatable): ?Response + { + if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) { + return Response::deny('You are not licensed for the Retention or Recruitment CRM.'); + } + + return null; + } + public function viewAny(Authenticatable $authenticatable): Response { return $authenticatable->canOrElse( diff --git a/app-modules/interaction/tests/Filament/InteractionCampaignResource/EditInteractionCampaignTest.php b/app-modules/interaction/tests/Filament/InteractionCampaignResource/EditInteractionCampaignTest.php index 43caa8f5f5..fb8c1136ef 100644 --- a/app-modules/interaction/tests/Filament/InteractionCampaignResource/EditInteractionCampaignTest.php +++ b/app-modules/interaction/tests/Filament/InteractionCampaignResource/EditInteractionCampaignTest.php @@ -38,11 +38,12 @@ use function Pest\Laravel\actingAs; +use AdvisingApp\Authorization\Enums\LicenseType; use AdvisingApp\Interaction\Models\InteractionCampaign; use AdvisingApp\Interaction\Filament\Resources\InteractionCampaignResource; test('EditInteractionCampaign is gated with proper access control', function () { - $user = User::factory()->create(); + $user = User::factory()->licensed(LicenseType::cases())->create(); $campaign = InteractionCampaign::factory()->create(); diff --git a/app-modules/interaction/tests/Filament/InteractionOutcomeResource/CreateInteractionOutcomeTest.php b/app-modules/interaction/tests/Filament/InteractionOutcomeResource/CreateInteractionOutcomeTest.php index fbf4bdf218..ebda95a417 100644 --- a/app-modules/interaction/tests/Filament/InteractionOutcomeResource/CreateInteractionOutcomeTest.php +++ b/app-modules/interaction/tests/Filament/InteractionOutcomeResource/CreateInteractionOutcomeTest.php @@ -38,10 +38,11 @@ use function Pest\Laravel\actingAs; +use AdvisingApp\Authorization\Enums\LicenseType; use AdvisingApp\Interaction\Filament\Resources\InteractionOutcomeResource; test('CreateInteractionOutcome is gated with proper access control', function () { - $user = User::factory()->create(); + $user = User::factory()->licensed(LicenseType::cases())->create(); actingAs($user) ->get( diff --git a/app-modules/interaction/tests/Filament/InteractionRelationResource/CreateInteractionRelationTest.php b/app-modules/interaction/tests/Filament/InteractionRelationResource/CreateInteractionRelationTest.php index 618cda1028..e898fad485 100644 --- a/app-modules/interaction/tests/Filament/InteractionRelationResource/CreateInteractionRelationTest.php +++ b/app-modules/interaction/tests/Filament/InteractionRelationResource/CreateInteractionRelationTest.php @@ -38,10 +38,11 @@ use function Pest\Laravel\actingAs; +use AdvisingApp\Authorization\Enums\LicenseType; use AdvisingApp\Interaction\Filament\Resources\InteractionRelationResource; test('CreateInteractionRelation is gated with proper access control', function () { - $user = User::factory()->create(); + $user = User::factory()->licensed(LicenseType::cases())->create(); actingAs($user) ->get( diff --git a/app-modules/interaction/tests/Filament/InteractionRelationResource/EditInteractionRelationTest.php b/app-modules/interaction/tests/Filament/InteractionRelationResource/EditInteractionRelationTest.php index 24e04a0207..d8e4c2e5f1 100644 --- a/app-modules/interaction/tests/Filament/InteractionRelationResource/EditInteractionRelationTest.php +++ b/app-modules/interaction/tests/Filament/InteractionRelationResource/EditInteractionRelationTest.php @@ -38,11 +38,12 @@ use function Pest\Laravel\actingAs; +use AdvisingApp\Authorization\Enums\LicenseType; use AdvisingApp\Interaction\Models\InteractionRelation; use AdvisingApp\Interaction\Filament\Resources\InteractionRelationResource; test('EditInteractionRelation is gated with proper access control', function () { - $user = User::factory()->create(); + $user = User::factory()->licensed(LicenseType::cases())->create(); $relation = InteractionRelation::factory()->create(); diff --git a/app-modules/interaction/tests/Filament/InteractionRelationResource/ListInteractionRelationsTest.php b/app-modules/interaction/tests/Filament/InteractionRelationResource/ListInteractionRelationsTest.php index dfc6a9eef2..6361321101 100644 --- a/app-modules/interaction/tests/Filament/InteractionRelationResource/ListInteractionRelationsTest.php +++ b/app-modules/interaction/tests/Filament/InteractionRelationResource/ListInteractionRelationsTest.php @@ -38,10 +38,11 @@ use function Pest\Laravel\actingAs; +use AdvisingApp\Authorization\Enums\LicenseType; use AdvisingApp\Interaction\Filament\Resources\InteractionRelationResource; test('ListInteractionRelations is gated with proper access control', function () { - $user = User::factory()->create(); + $user = User::factory()->licensed(LicenseType::cases())->create(); actingAs($user) ->get( diff --git a/app-modules/interaction/tests/Filament/InteractionResource/EditInteractionTest.php b/app-modules/interaction/tests/Filament/InteractionResource/EditInteractionTest.php index 25e2c1f7a3..4885ae1e73 100644 --- a/app-modules/interaction/tests/Filament/InteractionResource/EditInteractionTest.php +++ b/app-modules/interaction/tests/Filament/InteractionResource/EditInteractionTest.php @@ -45,12 +45,17 @@ test('EditInteraction is gated with proper access control', function () { $user = User::factory()->licensed(LicenseType::cases())->create(); + $user->givePermissionTo('student.*.view'); + $user->givePermissionTo('prospect.*.view'); + $user->givePermissionTo('service_request.*.view'); + $interaction = Interaction::factory()->create(); actingAs($user) ->get( InteractionResource::getUrl('edit', ['record' => $interaction]) - )->assertForbidden(); + ) + ->assertForbidden(); $user->givePermissionTo('interaction.view-any'); $user->givePermissionTo('interaction.*.update'); @@ -58,5 +63,6 @@ actingAs($user) ->get( InteractionResource::getUrl('edit', ['record' => $interaction]) - )->assertSuccessful(); + ) + ->assertSuccessful(); }); diff --git a/app-modules/service-management/database/migrations/2023_09_05_144251_create_service_requests_table.php b/app-modules/service-management/database/migrations/2023_09_05_144251_create_service_requests_table.php index 3eeadf26db..102a818077 100644 --- a/app-modules/service-management/database/migrations/2023_09_05_144251_create_service_requests_table.php +++ b/app-modules/service-management/database/migrations/2023_09_05_144251_create_service_requests_table.php @@ -45,8 +45,8 @@ public function up(): void $table->uuid('id')->primary(); $table->string('service_request_number')->unique(); - $table->string('respondent_type')->nullable(); - $table->string('respondent_id')->nullable(); + $table->string('respondent_type'); + $table->string('respondent_id'); $table->longText('close_details')->nullable(); $table->longText('res_details')->nullable(); diff --git a/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/Pages/CreateServiceRequest.php b/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/Pages/CreateServiceRequest.php index c2ca513929..15f184e43d 100644 --- a/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/Pages/CreateServiceRequest.php +++ b/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/Pages/CreateServiceRequest.php @@ -94,6 +94,7 @@ public function form(Form $form): Form ->string(), EducatableSelect::make('respondent') ->label('Related To') + ->required() ->hiddenOn([RelationManager::class, ManageRelatedRecords::class]), ]); } diff --git a/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/Pages/EditServiceRequest.php b/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/Pages/EditServiceRequest.php index 6535df0f40..57fd4e545e 100644 --- a/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/Pages/EditServiceRequest.php +++ b/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/Pages/EditServiceRequest.php @@ -92,7 +92,8 @@ public function form(Form $form): Form ->nullable() ->string(), EducatableSelect::make('respondent') - ->label('Related To'), + ->label('Related To') + ->required(), ]); } diff --git a/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/RelationManagers/AssignedToRelationManager.php b/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/RelationManagers/AssignedToRelationManager.php index ac07cf43e3..46dbd3922e 100644 --- a/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/RelationManagers/AssignedToRelationManager.php +++ b/app-modules/service-management/src/Filament/Resources/ServiceRequestResource/RelationManagers/AssignedToRelationManager.php @@ -93,7 +93,7 @@ public function table(Table $table): Table ->label('Reassign Service Request To') ->searchable() ->getSearchResultsUsing(fn (string $search): array => User::query() - ->tap(new HasLicense($this->getOwnerRecord()->respondent?->getLicenseType())) + ->tap(new HasLicense($this->getOwnerRecord()->respondent->getLicenseType())) ->where(new Expression('lower(name)'), 'like', '%' . str($search)->lower() . '%') ->pluck('name', 'id') ->all()) diff --git a/app-modules/service-management/src/Policies/ServiceRequestPolicy.php b/app-modules/service-management/src/Policies/ServiceRequestPolicy.php index b634395311..43b9477f29 100644 --- a/app-modules/service-management/src/Policies/ServiceRequestPolicy.php +++ b/app-modules/service-management/src/Policies/ServiceRequestPolicy.php @@ -72,7 +72,7 @@ public function viewAny(Authenticatable $authenticatable): Response public function view(Authenticatable $authenticatable, ServiceRequest $serviceRequest): Response { - if (! $authenticatable->hasLicense($serviceRequest->respondent?->getLicenseType())) { + if (! $authenticatable->hasLicense($serviceRequest->respondent->getLicenseType())) { return Response::deny('You do not have permission to view this service request.'); } @@ -92,7 +92,7 @@ public function create(Authenticatable $authenticatable): Response public function update(Authenticatable $authenticatable, ServiceRequest $serviceRequest): Response { - if (! $authenticatable->hasLicense($serviceRequest->respondent?->getLicenseType())) { + if (! $authenticatable->hasLicense($serviceRequest->respondent->getLicenseType())) { return Response::deny('You do not have permission to update this service request.'); } @@ -104,7 +104,7 @@ public function update(Authenticatable $authenticatable, ServiceRequest $service public function delete(Authenticatable $authenticatable, ServiceRequest $serviceRequest): Response { - if (! $authenticatable->hasLicense($serviceRequest->respondent?->getLicenseType())) { + if (! $authenticatable->hasLicense($serviceRequest->respondent->getLicenseType())) { return Response::deny('You do not have permission to delete this service request.'); } @@ -116,7 +116,7 @@ public function delete(Authenticatable $authenticatable, ServiceRequest $service public function restore(Authenticatable $authenticatable, ServiceRequest $serviceRequest): Response { - if (! $authenticatable->hasLicense($serviceRequest->respondent?->getLicenseType())) { + if (! $authenticatable->hasLicense($serviceRequest->respondent->getLicenseType())) { return Response::deny('You do not have permission to restore this service request.'); } @@ -128,7 +128,7 @@ public function restore(Authenticatable $authenticatable, ServiceRequest $servic public function forceDelete(Authenticatable $authenticatable, ServiceRequest $serviceRequest): Response { - if (! $authenticatable->hasLicense($serviceRequest->respondent?->getLicenseType())) { + if (! $authenticatable->hasLicense($serviceRequest->respondent->getLicenseType())) { return Response::deny('You do not have permission to permanently delete this service request.'); } diff --git a/app-modules/service-management/tests/RequestFactories/CreateServiceRequestRequestFactory.php b/app-modules/service-management/tests/RequestFactories/CreateServiceRequestRequestFactory.php index 87a97842d2..6985e1637d 100644 --- a/app-modules/service-management/tests/RequestFactories/CreateServiceRequestRequestFactory.php +++ b/app-modules/service-management/tests/RequestFactories/CreateServiceRequestRequestFactory.php @@ -37,6 +37,7 @@ namespace AdvisingApp\ServiceManagement\Tests\RequestFactories; use AdvisingApp\Division\Models\Division; +use AdvisingApp\Prospect\Models\Prospect; use Worksome\RequestFactories\RequestFactory; use AdvisingApp\ServiceManagement\Models\ServiceRequestType; use AdvisingApp\ServiceManagement\Models\ServiceRequestStatus; @@ -50,6 +51,8 @@ public function definition(): array 'division_id' => Division::inRandomOrder()->first()?->id ?? Division::factory()->create()->id, 'status_id' => ServiceRequestStatus::factory()->create()->id, 'priority_id' => ServiceRequestPriority::factory()->create()->id, + 'respondent_id' => Prospect::factory()->create()->getKey(), + 'respondent_type' => app(Prospect::class)->getMorphClass(), 'type_id' => ServiceRequestType::factory()->create()->id, 'close_details' => $this->faker->sentence, 'res_details' => $this->faker->sentence, diff --git a/app-modules/service-management/tests/ServiceRequest/CreateServiceRequestTest.php b/app-modules/service-management/tests/ServiceRequest/CreateServiceRequestTest.php index c24c45bb55..1f3e4d52f9 100644 --- a/app-modules/service-management/tests/ServiceRequest/CreateServiceRequestTest.php +++ b/app-modules/service-management/tests/ServiceRequest/CreateServiceRequestTest.php @@ -42,6 +42,9 @@ use function Pest\Laravel\actingAs; use function Pest\Livewire\livewire; + +use AdvisingApp\Prospect\Models\Prospect; + use function PHPUnit\Framework\assertCount; use function Pest\Laravel\assertDatabaseHas; @@ -65,6 +68,9 @@ livewire(ServiceRequestResource\Pages\CreateServiceRequest::class) ->fillForm($request->toArray()) + ->fillForm([ + 'respondent_id' => Prospect::factory()->create()->getKey(), + ]) ->call('create') ->assertHasNoFormErrors(); @@ -78,6 +84,7 @@ 'status_id', 'priority_id', 'type_id', + 'respondent_id', ] )->toArray() ); @@ -161,6 +168,9 @@ livewire(ServiceRequestResource\Pages\CreateServiceRequest::class) ->fillForm($request->toArray()) + ->fillForm([ + 'respondent_id' => Prospect::factory()->create()->getKey(), + ]) ->call('create') ->assertHasNoFormErrors(); @@ -174,6 +184,7 @@ 'status_id', 'priority_id', 'type_id', + 'respondent_id', ] )->toArray() ); @@ -223,12 +234,15 @@ livewire(CreateServiceRequest::class) ->fillForm($request->toArray()) + ->fillForm([ + 'respondent_id' => Prospect::factory()->create()->getKey(), + ]) ->call('create') ->assertHasNoFormErrors(); assertCount(1, ServiceRequest::all()); - assertDatabaseHas(ServiceRequest::class, $request->except('division_id')->toArray()); + assertDatabaseHas(ServiceRequest::class, $request->except(['division_id', 'respondent_id'])->toArray()); $serviceRequest = ServiceRequest::first();