From bfb5bc66990a863cba9a228bf3b99c066ed3a95f Mon Sep 17 00:00:00 2001 From: Artem Otliaguzov Date: Thu, 8 Aug 2024 14:20:20 +0200 Subject: [PATCH] fix notification --- app/Http/Controllers/EntityHfdController.php | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/EntityHfdController.php b/app/Http/Controllers/EntityHfdController.php index bacc717..3d26ca9 100644 --- a/app/Http/Controllers/EntityHfdController.php +++ b/app/Http/Controllers/EntityHfdController.php @@ -3,8 +3,13 @@ namespace App\Http\Controllers; use App\Facades\HfdTag; +use App\Mail\NewIdentityProvider; use App\Models\Entity; +use App\Notifications\EntityAddedToHfd; +use App\Notifications\EntityDeletedFromHfd; +use App\Services\NotificationService; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Mail; class EntityHfdController extends Controller { @@ -29,21 +34,16 @@ public function update(Entity $entity) return $entity; }); + if ($entity->hfd) { + NotificationService::sendOperatorNotification($entity->operators, new EntityAddedToHfd($entity)); + } else { + Mail::to(config('mail.ra.address'))->send(new NewIdentityProvider($entity)); + NotificationService::sendOperatorNotification($entity->operators, new EntityDeletedFromHfd($entity)); + } + $status = $entity->hfd ? 'hfd' : 'no_hfd'; $color = $entity->hfd ? 'red' : 'green'; - //TODO change HfD status (not working) - /* if ($entity->hfd) { - GitAddToHfd::dispatch($entity, Auth::user()); - Notification::send($entity->operators, new EntityAddedToHfd($entity)); - Notification::send(User::activeAdmins()->select('id', 'email')->get(), new EntityAddedToHfd($entity)); - } else { - GitDeleteFromHfd::dispatch($entity, Auth::user()); - Mail::to(config('mail.ra.address'))->send(new NewIdentityProvider($entity)); - Notification::send($entity->operators, new EntityDeletedFromHfd($entity)); - Notification::send(User::activeAdmins()->select('id', 'email')->get(), new EntityDeletedFromHfd($entity)); - }*/ - return redirect() ->route('entities.show', $entity) ->with('status', __("entities.$status"))