Exemple #1
0
 function addOrUpdate(array $data = array(), $group = 'autoload')
 {
     if (!empty($data)) {
         foreach ($data as $key => $value) {
             $setting = Setting::firstOrNew(['name' => $key]);
             if (is_array($value) || is_object($value)) {
                 $setting->value = serialize($value);
             } else {
                 $setting->value = $value;
             }
             $setting->autoload = $group;
             $setting->save();
         }
     }
 }
Exemple #2
0
 /**
  * Get Template setting from database
  * @param $templateKey
  * @param $param
  * @return \stdClass
  */
 function getEmailTemplate($templateKey, $param)
 {
     $data = new \stdClass();
     $email = SystemSetting::email()->first();
     $emailSet = $email->value;
     $data->from_name = $emailSet['name'];
     $data->from_email = $emailSet['email'];
     $subjectKey = $templateKey . '_subject';
     $templateSet = SystemSetting::template()->first();
     $emailTemplate = $templateSet->value;
     if (isset($emailTemplate[$subjectKey]) and isset($emailTemplate[$templateKey])) {
         $data->subject = $emailTemplate[$subjectKey];
         $data->body = str_replace(array_keys($param), array_values($param), $emailTemplate[$templateKey]);
     }
     return $data;
 }