where('is_admin', 1)->get(); // // foreach ($admins as $admin) { // if ($admin->contact_method === 1 || $admin->im_type === 0) { // Mail::send( // $admin->email, // $title, // $template, // [ // 'user' => $admin, // 'title' => $title, // 'text' => $msg, // ] // ); // } else { // IM::send($admin->im_value, $msg, $admin->im_type); // } // } // } public static function notifyAdmin($title = '', $msg = '', $template = 'warn.tpl', $scene = ''): void { $admins = (new User())->where('is_admin', 1)->get(); foreach ($admins as $admin) { if ($admin->contact_method === 1 || $admin->im_type === 0) { MailHub::admin($title, [ 'user' => $admin, 'title' => $title, 'text' => $msg, ])->to($admin->email); } else { IM::send($admin->im_value, $msg, $admin->im_type); } } } /** * @throws GuzzleException$scene * @throws TelegramSDKException * @throws ClientExceptionInterface */ // public static function notifyUser($user, $title = '', $msg = '', $template = 'warn.tpl'): void // { // if ($user->contact_method === 1 || $user->im_type === 0) { // $array = [ // 'user' => $user, // 'title' => $title, // 'text' => $msg, // ]; // // (new EmailQueue())->add($user->email, $title, $template, $array); // } else { // IM::send($user->im_value, $msg, $user->im_type); // } // } public static function notifyUser($user, $title = '', $msg = '', $template = 'warn.tpl', $scene = ''): void { if ($user->contact_method === 1 || $user->im_type === 0) { $array = [ 'user' => $user, 'title' => $title, 'text' => $msg, ]; (new EmailQueue())->add($user->email, $title, $template, $array, $scene); } else { IM::send($user->im_value, $msg, $user->im_type); } } /** * @throws GuzzleException * @throws TelegramSDKException */ // public static function notifyAllUser($title = '', $msg = '', $template = 'warn.tpl', $scene = ''): void // { // $users = User::all(); // // foreach ($users as $user) { // if ($user->contact_method === 1 || $user->im_type === 0) { // $array = [ // 'user' => $user, // 'title' => $title, // 'text' => $msg, // ]; // // (new EmailQueue())->add($user->email, $title, $template, $array); // } else { // IM::send($user->im_value, $msg, $user->im_type); // } // } // } public static function notifyAllUser($title = '', $msg = '', $template = 'warn.tpl', $scene = ''): void { $users = User::all(); foreach ($users as $user) { if ($user->contact_method === 1 || $user->im_type === 0) { $array = [ 'user' => $user, 'title' => $title, 'text' => $msg, ]; (new EmailQueue())->add($user->email, $title, $template, $array, $scene); } else { IM::send($user->im_value, $msg, $user->im_type); } } } }