本文整理汇总了PHP中Illuminate\Support\Facades\Cache::forever方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::forever方法的具体用法?PHP Cache::forever怎么用?PHP Cache::forever使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Cache
的用法示例。
在下文中一共展示了Cache::forever方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* @throws \Exception
*/
public function handle()
{
$name = $this->argument('name');
$isUserRestrict = $this->confirm('User restricted ?', false);
$author = $this->ask("Your username", Cache::get('developer.username', ''));
Cache::forever('developer.username', $author);
$generator = new Generator($name, $isUserRestrict, $author);
$templateData = $generator->getTemplateData();
$files = $generator->getFiles();
$belongToRelations = $this->getRelation('BelongTo');
if ($isUserRestrict) {
$belongToRelations[] = 'user';
}
$belongToRelations = array_unique($belongToRelations);
$manyToManyRelations = $this->getRelation('ManyToMany');
$manyToManyRelations = array_unique($manyToManyRelations);
$fields = $this->getFields();
$this->summary($templateData, $isUserRestrict);
$this->fieldsSummary($fields);
$this->generate($generator, $fields, ['belongTo' => $belongToRelations, 'manyToMany' => $manyToManyRelations]);
$this->runComposerDumpAutoload();
$this->migrateDatabase();
$this->generateDocumentation();
$this->info("");
$this->info("What you need to do now ?");
$this->info("\t [] Add Acl/Scope to your route in routes.php");
$this->info("\t [] Fill data provider for " . $files['controllerTest']);
$this->info("\t [] Fill data provider for " . $files['repositoryTest']);
}
示例2: array
/**
* Setup for Google API authorization to retrieve directory data
*/
function __construct()
{
// set config options
$clientId = Config::get('google.client_id');
$serviceAccountName = Config::get('google.service_account_name');
$delegatedAdmin = Config::get('google.admin_email');
$keyFile = base_path() . Config::get('google.key_file_location');
$appName = Config::get('google.app_name');
// array of scopes
$scopes = array('https://www.googleapis.com/auth/admin.directory.user', 'https://www.googleapis.com/auth/admin.directory.user.readonly');
// Create AssertionCredentails object for use with Google_Client
$creds = new \Google_Auth_AssertionCredentials($serviceAccountName, $scopes, file_get_contents($keyFile));
// set admin identity for API requests
$creds->sub = $delegatedAdmin;
// Create Google_Client to allow making API calls
$this->client = new \Google_Client();
$this->client->setApplicationName($appName);
$this->client->setClientId($clientId);
$this->client->setAssertionCredentials($creds);
if ($this->client->getAuth()->isAccessTokenExpired()) {
$this->client->getAuth()->refreshTokenWithAssertion($creds);
}
Cache::forever('service_token', $this->client->getAccessToken());
// Set instance of Directory object for making Directory API related calls
$this->service = new \Google_Service_Directory($this->client);
}
示例3: getTimestampMigrationName
/**
* @return string
*/
protected function getTimestampMigrationName()
{
if (!Cache::has(static::CACHENAME)) {
Cache::forever(static::CACHENAME, date('Y_m_d_His') . '_' . $this->getMigrationName());
}
return Cache::get(static::CACHENAME);
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::user()) {
Cache::forever('last_seen_' . Auth::user()->id, date('Y-m-d H:i:s'));
}
return $next($request);
}
示例5: getThemeColorChange
/**
* Admin Theme Color Change
*
* @param Request $request
* @return \Illuminate\Http\Response
*/
public function getThemeColorChange(Request $request)
{
if (Cache::has('theme_color')) {
Cache::forget('theme_color');
}
Cache::forever('theme_color', $request->all());
return response()->json(['result' => true]);
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Cache::has('settings')) {
$settings = json_decode(Storage::get('settings.json'), true);
Cache::forever('settings', $settings);
}
return $next($request);
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @param Request $request
* @return Response
*/
public function update($id, Request $request)
{
$this->authorize('authorizeAccess', 'category_edit');
$this->fieldCategory->where('id', '=', $id)->update(['name_ar' => $request->input('name_ar'), 'name_en' => $request->input('name_en')]);
$fieldsCategories = $this->fieldCategory->all();
Cache::forget('fieldsCategories');
Cache::forever('fieldsCategories', $fieldsCategories);
return redirect()->back()->with('success', trans('messages.success.updated'));
}
示例8: cacheSetting
public function cacheSetting()
{
$setting = self::all();
$set = [];
foreach ($setting as $k => $v) {
$set[$v['key']] = $v['value'];
}
Cache::forever('setting', $set);
}
示例9: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$position = Cache::get(self::class, 0);
if (!isset($this->shouts[$position])) {
return;
}
Shout::create(['message' => $this->shouts[$position]]);
Cache::forever(self::class, ++$position);
}
示例10: fillCacheTrans
public static function fillCacheTrans()
{
if (Cache::get('translations')) {
$array_translate = Cache::get('translations');
} else {
$array_translate = self::getArrayTranslation();
Cache::forever('translations', $array_translate);
}
return $array_translate;
}
示例11: groupOfName
/**
* @param $name
* @return Group
*/
public function groupOfName($name)
{
$cache_key = md5('group.' . $name);
if (Cache::has($cache_key)) {
return Cache::get($cache_key);
}
$group = $this->em->getRepository($this->groupClass)->findOneBy(['lastName' => $name]);
Cache::forever($cache_key, $group);
return $group;
}
示例12: updateSideBarCache
public static function updateSideBarCache()
{
$categories = Category::all();
$posts = Post::orderBy('updated_at', 'desc')->limit(2)->get();
if (Cache::has('categories') || Cache::has('posts')) {
Cache::flush();
}
Cache::forever('posts', compact('posts'));
Cache::forever('categories', compact('categories'));
}
示例13: getSort
public static function getSort()
{
if (Cache::has(GlobalVar::$SORT_CACHE)) {
return Cache::get(GlobalVar::$SORT_CACHE);
} else {
$sorts = Sort::all();
Cache::forever(GlobalVar::$SORT_CACHE, $sorts);
return $sorts;
}
}
示例14: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function update(Request $request)
{
$setting = $this->settingRepository->first();
$status = $this->settingRepository->update($request->all(), $setting->id);
if ($status) {
Cache::forever('systemSetting', (object) $request->except('_token'));
return redirect()->route('dashboard.system.setting')->with('message', trans('validation.notice.update_system_success'));
}
return back()->with('fail', trans('validation.notice.database_error'));
}
示例15: writeStatus
/**
* Store status in cache or print.
*
* @param string $status
* @param bool $webExecution
*/
protected function writeStatus($status, $webExecution)
{
if ($webExecution) {
$cachedStatus = unserialize(Cache::get('scaffolder-status'));
array_push($cachedStatus, $status);
Cache::forever('scaffolder-status', serialize($cachedStatus));
} else {
$this->info($status);
}
}