Пример #1
0
 /**
  * Display a listing of the resource.
  *
  * @param \App\Http\Requests\FilterArticlesRequest $request
  * @param int|null                                 $id
  * @return \Illuminate\Http\Response
  */
 public function index(FilterArticlesRequest $request, $id = null)
 {
     $query = $id ? Tag::findOrFail($id)->articles() : new Article();
     // If you are relying on 'file' or 'database' cache, cacheTags() methods is not available
     $query = taggable() ? $query->with('comments', 'author', 'tags', 'attachments')->remember(5)->cacheTags('articles') : $query->with('comments', 'author', 'tags', 'solution', 'attachments')->remember(5);
     $articles = $this->filter($request, $query)->paginate(10);
     return view('articles.index', compact('articles'));
 }
Пример #2
0
 /**
  * Handle the event.
  *
  * @param \App\Events\ModelChanged $event
  */
 public function handle(ModelChanged $event)
 {
     if (!taggable()) {
         // Remove all cache store
         return \Cache::flush();
     }
     // Remove only cache that has the given tag(s)
     return \Cache::tags($event->cacheTags)->flush();
 }
Пример #3
0
 /**
  * Constructor
  */
 public function __construct()
 {
     if (!is_api_request()) {
         $this->setSharedVariables();
     }
     $this->cache = app('cache');
     if ((new \ReflectionClass($this))->implementsInterface(\App\Http\Controllers\Cacheable::class) and taggable()) {
         $this->cache = app('cache')->tags($this->cacheKeys());
     }
 }