From b629150a7302b8d7d1eeb734db57b22088160e76 Mon Sep 17 00:00:00 2001 From: Lupu Gheorghe Date: Tue, 14 May 2024 17:40:37 +0300 Subject: [PATCH] Add donation amount config --- app/Http/Controllers/ProjectController.php | 10 +- config/app.php | 3 + lang/ro/custom_validation.php | 4 + .../js/Components/modals/DonateModal.vue | 116 +++++++++--------- resources/js/Pages/Public/Website/Contact.vue | 64 +++++----- 5 files changed, 101 insertions(+), 96 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 3f4786aa..fe5e4928 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -11,6 +11,7 @@ use App\Http\Filters\ProjectDatesFilter; use App\Http\Filters\ProjectStatusFilter; use App\Http\Filters\SearchFilter; +use App\Http\Requests\Project\DonateRequest; use App\Http\Resources\Collections\ProjectCardCollection; use App\Http\Resources\Project\ShowProjectResource; use App\Http\Sorts\ProjectDonationsCountSort; @@ -84,14 +85,9 @@ public function show(Project $project) ]); } - public function donate(Project $project, Request $request) + public function donate(Project $project, DonateRequest $request) { - $attributes = $request->validate([ - 'amount' => ['required', 'numeric', 'min:1'], - 'terms' => ['required', 'accepted'], - 'email' => ['required', 'email'], - 'name' => ['required'], - ]); + $attributes = $request->validated(); try { [$lastName, $firstName] = explode(' ', $attributes['name']); diff --git a/config/app.php b/config/app.php index e944efcc..9734887c 100644 --- a/config/app.php +++ b/config/app.php @@ -187,4 +187,7 @@ // 'Example' => App\Facades\Example::class, ])->toArray(), + 'min_donation' => env('MIN_DONATION', 10), + 'max_donation' => env('MAX_DONATION', 10000), + ]; diff --git a/lang/ro/custom_validation.php b/lang/ro/custom_validation.php index 38947d49..43eff6dd 100644 --- a/lang/ro/custom_validation.php +++ b/lang/ro/custom_validation.php @@ -38,5 +38,9 @@ 'end' => [ 'after' => 'Data de finalizare a proiectului trebuie să fie după data de început.', ], + 'donate' => [ + 'min' => 'Suma minimă de donație este de :min RON.', + 'max' => 'Suma maximă de donație este de :max RON.', + ], ], ]; diff --git a/resources/js/Components/modals/DonateModal.vue b/resources/js/Components/modals/DonateModal.vue index 6a35fcd1..b5e27e66 100644 --- a/resources/js/Components/modals/DonateModal.vue +++ b/resources/js/Components/modals/DonateModal.vue @@ -100,7 +100,7 @@ id="amount" type="number" v-model="guestForm.amount" - :error="guestForm.errors.amount" + :error="guestForm.errors.amount || errors?.amount" /> @@ -113,7 +113,7 @@ id="amount" type="number" v-model="authForm.amount" - :error="authForm.errors.amount" + :error="authForm.errors.amount || errors?.amount" /> @@ -174,60 +174,62 @@ diff --git a/resources/js/Pages/Public/Website/Contact.vue b/resources/js/Pages/Public/Website/Contact.vue index 7faa8ebd..c7f9c702 100644 --- a/resources/js/Pages/Public/Website/Contact.vue +++ b/resources/js/Pages/Public/Website/Contact.vue @@ -9,41 +9,41 @@

{{ $t('send_message') }}

{{ $t('send_message_info') }}

-
- - + + + + + + + + + + + - - + + + + + + + + + + - -