本文整理汇总了PHP中Setting::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::where方法的具体用法?PHP Setting::where怎么用?PHP Setting::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Setting
的用法示例。
在下文中一共展示了Setting::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSettings
/**
* @return array
*/
public function getSettings()
{
$obj = $this->setting->where('lang', getLang())->first() ?: $this->setting;
$jsonData = $obj->settings;
$setting = json_decode($jsonData, true);
if ($setting === null) {
$setting = array('site_title' => null, 'ga_code' => null, 'meta_keywords' => null, 'meta_description' => null);
}
return $setting;
}
示例2: store
/**
* Store a newly created resource in storage.
* POST /settings
*
* @return Response
*/
public function store()
{
$response = new stdClass();
$statusCode = 201;
$in = Input::only('email', 'subscription', 'phone');
$rules = array('email' => 'required | email | unique:settings', 'subscription' => 'boolean');
// 先檢查身分
$authId = Auth::user()->id;
$email = User::where(array('id' => $authId, 'email' => $in['email']))->pluck('email');
$vd = Validator::make($in, $rules);
if ($vd->fails()) {
$errs = $vd->messages();
$statusCode = 400;
if ($errs->has('email')) {
if ($email == $in['email']) {
$setting = Setting::where(array('email' => $in['email']));
if (!$setting->update($in)) {
$statusCode = 304;
$response = $errs->all();
} else {
$statusCode = 200;
}
}
}
} else {
if ($email == $in['email']) {
$response = Setting::firstOrCreate($in);
} else {
$statusCode = 403;
}
}
return Response::json($response, $statusCode);
}
示例3: set
/**
* Store setting
*
* @param $key
* @param $value
* @return bool
*/
public function set($key, $value)
{
/**
* Setup cache key
*/
$cacheKey = 'setting_' . md5($key);
/**
* Fetch from database
*/
$setting = Setting::where('key', '=', $key)->first();
/**
* If nothing was found, create a new object
*/
if (!is_object($setting)) {
$setting = new Setting();
}
/**
* Set the values
*/
$setting->setKey($key)->setValue($value)->save();
/**
* Expire the cache
*/
\Cache::forget($cacheKey);
return true;
}
示例4: getFeaturedAttribute
public function getFeaturedAttribute()
{
$featuredSetting = Setting::where('meta_key', '=', 'featured-doc')->first();
if ($featuredSetting) {
return $featuredSetting->meta_value == $this->id;
}
return false;
}
示例5: rule
/**
* @return string rule
*/
public static function rule($name = '')
{
$setting = Setting::where('name', '=', $name)->first();
if (is_object($setting[0])) {
return $setting->rule;
} else {
return false;
}
}
示例6: scopeKey
public function scopeKey($query, $key)
{
if (count(Setting::where('key', '=', $key)->get()) == 0) {
$setting = Setting::firstOrNew(['key' => $key]);
$setting->value = '';
$setting->save();
}
return $query->where('key', '=', $key);
}
示例7: get_tz
private function get_tz()
{
if (!$this->tz) {
$s = new Setting();
$s->where('name', 'site_timezone')->get();
$this->tz = $s->value;
}
return $this->tz;
}
示例8: getEmployeeSettingByEmployeeId
public function getEmployeeSettingByEmployeeId($employeeId = '')
{
if (empty($employeeId)) {
$employeeId = Session::get('userEmployeeId');
} else {
$employeeId = (int) $employeeId;
}
return Setting::where('employee_id', '=', $employeeId)->first();
}
示例9: Setting
function get_val($key)
{
$setting = new Setting();
//$query = $this->db->get_where($this->table, array("name" => $key));
//if ($query->num_rows() > 0){
//$row = $query->row();
//return $row->val;
//}
$result = $setting->where("name", $key)->get();
return $result->val;
}
示例10: putSetting
public function putSetting($name, $value = 0)
{
$setting = Setting::where('name', '=', $name)->first();
if (isset($setting->id)) {
Setting::where('name', $name)->update(array('value' => $value));
} else {
$this->name = $name;
$this->value = $value;
$this->save();
}
}
示例11: Setting
function after_content_create($content)
{
$s = new Setting();
$s->where('name', 'uploading_publish_on_captured_date')->get();
if ($s->exists() && $s->value === 'true') {
$fresh = new Content();
$fresh->get_by_id($content['id']);
$fresh->published_on = $content['captured_on']['utc'] ? $content['captured_on']['timestamp'] : 'captured_on';
$fresh->save();
}
}
示例12: sil
public function sil($id)
{
$settings = Setting::find($id);
if ($settings->active == 1) {
Setting::where('id', '=', 1)->update(['active' => 1]);
}
if ($settings->delete()) {
return Redirect::back()->withInput()->with(array('basarili' => 'Ayar başarı ile silindi.'));
} else {
return Redirect::back()->withInput()->with(array('hata' => 'Ayar başarı ile silinemedi.'));
}
}
示例13: postIndex
public function postIndex()
{
//dd(Input::all());
$user = Auth::user()->id;
$setting = Setting::findOrFail(Input::get('id'));
$validator = Validator::make($data = Input::all(), Setting::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$settings = array('language' => Input::get('language'), 'currency_id' => Input::get('country_id'));
$item = Setting::where('id', '=', Input::get('id'))->update($settings);
return Redirect::to('settings')->with('success', Lang::get('settings.message.success.update'));
}
示例14: decrease
public static function decrease($name = false)
{
if (!$name) {
return false;
}
$set = Setting::where('name', $name)->first();
if (is_object($set)) {
$set->value = $set->value > 0 ? $set->value - 1 : 0;
$set->save();
$set->touch();
} else {
Setting::create(array('name' => $name, 'value' => 0));
}
return true;
}
示例15: update
function update()
{
$setting = new Setting();
// upload photo
$config['upload_path'] = 'assets/upload';
$config['allowed_types'] = 'gif|jpg|png|bmp';
$this->load->library("upload", $config);
if ($this->upload->do_upload("logo")) {
$data = $this->upload->data();
//print_r($data["file_name"]);
//$setting->logo = $data["file_name"];
} else {
//print_r($this->upload->display_errors());
}
$setting->where('id', $this->input->post('id'))->update(array('logo' => $data["file_name"], 'company_name' => $this->input->post('company_name'), 'address' => $this->input->post('address'), 'phone' => $this->input->post('phone'), 'fax' => $this->input->post('fax'), 'email' => $this->input->post('email'), 'city' => $this->input->post('city'), 'no_npwp' => $this->input->post('no_npwp')));
$this->session->set_flashdata('message', 'Config Update successfuly.');
redirect('settings/edit/1');
}