Example #1
0
 public static function sendTemplate($path, $params, $locale = null)
 {
     if (!isset($params[self::EMAIL_FROM])) {
         $params[self::EMAIL_FROM] = appEmail();
     }
     if (!isset($params[self::EMAIL_FROM_NAME])) {
         $params[self::EMAIL_FROM_NAME] = appName();
     }
     if (!isset($params[self::EMAIL_SUBJECT])) {
         $params[self::EMAIL_SUBJECT] = trans('label.message_from_') . appName();
     }
     if (!isset($params[self::EMAIL_TO])) {
         return false;
     }
     if (!empty($locale)) {
         $params['site_locale'] = $locale;
     }
     $locale = $params['site_locale'];
     try {
         Mail::send('emails.' . $path . '.' . $locale, $params, function ($message) use($params) {
             $message->from($params[MailHelper::EMAIL_FROM], $params[MailHelper::EMAIL_FROM_NAME]);
             $message->subject($params[MailHelper::EMAIL_SUBJECT]);
             if (isset($params[MailHelper::EMAIL_TO_NAME])) {
                 $message->to($params[MailHelper::EMAIL_TO]);
             } else {
                 $message->to($params[MailHelper::EMAIL_TO], $params[MailHelper::EMAIL_TO_NAME]);
             }
         });
         return count(Mail::failures()) > 0;
     } catch (\Exception $ex) {
         return false;
     }
 }
Example #2
0
 public function __construct(Request $request)
 {
     parent::__construct($request);
     $this->theme = Theme::byRequest();
     $this->theme->register($this->is_auth);
     $this->globalViewParams = ['site_locale' => $this->localeCode, 'site_version' => appVersion(), 'site_name' => appName(), 'site_logo' => appLogo(), 'site_keywords' => appKeywords(), 'site_short_name' => appShortName(), 'site_description' => appDescription(), 'site_author' => appAuthor(), 'site_email' => appEmail(), 'site_domain' => appDomain(), 'site_home_url' => homeUrl(), 'is_auth' => $this->is_auth, 'auth_user' => $this->auth_user, 'session_id' => $request->session()->getId()];
     foreach ($this->globalViewParams as $key => $value) {
         view()->share($key, $value);
     }
 }
Example #3
0
 protected function __construct($type)
 {
     $this->name = $this::NAME;
     $this->view = $this::VIEW;
     $this->type = $type;
     $this->viewPath = empty($type) ? $this->view . '.' : $this->type . '.' . $this->view . '.';
     $this->assetPath = empty($type) ? 'assets/' . $this->view . '/' : 'assets/' . $this->type . '/' . $this->view . '/';
     $this->header = new TextQueue();
     $this->footer = new TextQueue();
     $this->libJsQueue = new JsQueue();
     $this->extJsQueue = new JsQueue();
     $this->libCssQueue = new CssQueue();
     $this->extCssQueue = new CssQueue();
     $this->titleRoot = appName();
     $this->title = appName();
     $this->description = appDescription();
     $this->applicationName = appName();
     $this->author = appAuthor() . ' (' . appEmail() . ')';
     $this->generator = frameworkVersion();
     $this->keywords = appKeywords();
 }