$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);
$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);
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);
+ }
+ }
+ }
}