本文整理汇总了PHP中Setting::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::create方法的具体用法?PHP Setting::create怎么用?PHP Setting::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Setting
的用法示例。
在下文中一共展示了Setting::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerUser
/**
* This function will create a new user object and return the newly created user object.
*
* @param array $userInfo This should have the properties: username, firstname, lastname, password, ui_language
*
* @return mixed
*/
public function registerUser(array $userInfo, $userLanguage)
{
$user = \User::create($userInfo);
//make the first user an admin
if (\User::all()->count() <= 1) {
$user->is_admin = 1;
}
// Trim trailing whitespace from user first and last name.
$user->firstname = trim($user->firstname);
$user->lastname = trim($user->lastname);
$user->save();
\Setting::create(['ui_language' => $userLanguage, 'user_id' => $user->id]);
/* Add welcome note to user - create notebook, tag and note */
//$notebookCreate = Notebook::create(array('title' => Lang::get('notebooks.welcome_notebook_title')));
$notebookCreate = new \Notebook();
$notebookCreate->title = Lang::get('notebooks.welcome_notebook_title');
$notebookCreate->save();
$notebookCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
//$tagCreate = Tag::create(array('title' => Lang::get('notebooks.welcome_note_tag'), 'visibility' => 0));
$tagCreate = new \Tag();
$tagCreate->title = Lang::get('notebooks.welcome_note_tag');
$tagCreate->visibility = 0;
$tagCreate->user_id = $user->id;
$tagCreate->save();
//$tagCreate->users()->attach($user->id);
$noteCreate = new \Note();
$versionCreate = new \Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $user->id]);
$versionCreate->save();
$noteCreate->version()->associate($versionCreate);
$noteCreate->notebook_id = $notebookCreate->id;
$noteCreate->save();
$noteCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
$noteCreate->tags()->sync([$tagCreate->id]);
return $user;
}
示例2: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Setting::create([]);
}
}
示例3: store
/**
* Store a newly created setting in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Setting::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
Setting::create($data);
return Redirect::route('settings.index');
}
示例4: setKey
static function setKey($key, $value)
{
self::$cache[$key] = $value;
$setting = Setting::findOne('`key` = ?', [$key]);
if (!$setting) {
$setting = Setting::create();
$setting->key = $key;
}
$setting->value = $value;
$setting->save();
}
示例5: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Setting::truncate();
Schema::table('settings', function (Blueprint $table) {
$table->string('key')->unique();
$table->string('value')->nullable();
});
$settings = ['project_name' => 'Logboek', 'ex_title' => 'ex_logboek', 'ex_customer' => 'Opdrachtgever', 'ex_date' => '01-01-1970', 'ex_version' => '1.0', 'ex_disclaimer' => '', 'ex_disclaimer_html' => '', 'ex_pdf_sh_evidences' => '1', 'ex_pdf_sh_coc' => '1', 'ex_pdf_sh_attachments' => '1', 'ex_pdf_sh_suspects' => '1', 'ex_pdf_sh_legals' => '1', 'ex_html_sh_evidences' => '1', 'ex_html_sh_coc' => '1', 'ex_html_sh_attachments' => '1', 'ex_html_sh_suspects' => '1', 'ex_html_sh_legals' => '1', 'menu' => join(';', ['entries', 'logbooks', 'tasks', 'attachments', 'evidences', 'exports', 'menu', 'settings', 'intro'])];
foreach ($settings as $key => $value) {
Setting::create(['key' => $key, 'value' => $value]);
}
}
示例6: 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;
}
示例7: store
/**
* Stores new account
*
* @return Illuminate\Http\Response
*/
public function store()
{
$repo = App::make('UserRepository');
$user = $repo->signup(Input::all());
if ($user->id) {
$settings = array('user_id' => $user->id, 'language' => 'en', 'currency_id' => 840);
Setting::create($settings);
if (Config::get('confide::signup_email')) {
Mail::queueOn(Config::get('confide::email_queue'), Config::get('confide::email_account_confirmation'), compact('user'), function ($message) use($user) {
$message->to($user->email, $user->username)->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
});
}
return Redirect::action('UsersController@login')->with('notice', Lang::get('confide::confide.alerts.account_created'));
} else {
$error = $user->errors()->all(':message');
return Redirect::action('UsersController@create')->withInput(Input::except('password'))->with('error', $error);
}
}
示例8: getIndex
public function getIndex()
{
// truncate tables and add default user 'admin'
DB::table('users')->truncate();
DB::table('profiles')->truncate();
DB::table('password_resets')->truncate();
DB::table('settings')->truncate();
DB::table('domains')->truncate();
DB::table('phone_numbers')->truncate();
DB::table('logs')->truncate();
$profile = new Profile(array('first_name' => 'System', 'last_name' => 'Administrator', 'website' => 'https://github.com/antonraharja/laravel-startup'));
$profile->save();
$user = new User(array('email' => 'admin@host.local', 'username' => 'admin', 'password' => Hash::make('admin123'), 'status' => 2, 'ban' => 0));
$user->profile()->associate($profile);
$user->save();
$settings = array(array('name' => 'global_prefix', 'value' => '62520'), array('name' => 'panel_path', 'value' => 'dcp'), array('name' => 'domain_limit', 'value' => '1'), array('name' => 'phone_number_limit', 'value' => '1'), array('name' => 'email_address_for_notification', 'value' => 'noreply@voip-id.teleponrakyat.id'), array('name' => 'email_address_for_admin', 'value' => 'noreply@voip-id.teleponrakyat.id'), array('name' => 'sender_name', 'value' => 'VoIP ID'), array('name' => 'sip_server', 'value' => '192.168.1.150'), array('name' => 'reserved_extension', 'value' => '100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999, 123456, 654321'), array('name' => 'reserved_domain_prefix', 'value' => '100, 200, 300, 400, 500, 600, 700, 800, 900, 111, 222, 333, 444, 555, 666, 777, 888, 999, 123, 456, 789, 987, 654, 321'), array('name' => 'log_file', 'value' => '/var/log/voip_id/voip_id.log'), array('name' => 'available_css', 'value' => 'default, flatly, united, lumen, yeti, paper, cerulean, cyborg, darkly, journal, readable, sandstone, simplex, slate, spacelab, superhero'));
foreach ($settings as $setting) {
Setting::create($setting);
}
// just throw something
print_r('init done.');
}
示例9: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Setting::truncate();
Schema::table('settings', function (Blueprint $table) {
$table->dropColumn('project_name');
$table->dropColumn('vw_menu_entries');
$table->dropColumn('vw_menu_logbooks');
$table->dropColumn('vw_menu_tasks');
$table->dropColumn('vw_menu_attachments');
$table->dropColumn('vw_menu_evidences');
$table->dropColumn('vw_menu_exports');
$table->dropColumn('vw_menu_cipher');
$table->dropColumn('vw_menu_settings');
$table->dropColumn('vw_menu_intro');
$table->string('key')->unique();
$table->string('value')->nullable();
});
$settings = ['project_name' => 'Logboek', 'menu' => join(';', ['entries', 'logbooks', 'tasks', 'attachments', 'evidences', 'exports', 'cipher', 'settings', 'intro'])];
foreach ($settings as $key => $value) {
Setting::create(['key' => $key, 'value' => $value]);
}
}
示例10: storeReview
public function storeReview()
{
$inputs = Input::only(array('frequency', 'hour', 'minute', 'ng-word', 'id'));
if ($inputs['id'] != null) {
// DB更新
$setting = Setting::where('id', '=', $inputs['id'])->update(array('frequency' => $inputs['frequency'], 'hour' => $inputs['hour'], 'minute' => $inputs['minute'], 'ng_word' => $inputs['ng-word']));
} else {
// 新しい設定の挿入
$setting = Setting::create(array('frequency' => $inputs['frequency'], 'hour' => $inputs['hour'], 'minute' => $inputs['minute'], 'ng_word' => $inputs['ng-word']));
}
/**
* TODO このファイルの指定方法危険
*/
$fp = fopen("/usr/local/www/rst.prodrb.com/bin/cron/cron.txt", 'w');
//$text = "MAILTO=itakedaka@gmail.com\n{$inputs['minute']} {$inputs['hour']} * * * /usr/bin/php /usr/local/www/rst.prodrb.com/bin/scripts/getReviewScript.php\n";
$text = "*/5 * * * * /usr/bin/php /usr/local/www/rst.prodrb.com/bin/scripts/getReviewScript.php\n";
fputs($fp, $text);
$resutl = system('crontab /usr/local/www/rst.prodrb.com/bin/cron/cron.txt');
fclose($fp);
// フラッシュデータ
Session::flush('message', '設定を更新しました');
return Redirect::route('setting.review');
}
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Setting::create(['index' => 'security', 'subindex' => 'password', 'parameter' => 'salt_left', 'value' => 'd5Gjh', 'description' => 'Salt esquerdo da senha', 'type' => 'string']);
Setting::create(['index' => 'security', 'subindex' => 'password', 'parameter' => 'salt_right', 'value' => 's2Gv0', 'description' => 'Salt direito da senha', 'type' => 'string']);
}
示例12: checkSandstormUsers
public function checkSandstormUsers()
{
if (Config::get('paperwork.emergency_export') && DB::table('migrations')->where('batch', '=', 1)->count() == Config::get('paperwork.emergency_export_count')) {
$credentials = ["username" => "sandstorm_dummy", "password" => "sandstorm_dummy"];
if (Auth::attempt($credentials)) {
$settings = Setting::where('user_id', '=', Auth::user()->id)->first();
Session::put('ui_language', $settings->ui_language);
return View::make('user.emergency_export');
}
} else {
// get permission via HTTP_X_SANDSTORM header
$sandstorm_permissions = $_SERVER['HTTP_X_SANDSTORM_PERMISSIONS'];
// Only when we are admin, we check and create users
if ($sandstorm_permissions == "admin,write,read") {
// check for admin user
if (User::where('username', '=', 'sandstorm_admin')->count() == 0) {
$sandstorm_admin = User::create(Input::except('_token', 'password_confirmation', 'ui_language'));
if ($sandstorm_admin) {
//make the first user an admin
$sandstorm_admin->firstname = "sandstorm_admin";
$sandstorm_admin->lastname = " ";
$sandstorm_admin->username = "sandstorm_admin";
$sandstorm_admin->password = "sandstorm_admin";
$sandstorm_admin->is_admin = 1;
$sandstorm_admin->save();
$setting_sandstorm_admin = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_admin->id]);
}
} else {
$sandstorm_admin = User::where('username', '=', 'sandstorm_admin');
}
// Then the read & write user
if (User::where('username', '=', 'sandstorm_readwrite')->count() == 0) {
$sandstorm_readwrite = User::create(Input::except('_token', 'password_confirmation', 'ui_language'));
if ($sandstorm_readwrite) {
$sandstorm_readwrite->firstname = "sandstorm_readwrite";
$sandstorm_readwrite->lastname = " ";
$sandstorm_readwrite->username = "sandstorm_readwrite";
$sandstorm_readwrite->password = "sandstorm_readwrite";
$sandstorm_readwrite->save();
$setting_sandstorm_readwrite = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_readwrite->id]);
}
} else {
$sandstorm_readwrite = User::where('username', '=', 'sandstorm_readwrite');
}
// Then the read only user
if (User::where('username', '=', 'sandstorm_readonly')->count() == 0) {
$sandstorm_readonly = User::create(Input::except('_token', 'password_confirmation', 'ui_language'));
if ($sandstorm_readonly) {
$sandstorm_readonly->firstname = "sandstorm_readonly";
$sandstorm_readonly->lastname = " ";
$sandstorm_readonly->username = "sandstorm_readonly";
$sandstorm_readonly->password = "sandstorm_readonly";
$sandstorm_readonly->save();
$setting_sandstorm_readonly = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_readonly->id]);
}
} else {
$sandstorm_readonly = User::where('username', '=', 'sandstorm_readonly');
}
}
// Now that the required users are there we create the default
if (Notebook::all()->count() == 0 && Tag::all()->count() == 0 && Note::all()->count() == 0) {
// Notebook ...
$notebookCreate = new Notebook();
$notebookCreate->title = Lang::get('notebooks.welcome_notebook_title');
$notebookCreate->save();
$notebookCreate->users()->attach($sandstorm_readonly->id, ['umask' => PaperworkHelpers::UMASK_READONLY]);
$notebookCreate->users()->attach($sandstorm_readwrite->id, ['umask' => PaperworkHelpers::UMASK_READWRITE]);
$notebookCreate->users()->attach($sandstorm_admin->id, ['umask' => PaperworkHelpers::UMASK_OWNER]);
// Tag ...
$tagCreate = new Tag();
$tagCreate->title = Lang::get('notebooks.welcome_note_tag');
$tagCreate->visibility = 1;
$tagCreate->user_id = $sandstorm_admin->id;
$tagCreate->save();
// Note ...
$noteCreate = new Note();
$versionCreate = new Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $sandstorm_admin->id]);
$versionCreate->save();
$noteCreate->version()->associate($versionCreate);
$noteCreate->notebook_id = $notebookCreate->id;
$noteCreate->save();
$noteCreate->users()->attach($sandstorm_readonly->id, ['umask' => PaperworkHelpers::UMASK_READONLY]);
$noteCreate->users()->attach($sandstorm_readwrite->id, ['umask' => PaperworkHelpers::UMASK_READWRITE]);
$noteCreate->users()->attach($sandstorm_admin->id, ['umask' => PaperworkHelpers::UMASK_OWNER]);
$noteCreate->tags()->sync([$tagCreate->id]);
}
// login
if ($sandstorm_permissions == "read") {
$credentials = ["username" => "sandstorm_readonly", "password" => "sandstorm_readonly"];
}
if ($sandstorm_permissions == "write,read") {
$credentials = ["username" => "sandstorm_readwrite", "password" => "sandstorm_readwrite"];
}
if ($sandstorm_permissions == "admin,write,read") {
$credentials = ["username" => "sandstorm_admin", "password" => "sandstorm_admin"];
}
if (Auth::attempt($credentials)) {
$settings = Setting::where('user_id', '=', Auth::user()->id)->first();
Session::put('ui_language', $settings->ui_language);
return Redirect::route("/");
//.........这里部分代码省略.........
示例13: getsetting
/**
* Enter description here...
*/
function getsetting($name = null)
{
if (!$name) {
return false;
}
$objSetting = new Setting();
$setting = $objSetting->find('first', array('conditions' => array('parent_id' => '<> 0', 'name' => $name)));
if (empty($setting)) {
$defaultGroup = $objSetting->find('first', array('conditions' => array('parent_id' => 0, 'name' => 'Global'), 'fields' => 'id'));
if (empty($defaultGroup)) {
$objSetting->create(array('parent_id' => 0, 'name' => 'Global'));
$objSetting->save() or $this->logErr('cannot create default settings group');
$gid = $objSetting->id;
} else {
$gid = $defaultGroup['Setting']['id'];
}
$objSetting->create(array('parent_id' => $gid, 'name' => $name));
$objSetting->save();
//or $this->logErr('cannot create a new setting');
} else {
return $setting['Setting']['value'];
}
}
示例14: headings
function headings($line = '1')
{
Setting::create(array('name' => 'test123'));
$data['page_name'] = '<b>Payroll Headings</b>';
$data['msg'] = '';
$data['rows'] = PayrollHeading::line(1)->orderBy('order')->get();
$data['rows2'] = PayrollHeading::line(2)->orderBy('order')->get();
$data['main_content'] = 'report/headings';
$validator = Validator::make($data1 = array('name' => '', 'email' => 'mannysoft@gmail.com'), $rules = array('name' => 'email|required|max:5', 'email' => 'email|required|max:5'));
if ($validator->fails()) {
// The given data did not pass validation
$messages = $validator->messages()->all();
foreach ($messages as $message) {
//
echo $message;
}
}
//var_dump(class_exists('Input1'));
//echo Input1::get('aa');
//print_r(get_declared_classes());
//\Illuminate\Support\Facades\Input::all();
//$a->all();
//var_dump($a);
//exit;
//$v = new View(Illuminate\View\Environment, EngineInterface, $view = '');
//return View::make('account.register', $data);
//exit;
//Decoration::setLineColors();
//$p = new Payment;
//$p->process();
//Input::get();
//https://github.com/laravel/framework/issues/854
//var_dump($validator);
return View::make('includes/template', $data);
}
示例15: postInstallData
private function postInstallData($siteTitle)
{
// Add default settings
$host = substr_count($_SERVER['HTTP_HOST'], '.') > 1 ? substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.') + 1) : $_SERVER['HTTP_HOST'];
$host = strpos($host, ':') !== false ? substr($host, 0, strpos($host, ':')) : $host;
// Remove port if present on unusual configurations
App::uses('Setting', 'Model');
$settingModel = new Setting();
$defaultSettings = array();
$defaultSettings['title'] = $siteTitle;
$defaultSettings['theme'] = json_encode(array('logo' => '/img/logo.png', 'bgcolor' => '#444444', 'bgimage' => $this->request->webroot . 'img/bg.png', 'bgrepeat' => 'repeat'));
$defaultSettings['css'] = '';
$defaultSettings['notifications'] = json_encode(array('enabled' => 1, 'signup' => 0, 'contact' => ''));
$defaultSettings['email'] = json_encode(array('name' => 'MushRaider', 'from' => 'mushraider@' . $host, 'encoding' => '', 'transport' => 'Mail', 'host' => '', 'port' => '', 'username' => '', 'password' => ''));
$defaultSettings['Mushstats'] = time();
$defaultSettings['calendar'] = json_encode(array('weekStartDay' => 1, 'title' => 'event', 'timeToDisplay' => 'time_invitation', 'gameIcon' => 1, 'dungeonIcon' => 1));
$defaultSettings['timezone'] = 'Europe/Paris';
foreach ($defaultSettings as $option => $value) {
$settingModel->create();
$settingModel->save(array('option' => $option, 'value' => $value));
}
// Add default roles permissions
$rolesPermissions = array(array('title' => __('Full permissions'), 'alias' => 'full_permissions', 'description' => __('Like Chuck Norris, he can do anything. This overwrite every permissions')), array('title' => __('Limited admin access'), 'alias' => 'limited_admin', 'description' => __('Like Robin, he can do some things but not all (like driving the batmobile or change user role)')), array('title' => __('Can manage events'), 'alias' => 'manage_events', 'description' => __('Can create, edit and delete events. Can also manage the roster for each events')), array('title' => __('Can manage own events only'), 'alias' => 'manage_own_events', 'description' => __('Can create, edit and delete own events only. Can also manage the roster for his events')), array('title' => __('Can create templates'), 'alias' => 'create_templates', 'description' => __('Can create events templates')), array('title' => __('Can create reports'), 'alias' => 'create_reports', 'description' => __('Can create events reports')));
App::uses('RolePermission', 'Model');
$RolePermissionModel = new RolePermission();
foreach ($rolesPermissions as $rolesPermission) {
$RolePermissionModel->create();
$RolePermissionModel->save($rolesPermission);
}
// Add new roles permissions to existing roles
App::uses('Role', 'Model');
$RoleModel = new Role();
App::uses('RolePermissionRole', 'Model');
$RolePermissionRoleModel = new RolePermissionRole();
$RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('admin'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('full_permissions')));
$RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('limited_admin')));
$RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('manage_events')));
$RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('create_templates')));
$RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('create_reports')));
}