public function getSetting($name) { if (is_null($this->setting)) { $this->setting = $this->settings->where('id', 1)->fetch(); } return $this->setting[$name]; }
public function configMail() { //KONFIGURASI INI SESUAIKAN DENGAN DATABASE KONFIGURASI EMAIL $mail = Setting::where('type', 'mail')->lists('value', 'setting'); $config = array('driver' => $mail['mail_driver'], 'host' => $mail['mail_host'], 'port' => $mail['mail_port'], 'from' => array('address' => $mail['mail_address'], 'name' => $mail['mail_name']), 'encryption' => 'tls', 'username' => $mail['mail_username'], 'password' => $mail['mail_password'], 'sendmail' => '/usr/sbin/sendmail -bs', 'pretend' => false); return $config; }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request) { $langs = get_langs(); foreach ($langs as $lang) { $datas = $request->input($lang->code); if (is_array($datas) || is_object($datas)) { foreach ($datas as $key => $value) { $value = is_array($value) ? serialize($value) : $value; $args = ['lang_id' => $lang->id, 'key' => $key, 'value' => $value]; $cond = Setting::where('key', $key)->where('lang_id', $lang->id); if ($cond->count() > 0) { $cond->update(['value' => $value]); } else { $meta = new Setting(); $meta->lang_id = $lang->id; $meta->key = $key; $meta->value = $value; $meta->save(); } } } } return redirect()->back()->with('Mess', 'Cập nhật thành công'); }
public function actionDefault() { $this->row = $this->model->where('language_id', $this->webLanguage)->fetch(); }
function get_setting($key, $lang_id = null) { $lang_id = $lang_id == null ? default_lang_id() : $lang_id; $result = \App\Model\Setting::where('key', $key)->where('lang_id', $lang_id)->get(['value'])->first(); if (empty($result)) { return null; } else { $value = $result->value; $value = is_serialized($value) ? unserialize($value) : $value; return $value; } }