当前位置: 首页>>代码示例>>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;未经允许,请勿转载。