當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Category::getAllFromCache方法代碼示例

本文整理匯總了PHP中app\Category::getAllFromCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::getAllFromCache方法的具體用法?PHP Category::getAllFromCache怎麽用?PHP Category::getAllFromCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Category的用法示例。


在下文中一共展示了Category::getAllFromCache方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     if (Schema::hasTable('categories')) {
         $categories = Category::getAllFromCache();
         view()->share('categories', $categories);
     }
 }
開發者ID:mikolajszczepanski,項目名稱:NuPtr,代碼行數:12,代碼來源:CategoryServiceProvider.php

示例2: index

 public function index(Request $request = null, $alias = null, $paginate = 15)
 {
     $time_start = microtime(true);
     $tasks = Task::where('deleted', false);
     if (!empty($alias) && strlen($alias) >= 1 && strlen($alias) <= 20) {
         $categories = Category::getAllFromCache();
         $found_category = null;
         foreach ($categories as $category) {
             if ($category->alias == $alias) {
                 $found_category = $category;
                 break;
             }
         }
         if ($found_category) {
             $tasks = $tasks->where('category_id', $found_category->id);
         }
     }
     if (!$alias) {
         $alias = '';
     }
     $current_page = !empty($request->input('page')) ? (int) $request->input('page') : 1;
     $cache_name = __METHOD__ . '_alias=' . $alias . 'paginate=' . $paginate . 'page=' . $current_page;
     $tasks = Cache::remember($cache_name, Config::get('constants.CACHE_TIME_DAY'), function () use($tasks, $paginate, $cache_name) {
         if (App::environment('local')) {
             Log::debug('Cache: ' . $cache_name);
         }
         return $tasks->orderBy('created_at', 'desc')->paginate($paginate);
     });
     Task::resolveTasksDependencies($tasks);
     $time_end = microtime(true);
     return view('task/index', ['tasks' => $tasks, 'alias' => $alias, 'debug_time_of_execution' => $time_end - $time_start]);
 }
開發者ID:mikolajszczepanski,項目名稱:NuPtr,代碼行數:32,代碼來源:TaskController.php

示例3: resolveTaskDependencies

 public static function resolveTaskDependencies(&$task, $categories = null)
 {
     if (!$categories) {
         $categories = Category::getAllFromCache();
     }
     $task->category_name = $categories[$task->category_id - 1]->name;
     $cache_name = __METHOD__ . '_task_id=' . $task->id;
     $task->files = Cache::remember($cache_name, Config::get('constants.CACHE_TIME_DAY'), function () use($task, $cache_name) {
         if (App::environment('local')) {
             Log::debug('Cache: ' . $cache_name);
         }
         return TaskFile::where('task_id', $task->id)->where('deleted', false)->select('id', 'name', 'user_id', 'task_id', 'created_at', 'updated_at')->get();
     });
     $task->solutions = Solution::getTaskSolutionsDependencies($task->id);
 }
開發者ID:mikolajszczepanski,項目名稱:NuPtr,代碼行數:15,代碼來源:Task.php


注:本文中的app\Category::getAllFromCache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。