本文整理汇总了PHP中Setting::first方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::first方法的具体用法?PHP Setting::first怎么用?PHP Setting::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Setting
的用法示例。
在下文中一共展示了Setting::first方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_settings
public function save_settings()
{
$input = Input::all();
$settings = Setting::first();
$demo_mode = Input::get('demo_mode');
$enable_https = Input::get('enable_https');
if (empty($demo_mode)) {
$input['demo_mode'] = 0;
}
if (empty($enable_https)) {
$input['enable_https'] = 0;
}
if (Input::hasFile('logo')) {
$input['logo'] = ImageHandler::uploadImage(Input::file('logo'), 'settings');
} else {
$input['logo'] = $settings->logo;
}
if (Input::hasFile('favicon')) {
$input['favicon'] = ImageHandler::uploadImage(Input::file('favicon'), 'settings');
} else {
$input['favicon'] = $settings->favicon;
}
$settings->update($input);
return Redirect::to('admin/settings')->with(array('note' => 'Successfully Updated Site Settings!', 'note_type' => 'success'));
}
示例2: __construct
public function __construct(Setting $settings = null, Portfolio $portfolio = null, Filesystem $filesystem = null)
{
$this->settings = $settings == null ? Setting::first() : $settings;
$this->portfolio = $portfolio == null ? Portfolio::all() : $portfolio;
$this->filesystem = $filesystem == null ? new Filesystem() : $filesystem;
\View::share('settings', $this->settings);
}
示例3: login
public function login()
{
// get login POST data
$email_login = array('email' => Input::get('email'), 'password' => Input::get('password'));
$username_login = array('username' => Input::get('email'), 'password' => Input::get('password'));
if (Auth::attempt($email_login) || Auth::attempt($username_login)) {
//dd(Auth::user());
if (Auth::user()->subscribed() || (Auth::user()->role == 'admin' || Auth::user()->role == 'demo')) {
$redirect = Input::get('redirect', 'false') ? Input::get('redirect') : '/';
if (Auth::user()->role == 'demo' && Setting::first()->demo_mode != 1) {
Auth::logout();
return Redirect::to($redirect)->with(array('note' => 'Sorry, Demo Mode has been disabled', 'note_type' => 'error'));
} else {
return Redirect::to($redirect)->with(array('note' => 'You have been successfully logged in.', 'note_type' => 'success'));
}
} else {
$username = Auth::user()->username;
return Redirect::to('user/' . $username . '/renew_subscription')->with(array('note' => 'Uh oh, looks like you don\'t have an active subscription, please renew to gain access to all content', 'note_type' => 'error'));
}
} else {
$redirect = Input::get('redirect', false) ? '?redirect=' . Input::get('redirect') : '';
// auth failure! redirect to login with errors
return Redirect::to('login' . $redirect)->with(array('note' => 'Invalid login, please try again.', 'note_type' => 'error'));
}
}
示例4: __construct
private function __construct()
{
$setting = Setting::first();
if ($setting) {
self::$google_api_key = $setting->api_key;
}
}
示例5: settings_form
public function settings_form()
{
$settings = Setting::first();
$user = Auth::user();
$data = array('settings' => $settings, 'admin_user' => $user);
return View::make('admin.settings.index', $data);
}
示例6: simpan_jadwal
public function simpan_jadwal()
{
if (Request::ajax()) {
$setting = Setting::first();
$hari = Input::get('hari');
$guru = Input::get('guru');
$rombel = Input::get('rombel');
$jam = Input::get('jam');
$mapel = Input::get('mapel');
$cek = DB::table('jadwal')->where('kd_rombel', '=', $rombel)->where('hari', '=', $hari)->where('jam_ke', '=', $jam)->count();
if ($cek > 0) {
echo "error";
} else {
//cek apakah guru ini sudah mengajar ditempat lain atau belum
$cekguru = DB::table('jadwal')->where('kd_rombel', 'like', $setting->dari_tahun . '-' . $setting->sampai_tahun . "%")->where('id_guru', '=', $guru)->where('hari', '=', $hari)->where('jam_ke', '=', $jam)->where('kd_mapel', '=', $mapel)->count();
if ($cekguru > 0) {
echo "error2";
} else {
$jadwal = new Jadwal();
$jadwal->kd_rombel = Input::get('rombel');
$jadwal->hari = Input::get('hari');
$jadwal->jam_ke = Input::get('jam');
$jadwal->id_guru = Input::get('guru');
$jadwal->kd_mapel = Input::get('mapel');
$jadwal->save();
echo "sukses";
}
}
}
}
示例7: subscribers
public function subscribers()
{
$user = Sentry::getUser();
$subscribers = Subscriber::orderBy('first_name', 'asc')->get();
$sitename = Setting::first()->pluck('sitename');
return View::make('dashboard.subscribers', array('user' => $user, 'subscribers' => $subscribers, 'sitename' => $sitename));
}
示例8: activate
public function activate($slug)
{
$settings = Setting::first();
$settings->theme = $slug;
$settings->save();
return Redirect::to('admin/themes')->with(array('note' => 'Successfully Activated ' . ucfirst($slug) . ' Theme', 'note_type' => 'success'));
}
示例9: add_db_data
public function add_db_data()
{
if (Request::ajax()) {
try {
$settings = Setting::first();
if ($settings) {
return Redirect::to('/');
} else {
throw new Exception('settings not set, first install the script');
}
} catch (Exception $e) {
try {
$this->add_all_tables();
$this->insert_settings();
$this->insert_categories();
if (Input::get('preloaded_data') == 'true') {
$this->insert_media();
}
$this->upgrade();
echo true;
} catch (Exception $e) {
echo false;
}
}
} else {
echo false;
}
}
示例10: settings
public function settings()
{
$user = Sentry::getUser();
if (Input::get('email') == $user->email) {
$rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255', 'password' => 'required|min:7|confirmed', 'sitename' => 'required|max:50');
} else {
$rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:7|confirmed', 'sitename' => 'required|max:50');
}
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Response::json($validator->messages());
} else {
$setting = Setting::first();
$setting->sitename = Input::get('sitename');
$setting->save();
$user = User::find($user->id);
$user->first_name = Input::get('first_name');
$user->last_name = Input::get('last_name');
$user->email = Input::get('email');
$user->password = Input::get('password');
$user->save();
$feedback = array('success' => 'Settings successfully saved.');
return Response::json($feedback);
}
}
示例11: create
function create()
{
if ($_POST) {
unset($_POST['send']);
$_POST['datetime'] = time();
$_POST = array_map('htmlspecialchars', $_POST);
unset($_POST['files']);
$project = Project::create($_POST);
$new_project_reference = $_POST['reference'] + 1;
$project_reference = Setting::first();
$project_reference->update_attributes(array('project_reference' => $new_project_reference));
if (!$project) {
$this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_project_error'));
} else {
$this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_project_success'));
$project_last = Project::last();
$sql = "INSERT INTO `project_has_workers` (`project_id`, `user_id`) VALUES (" . $project_last->id . ", " . $this->user->id . ")";
$query = $this->db->query($sql);
}
redirect('projects');
} else {
$this->view_data['companies'] = Company::find('all', array('conditions' => array('inactive=?', '0')));
$this->view_data['next_reference'] = Project::last();
$this->theme_view = 'modal';
$this->view_data['title'] = $this->lang->line('application_create_project');
$this->view_data['form_action'] = 'projects/create';
$this->content_view = 'projects/_project';
}
}
示例12: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$mengajar = Mengajar::find($id);
$guru = Guru::all();
$mapel = Mapel::all();
$setting = Setting::first();
return View::make('mengajar.edit')->with('mengajar', $mengajar)->with('guru', $guru)->with('mapel', $mapel)->with('setting', $setting);
}
示例13: __construct
function __construct()
{
parent::__construct();
$this->view_data['core_settings'] = Setting::first();
if ($this->input->cookie('language') != "") {
$language = $this->input->cookie('language');
} else {
if (isset($this->view_data['language'])) {
$language = $this->view_data['language'];
} else {
if (!empty($this->view_data['core_settings']->language)) {
$language = $this->view_data['core_settings']->language;
} else {
$language = "english";
}
}
}
$this->lang->load('application', $language);
$this->lang->load('messages', $language);
$this->lang->load('event', $language);
$this->user = $this->session->userdata('user_id') ? User::find_by_id($this->session->userdata('user_id')) : FALSE;
$this->client = $this->session->userdata('client_id') ? Client::find_by_id($this->session->userdata('client_id')) : FALSE;
if ($this->client) {
$this->theme_view = 'application_client';
}
$this->view_data['datetime'] = date('Y-m-d H:i', time());
$this->view_data['sticky'] = Project::all(array('conditions' => 'sticky = 1'));
$this->view_data['quotations_new'] = Quote::find_by_sql("select count(id) as amount from quotations where status='New'");
if ($this->user || $this->client) {
$access = $this->user ? $this->user->access : $this->client->access;
$access = explode(",", $access);
if ($this->user) {
$this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'main')));
$this->view_data['widgets'] = Module::find('all', array('conditions' => array('id in (?) AND type = ?', $access, 'widget')));
} else {
$this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'client')));
}
if ($this->user) {
$update = User::find($this->user->id);
} else {
$update = Client::find($this->client->id);
}
$update->last_active = time();
$update->save();
if ($this->user) {
$this->view_data['user_online'] = User::all(array('conditions' => array('last_active+(30 * 60) > ? AND status = ?', time(), "active")));
$this->view_data['client_online'] = Client::all(array('conditions' => array('last_active+(30 * 60) > ? AND inactive = ?', time(), "0")));
}
$email = $this->user ? 'u' . $this->user->id : 'c' . $this->client->id;
$this->view_data['messages_new'] = Privatemessage::find_by_sql("select count(id) as amount from privatemessages where `status`='New' AND recipient = '" . $email . "'");
$this->view_data['tickets_new'] = Ticket::find_by_sql("select count(id) as amount from tickets where `status`='New'");
}
/*$this->load->database();
$sql = "select * FROM templates WHERE type='notes'";
$query = $this->db->query($sql); */
$this->view_data["note_templates"] = "";
//$query->result();
}
示例14: create
function create()
{
if ($_POST) {
$config['upload_path'] = './files/media/';
$config['encrypt_name'] = TRUE;
$config['allowed_types'] = '*';
$this->load->library('upload', $config);
$this->load->helper('notification');
unset($_POST['userfile']);
unset($_POST['file-name']);
unset($_POST['send']);
unset($_POST['_wysihtml5_mode']);
unset($_POST['files']);
$settings = Setting::first();
$client = Client::find_by_id($this->client->id);
$user = User::find_by_id($settings->ticket_default_owner);
$_POST['from'] = $client->firstname . ' ' . $client->lastname . ' - ' . $client->email;
$_POST['company_id'] = $client->company->id;
$_POST['client_id'] = $client->id;
$_POST['user_id'] = $settings->ticket_default_owner;
$_POST['queue_id'] = $settings->ticket_default_queue;
$_POST['type_id'] = $settings->ticket_default_type;
$_POST['status'] = $settings->ticket_default_status;
$_POST['created'] = time();
$_POST['subject'] = htmlspecialchars($_POST['subject']);
$ticket_reference = Setting::first();
$_POST['reference'] = $ticket_reference->ticket_reference;
$ticket = Ticket::create($_POST);
$new_ticket_reference = $_POST['reference'] + 1;
$ticket_reference->update_attributes(array('ticket_reference' => $new_ticket_reference));
if (!$this->upload->do_upload()) {
$error = $this->upload->display_errors('', ' ');
$this->session->set_flashdata('message', 'error:' . $error);
} else {
$data = array('upload_data' => $this->upload->data());
$attributes = array('ticket_id' => $ticket->id, 'filename' => $data['upload_data']['orig_name'], 'savename' => $data['upload_data']['file_name']);
$attachment = TicketHasAttachment::create($attributes);
}
if (!$ticket) {
$this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_ticket_error'));
redirect('ctickets');
} else {
$this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_ticket_success'));
if (isset($user->email) && isset($ticket->reference)) {
send_ticket_notification($user->email, '[Ticket#' . $ticket->reference . '] - ' . $_POST['subject'], $_POST['text'], $ticket->id);
}
if (isset($client->email) && isset($ticket->reference)) {
send_ticket_notification($client->email, '[Ticket#' . $ticket->reference . '] - ' . $_POST['subject'], $_POST['text'], $ticket->id);
}
redirect('ctickets/view/' . $ticket->id);
}
} else {
$this->theme_view = 'modal';
$this->view_data['title'] = $this->lang->line('application_create_ticket');
$this->view_data['form_action'] = 'ctickets/create';
$this->content_view = 'tickets/client_views/_ticket';
}
}
示例15: getSettings
public function getSettings()
{
$settings = Setting::first($this->public_settings);
// Include the Uploads URL
$settings['uploads_dir'] = Config::get('site.uploads_dir');
// Include Site URL
$settings['url'] = URL::to('/');
return Response::json($settings);
}