From 0cc495acabfdd0b2e609e77e24c8da753326df22 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Tue, 22 Feb 2022 10:42:20 +0100 Subject: [PATCH] #38 - cr fix --- .../Listeners/HandleCreatedVacationRequest.php | 2 +- .../SendCreatedVacationRequestNotification.php | 4 ++-- app/Eloquent/Models/VacationRequest.php | 6 +++--- .../Http/Requests/VacationRequestRequest.php | 4 ++-- database/factories/VacationRequestFactory.php | 4 ++-- ...2_01_26_100039_create_vacation_requests_table.php | 2 +- resources/js/Pages/VacationRequest/Create.vue | 12 ++++++------ tests/Feature/VacationRequestTest.php | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/Domain/Listeners/HandleCreatedVacationRequest.php b/app/Domain/Listeners/HandleCreatedVacationRequest.php index ee7b691..bdc0824 100644 --- a/app/Domain/Listeners/HandleCreatedVacationRequest.php +++ b/app/Domain/Listeners/HandleCreatedVacationRequest.php @@ -20,7 +20,7 @@ class HandleCreatedVacationRequest { $vacationRequest = $event->vacationRequest; - if ($vacationRequest->shouldSkipFlow()) { + if ($vacationRequest->hasFlowSkipped()) { $this->stateManager->approve($vacationRequest); return; diff --git a/app/Domain/Listeners/SendCreatedVacationRequestNotification.php b/app/Domain/Listeners/SendCreatedVacationRequestNotification.php index bd31e9b..56bd726 100644 --- a/app/Domain/Listeners/SendCreatedVacationRequestNotification.php +++ b/app/Domain/Listeners/SendCreatedVacationRequestNotification.php @@ -19,9 +19,9 @@ class SendCreatedVacationRequestNotification $vacationRequest = $event->vacationRequest; if ($vacationRequest->creator->is($vacationRequest->user)) { - $event->vacationRequest->user->notify(new VacationRequestCreatedNotification($event->vacationRequest)); + $vacationRequest->user->notify(new VacationRequestCreatedNotification($vacationRequest)); } else { - $event->vacationRequest->user->notify(new VacationRequestCreatedOnEmployeeBehalf($event->vacationRequest)); + $vacationRequest->user->notify(new VacationRequestCreatedOnEmployeeBehalf($vacationRequest)); } } } diff --git a/app/Eloquent/Models/VacationRequest.php b/app/Eloquent/Models/VacationRequest.php index f373894..da28c1a 100644 --- a/app/Eloquent/Models/VacationRequest.php +++ b/app/Eloquent/Models/VacationRequest.php @@ -22,7 +22,7 @@ use Toby\Domain\Enums\VacationType; * @property Carbon $from * @property Carbon $to * @property string $comment - * @property boolean $skip_flow + * @property bool $flow_skipped * @property User $user * @property User $creator * @property YearPeriod $yearPeriod @@ -76,9 +76,9 @@ class VacationRequest extends Model $this->save(); } - public function shouldSkipFlow(): bool + public function hasFlowSkipped(): bool { - return $this->skip_flow; + return $this->flow_skipped; } public function scopeStates(Builder $query, array $states): Builder diff --git a/app/Infrastructure/Http/Requests/VacationRequestRequest.php b/app/Infrastructure/Http/Requests/VacationRequestRequest.php index b3d0c20..f69ef10 100644 --- a/app/Infrastructure/Http/Requests/VacationRequestRequest.php +++ b/app/Infrastructure/Http/Requests/VacationRequestRequest.php @@ -20,7 +20,7 @@ class VacationRequestRequest extends FormRequest "type" => ["required", new Enum(VacationType::class)], "from" => ["required", "date_format:Y-m-d", new YearPeriodExists()], "to" => ["required", "date_format:Y-m-d", new YearPeriodExists()], - "skipFlow" => ["nullable", "boolean"], + "flowSkipped" => ["nullable", "boolean"], "comment" => ["nullable"], ]; } @@ -36,7 +36,7 @@ class VacationRequestRequest extends FormRequest "to" => $this->get("to"), "year_period_id" => YearPeriod::findByYear(Carbon::create($from)->year)->id, "comment" => $this->get("comment"), - "skip_flow" => $this->boolean("skipFlow"), + "flow_skipped" => $this->boolean("flowSkipped"), ]; } } diff --git a/database/factories/VacationRequestFactory.php b/database/factories/VacationRequestFactory.php index 2c5e65f..a0fb00c 100644 --- a/database/factories/VacationRequestFactory.php +++ b/database/factories/VacationRequestFactory.php @@ -24,9 +24,9 @@ class VacationRequestFactory extends Factory return [ "user_id" => User::factory(), - "creator_id" => fn(array $attributes) => $attributes["user_id"], + "creator_id" => fn(array $attributes): int => $attributes["user_id"], "year_period_id" => YearPeriod::factory(), - "name" => fn(array $attributes) => $this->generateName($attributes), + "name" => fn(array $attributes): string => $this->generateName($attributes), "type" => $this->faker->randomElement(VacationType::cases()), "state" => $this->faker->randomElement(VacationRequestState::cases()), "from" => $from, diff --git a/database/migrations/2022_01_26_100039_create_vacation_requests_table.php b/database/migrations/2022_01_26_100039_create_vacation_requests_table.php index 367df76..d9efcc7 100644 --- a/database/migrations/2022_01_26_100039_create_vacation_requests_table.php +++ b/database/migrations/2022_01_26_100039_create_vacation_requests_table.php @@ -22,7 +22,7 @@ return new class() extends Migration { $table->date("from"); $table->date("to"); $table->text("comment")->nullable(); - $table->boolean("skip_flow")->default(false); + $table->boolean("flow_skipped")->default(false); $table->timestamps(); }); } diff --git a/resources/js/Pages/VacationRequest/Create.vue b/resources/js/Pages/VacationRequest/Create.vue index 10405a7..d36105c 100644 --- a/resources/js/Pages/VacationRequest/Create.vue +++ b/resources/js/Pages/VacationRequest/Create.vue @@ -233,19 +233,19 @@
@@ -319,7 +319,7 @@ export default { to: null, type: props.vacationTypes[0], comment: null, - skipFlow: false, + flowSkipped: false, }) const estimatedDays = ref([]) diff --git a/tests/Feature/VacationRequestTest.php b/tests/Feature/VacationRequestTest.php index 243dd1e..d3a30c6 100644 --- a/tests/Feature/VacationRequestTest.php +++ b/tests/Feature/VacationRequestTest.php @@ -150,7 +150,7 @@ class VacationRequestTest extends FeatureTestCase "from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(), "comment" => "Comment for the vacation request.", - "skipFlow" => 1, + "flowSkipped" => true, ]) ->assertSessionHasNoErrors();