Пример #1
0
 public static function firstVersion($action)
 {
     return Version::query()->where('action', 'LIKE', $action)->where('is_active', '=', 1)->orderByRaw('RAND()')->first();
 }
Пример #2
0
 /**
  * @param $controller
  * @param $action
  * @param ...$args
  * @throws \Exception
  */
 public static function sync($controller, $action, ...$args)
 {
     $version = Version::query()->where('controller', '=', $controller)->where('action', '=', $action)->where('is_active', 1)->first();
     if (empty($version)) {
         throw new \Exception('Impossible de trouver une version active pour le mail ' . $action);
     }
     $mail = ModelMail::create(['mail_status_id' => self::STATUS_FILED, 'mail_version_id' => $version->getKey(), 'args' => json_encode($args)]);
     //On envoie le mail directement
     $class = self::class;
     $business = new $class($mail->mail_id);
     $business->send();
     return $mail->mail_id;
 }