本文整理汇总了PHP中Setting::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::find方法的具体用法?PHP Setting::find怎么用?PHP Setting::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Setting
的用法示例。
在下文中一共展示了Setting::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getKey
static function getKey($key)
{
if (self::$cache === null) {
self::$cache = Model::pluck(Setting::find('1=1'), 'value', 'key');
}
return self::$cache[$key];
}
示例2: postreg
public function postreg()
{
//if($slug == Setting::find(3)->value){
if (Auth::check()) {
return View::make('admin.index');
} else {
$input = Input::all();
$validator = Validator::make($input, array('username' => 'required|unique:Users,username|between:5,20', 'email' => 'required|email', 'password' => 'required|between:5,50', 'code' => 'required'));
if ($validator->fails()) {
$messages = $validator->messages();
$out = '';
foreach ($messages->all() as $message) {
$out .= $message . '<Br>';
}
return View::make('admin.register')->with('error', $out);
} else {
if (Input::get('code') !== Setting::find(5)->value) {
return View::make('admin.register')->with('error', 'Invalid Code');
}
$user = new User();
$user->email = Input::get('email');
$user->username = Input::get('username');
$user->password = Hash::make(Input::get('password'));
$user->status = 'active';
$user->save();
Auth::login($user);
return Redirect::to('/admin/' . Setting::find(3)->value);
}
}
//}else{
//App::abort('404');
//}
}
示例3: sendEmail
public function sendEmail()
{
App::import('Model', 'Setting');
$setting_model = new Setting();
$setting = $setting_model->find('first', array('fields' => 'email_contact'));
$email_contact = empty($setting['Setting']['email_contact']) ? '' : $setting['Setting']['email_contact'];
if (!empty($this->data['Contato'])) {
$contato = $this->data['Contato'];
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail();
$Email->config('smtp');
$Email->template('contato', null);
$Email->viewVars(array('contato' => $contato));
$Email->to($email_contact);
$Email->emailFormat('html');
$Email->subject("Cartório NET - Contato: " . $contato['subject']);
$success = false;
try {
if ($Email->send()) {
$success = true;
} else {
$success = false;
}
} catch (Exception $e) {
// pr($e);die;
$success = false;
}
return $success;
}
return false;
}
示例4: update
public function update($id)
{
$data = Setting::find($id);
$data->email_sender = Input::get('email');
$data->protokol = Input::get('protokol');
$data->port = Input::get('port');
$data->host = Input::get('host');
$data->user_email = Input::get('user');
$data->pass_email = Input::get('pass');
$data->save();
if ($data->save()) {
Session::flash('messages', '
<div class="alert alert-info alert-dismissable" id="notif">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Keterangan</strong><br>
Setting berhasil disimpan
</div>
');
} else {
Session::flash('messages', '
<div class="alert alert-danger alert-dismissable" id="notif">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Peringatan...</strong><br>
Settig gagal disimpan
</div>
');
}
return Redirect::to('admin/setting/email');
}
示例5: edit
/**
* Show the form for editing the specified resource.
* GET /settings/{id}/edit
*
* @param int $id
* @return Response
*/
public function edit($id = NULL)
{
parent::show();
$banner = $this->banner;
$path = "/img/settings";
$setting = Setting::find($id);
return View::make('settings.edit', compact('setting', 'path', 'banner'));
}
示例6: getSettings
public static function getSettings()
{
static $static_cache = NULL;
if (!$static_cache) {
$static_cache = Setting::find(1);
}
return $static_cache;
}
示例7: get_index
public function get_index()
{
$articles = cmsHelper::getAllArticles($message, true);
//get the article limit size
$articles = $articles->where('status', '=', 1)->paginate(Setting::find(2)->value);
$dbquery = $articles;
$articles = cmsHelper::bakeArticleForViewers($articles->results);
return View::make('visitor.index', array("articles" => $articles, 'dbquery' => $dbquery));
}
示例8: get_index
public function get_index($authorname)
{
$user = User::where('username', '=', $authorname)->first();
//get the article limit size
$articles = Article::where('author_id', '=', $user->id)->paginate(Setting::find(2)->value);
$dbquery = $articles;
$articles = cmsHelper::bakeArticleForViewers($articles->results);
return View::make('visitor.index', array("articles" => $articles, 'dbquery' => $dbquery, 'message' => 'Showing all articles by ' . $user->displayname));
}
示例9: updateSetting
/**
* update() Update a database setting
* @var string, Current setting name to update
* @var string, setting name
* @var string, New value for the setting
*
* @return boolean
*/
public static function updateSetting($name, $newvalue)
{
//All clear now, now to the fun stuff. We are going to pull our current setting
$setting = Setting::find($name);
//Declare our new property values
$setting->value = $newvalue;
//Finally update the db
$setting->save();
//The response everyone is looking for :)
return true;
}
示例10: getAdjustedArticleContent
public function getAdjustedArticleContent()
{
$trim = Setting::find(1)->value;
if ($trim != 0 && strlen($this->content) > $trim) {
$text = substr($this->content, 0, $trim) . '...';
} else {
$text = $this->content;
}
$tidy = new tidy();
$tidy->parseString($text, array('show-body-only' => true), 'utf8');
$tidy->cleanRepair();
return $tidy . '<a href="' . $this->getArticleUrl() . '">[ Continue reading ]</a>';
}
示例11: massUpdate
/**
* Update the settings in mass
*
* @param array $settingsToUpdate Setting name => value array
*
* @return integer Number of settings that were affected
*/
public static function massUpdate($settingsToUpdate)
{
$affected = 0;
foreach ($settingsToUpdate as $name => $value) {
$setting = Setting::find($name);
if (!$setting) {
continue;
}
// Only update if there is a difference
if ($setting->value != $value && $setting->save()) {
$affected++;
}
}
return $affected;
}
示例12: post_index
public function post_index($category, $title, $id, $idparent = null)
{
$id = !is_null($idparent) ? $idparent : $id;
Input::flash();
//check if unregistered users' are allowed to post
if (Setting::find(5)->value != 1 && Auth::guest()) {
echo " Only Registered user's can post comments";
die;
}
if (Setting::find(6)->value < strlen(Input::get('content'))) {
echo " Comment size cannot be greater than " . Setting::find(6)->value . ' characters ';
die;
}
//Add rules here
$rules = array('name' => 'required|max:100', 'email' => 'required|email', 'content' => 'required');
//Get all inputs fields
$input = Input::all();
//Apply validaiton rules
$validation = Validator::make($input, $rules);
if ($validation->fails()) {
return Redirect::to($_SERVER['PATH_INFO'] . '#commentheading')->with_errors($validation);
}
$newComment = new Comment();
$newComment->name = Input::get('name');
$newComment->email = Input::get('email');
$newComment->content = Input::get('content');
$newComment->article_id = $id;
$newComment->approved = 1;
$blacklists = explode(',', Setting::find(8)->value);
foreach ($blacklists as $blword) {
if (false !== strpos($newComment->content, $blword)) {
$newComment->approved = 0;
break;
}
}
$newComment->save();
Input::flush();
return Redirect::to($_SERVER['PATH_INFO'] . '#comment-' . $newComment->id);
}
示例13: send_email
public function send_email($id)
{
$solicitacao = $this->getSolicitacao($id);
App::import('Model', 'Setting');
$settingModel = new Setting();
$setting = $settingModel->find('first', array('fields' => 'email_contact'));
$email_contact = empty($setting['Setting']['email_contact']) ? '' : $setting['Setting']['email_contact'];
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail();
$Email->config('smtp');
$Email->template('servicos', null);
$Email->viewVars(array('solicitacao' => $solicitacao));
$Email->to($email_contact);
$Email->emailFormat('html');
$Email->subject('Cartório NET - Solicitação de Serviço');
/*#### DEBUG ####*/
// $Email->transport('Debug');
// $response = $Email->send();
//
// echo $response['message'];
// die;
/*#### END DEBUG ####*/
$success = false;
try {
if ($Email->send()) {
$success = true;
} else {
$success = false;
}
} catch (Exception $e) {
// pr($e);
// die;
$success = false;
}
$this->id = $id;
$this->saveField('email_send', $success);
return $success;
}
示例14: editSetting
public function editSetting()
{
$setting = Setting::find(Input::get('id'));
$setting->setting_value = Input::get('value');
$setting->save();
return Redirect::route('get.admin.settings');
}
示例15: firstword
/**
* Ugly and wrong, but thi will get the word when user open an app for a first time
*
* @param $id user_id
* @return Response
*/
public function firstword($id)
{
$word = Setting::find(1)->word_id;
return $this->respond($word);
}