本文整理汇总了PHP中CachetHQ\Cachet\Facades\Setting::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::set方法的具体用法?PHP Setting::set怎么用?PHP Setting::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CachetHQ\Cachet\Facades\Setting
的用法示例。
在下文中一共展示了Setting::set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch
/**
* Returns the segment write key.
*
* @return string
*/
public function fetch()
{
$writeKey = null;
try {
// Firstly, does the setting exist?
if (null === ($writeKey = Setting::get('segment_write_key'))) {
// No, let's go fetch it.
$writeKey = $this->repository->fetch();
Setting::set('segment_write_key', $writeKey);
} else {
// It does, but how old is it?
$setting = SettingModel::where('name', 'segment_write_key')->first();
// It's older than an hour, let's refresh
if ($setting->updated_at->lt(Carbon::now()->subHour())) {
$writeKey = $this->repository->fetch();
// Update the setting. This is done manual to make sure updated_at is overwritten.
$setting->value = $writeKey;
$setting->updated_at = Carbon::now();
$setting->save();
}
}
} catch (QueryException $e) {
// Just return it until we're setup.
$writeKey = $this->repository->fetch();
}
return $writeKey;
}
示例2: postStep3
/**
* Handles the actual app setup, including user, settings and env.
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
*/
public function postStep3()
{
$postData = Binput::all();
$v = Validator::make($postData, $this->rulesStep1 + $this->rulesStep2 + $this->rulesStep3);
if ($v->passes()) {
// Pull the user details out.
$userDetails = array_pull($postData, 'user');
$user = User::create(['username' => $userDetails['username'], 'email' => $userDetails['email'], 'password' => $userDetails['password'], 'level' => User::LEVEL_ADMIN]);
Auth::login($user);
$settings = array_pull($postData, 'settings');
foreach ($settings as $settingName => $settingValue) {
Setting::set($settingName, $settingValue);
}
$envData = array_pull($postData, 'env');
// Write the env to the .env file.
foreach ($envData as $envKey => $envValue) {
$this->writeEnv($envKey, $envValue);
}
Session::flash('setup.done', true);
if (Request::ajax()) {
return Response::json(['status' => 1]);
}
return Redirect::to('dashboard');
}
if (Request::ajax()) {
return Response::json(['errors' => $v->getMessageBag()], 400);
}
return Redirect::route('setup.index')->withInput()->withErrors($v->getMessageBag());
}
示例3: postSettings
/**
* Updates the status page settings.
*
* @return \Illuminate\View\View
*/
public function postSettings()
{
$redirectUrl = Session::get('redirect_to', route('dashboard.settings.setup'));
if (Binput::get('remove_banner') === '1') {
Setting::set('app_banner', null);
}
if (Binput::hasFile('app_banner')) {
$file = Binput::file('app_banner');
// Image Validation.
// Image size in bytes.
$maxSize = $file->getMaxFilesize();
if ($file->getSize() > $maxSize) {
return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.too-big', ['size' => $maxSize]));
}
if (!$file->isValid() || $file->getError()) {
return Redirect::to($redirectUrl)->withErrors($file->getErrorMessage());
}
if (!starts_with($file->getMimeType(), 'image/')) {
return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.images-only'));
}
// Store the banner.
Setting::set('app_banner', base64_encode(file_get_contents($file->getRealPath())));
// Store the banner type.
Setting::set('app_banner_type', $file->getMimeType());
}
try {
foreach (Binput::except(['app_banner', 'remove_banner']) as $settingName => $settingValue) {
if ($settingName === 'app_analytics_pi_url') {
$settingValue = rtrim($settingValue, '/');
}
Setting::set($settingName, $settingValue);
}
} catch (Exception $e) {
return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.edit.failure'));
}
if (Binput::has('app_locale')) {
Lang::setLocale(Binput::get('app_locale'));
}
return Redirect::to($redirectUrl)->withSuccess(trans('dashboard.settings.edit.success'));
}
示例4: postStep3
/**
* Handles the actual app setup, including user, settings and env.
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
*/
public function postStep3()
{
$postData = Binput::all();
$v = Validator::make($postData, ['env.cache_driver' => 'required|in:' . implode(',', array_keys($this->cacheDrivers)), 'env.session_driver' => 'required|in:' . implode(',', array_keys($this->cacheDrivers)), 'settings.app_name' => 'required', 'settings.app_domain' => 'required', 'settings.app_timezone' => 'required', 'settings.app_locale' => 'required', 'settings.show_support' => 'bool', 'user.username' => ['required', 'regex:/\\A(?!.*[:;]-\\))[ -~]+\\z/'], 'user.email' => 'email|required', 'user.password' => 'required']);
if ($v->passes()) {
// Pull the user details out.
$userDetails = array_pull($postData, 'user');
$user = User::create(['username' => $userDetails['username'], 'email' => $userDetails['email'], 'password' => $userDetails['password'], 'level' => 1]);
Auth::login($user);
$settings = array_pull($postData, 'settings');
foreach ($settings as $settingName => $settingValue) {
Setting::set($settingName, $settingValue);
}
$envData = array_pull($postData, 'env');
// Write the env to the .env file.
foreach ($envData as $envKey => $envValue) {
$this->writeEnv($envKey, $envValue);
}
Session::flash('setup.done', true);
if (Request::ajax()) {
return Response::json(['status' => 1]);
}
return Redirect::to('dashboard');
}
if (Request::ajax()) {
return Response::json(['errors' => $v->getMessageBag()], 400);
}
return Redirect::route('setup.index')->withInput()->withErrors($v->getMessageBag());
}