From 41e98192d1f8d84060ff79d3ecc3cf81afa13b44 Mon Sep 17 00:00:00 2001 From: Chri$ Date: Mon, 14 Oct 2024 18:33:31 +0200 Subject: [PATCH 1/5] feat:[LAR-60] Add send mail for decline article and fix unsend mail for approve article --- app/Http/Livewire/Modals/DeclinedArticle.php | 60 +++++++++ app/Notifications/SendApprovedArticle.php | 3 +- app/Notifications/SendDeclinedArticle.php | 35 +++++ resources/views/articles/show.blade.php | 112 ++++++++-------- .../views/components/danger-button.blade.php | 2 +- .../components/forms/address-form.blade.php | 122 ++++++++++++++++++ .../views/components/forms/errors.blade.php | 9 ++ .../views/components/forms/input.blade.php | 3 + .../views/components/forms/label.blade.php | 8 ++ .../views/components/forms/textarea.blade.php | 3 + .../modals/declined-article.blade.php | 28 ++++ 11 files changed, 330 insertions(+), 55 deletions(-) create mode 100644 app/Http/Livewire/Modals/DeclinedArticle.php create mode 100644 app/Notifications/SendDeclinedArticle.php create mode 100755 resources/views/components/forms/address-form.blade.php create mode 100755 resources/views/components/forms/errors.blade.php create mode 100755 resources/views/components/forms/input.blade.php create mode 100755 resources/views/components/forms/label.blade.php create mode 100755 resources/views/components/forms/textarea.blade.php create mode 100644 resources/views/livewire/modals/declined-article.blade.php diff --git a/app/Http/Livewire/Modals/DeclinedArticle.php b/app/Http/Livewire/Modals/DeclinedArticle.php new file mode 100644 index 00000000..3b5cf412 --- /dev/null +++ b/app/Http/Livewire/Modals/DeclinedArticle.php @@ -0,0 +1,60 @@ + 'required|string|min:6', + 'description' => 'required|string', + ]; + + public function mount(int $id): void + { + $this->article = Article::find($id); + } + + public static function modalMaxWidth(): string + { + return 'xl'; + } + + public function declined(): void + { + $data = $this->validate(); + + $this->authorize(ArticlePolicy::DISAPPROVE, $this->article); + + $this->article->update(['declined_at' => now()]); // @phpstan-ignore-line + + Cache::forget('post-'.$this->article->id); // @phpstan-ignore-line + + $this->article->user->notify(new SendDeclinedArticle($this->article, $data)); // @phpstan-ignore-line + + session()->flash('status', __('L\'article a été décliné et le mail a été envoyé à l\'auteur pour le notifier.')); + + $this->redirectRoute('articles'); + } + + + public function render() + { + return view('livewire.modals.declined-article'); + } +} diff --git a/app/Notifications/SendApprovedArticle.php b/app/Notifications/SendApprovedArticle.php index d460e3d9..96dd8de7 100644 --- a/app/Notifications/SendApprovedArticle.php +++ b/app/Notifications/SendApprovedArticle.php @@ -6,11 +6,10 @@ use App\Models\Article; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; -final class SendApprovedArticle extends Notification implements ShouldQueue +final class SendApprovedArticle extends Notification { use Queueable; diff --git a/app/Notifications/SendDeclinedArticle.php b/app/Notifications/SendDeclinedArticle.php new file mode 100644 index 00000000..044fa949 --- /dev/null +++ b/app/Notifications/SendDeclinedArticle.php @@ -0,0 +1,35 @@ +subject(__('Article Décliné ❌.')) + ->greeting(__('Article Décliné : '.$this->data['raison'])) + ->line(__('Nous avons le regret de vous informer que votre article a été décliné.')) + ->line($this->data['description']) + ->action(__('Voir mon article'), route('articles.show', $this->article)) + ->line(__('Merci d\'avoir utilisé Laravel Cameroun.!')); + } +} diff --git a/resources/views/articles/show.blade.php b/resources/views/articles/show.blade.php index b6d45894..769bea21 100644 --- a/resources/views/articles/show.blade.php +++ b/resources/views/articles/show.blade.php @@ -11,14 +11,14 @@ @endphp
-