]> _ Git - bastide-resah.git/commitdiff
wait #7178 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 6 Nov 2024 16:05:04 +0000 (17:05 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 6 Nov 2024 16:05:04 +0000 (17:05 +0100)
app/Http/Controllers/FluidbookController.php
app/Models/User.php

index 4ba1e06f8ddad2821831d853f0a8f8e91e3ed28f..39471ef35bf600f990ad948aac55d904c2882950 100644 (file)
@@ -56,7 +56,11 @@ class FluidbookController extends Controller
             $client->enabled = false;
             $client->save();
 
-            User::withoutGlobalScopes()->find(3)->notify(new ResahNotification(ResahNotification::ACCOUNT_CREATED, $client));
+            try {
+                User::notifyAdmins(new ResahNotification(ResahNotification::ACCOUNT_CREATED, $client), 'client');
+            } catch (\Exception $exception) {
+
+            }
 
             return response()->json(['success' => 'ok'])->setStatusCode(200);
 
@@ -187,7 +191,7 @@ class FluidbookController extends Controller
         $order->saveQuietly();
 
         $user->notify(new ResahNotification(ResahNotification::QUOTE_REQUEST_SENT, $order));
-        User::withoutGlobalScopes()->find(3)->notify(new ResahNotification(ResahNotification::QUOTE_REQUEST, $order));
+        User::notifyAdmins(new ResahNotification(ResahNotification::QUOTE_REQUEST, $order), 'order');
 
         return response()->json(['success' => 'ok', 'order' => $order->id, 'subTotal' => $total, 'taxes' => $cumul_tva, 'total' => $total + $cumul_tva])->setStatusCode(200);
 
index 1187a8da53c55dae3d7bc21026722152d404c563..e8f8c8b86ea5526ecb2393496cbafb759a8f6e68 100644 (file)
@@ -3,9 +3,21 @@
 namespace App\Models;
 
 use Cubist\Backpack\Magic\Models\CubistMagicAuthenticatable;
+use Illuminate\Notifications\Notification;
 
 
 class User extends CubistMagicAuthenticatable
 {
+    public static function notifyAdmins(Notification $notification, $type)
+    {
+        foreach (User::withoutGlobalScopes()->get() as $u) {
+            if (stristr($u->email, '@cubedesigners.com')) {
+                //continue;
+            }
+            if ($u->hasPermissionTo($type . ':notified')) {
+                $u->notify($notification);
 
+            }
+        }
+    }
 }