dimanche 11 août 2019

use Cache in srevice provider

my layout some section have dynamic conetent, i want to send loaded data to layout. for that in AppServiceProvider (register method) i did like this.

to reduce number of query to database i want to use cache. but i get this error: i tried :

use Cache 

or use Illuminate\Support\Facades\Cache;

how can i fix this issue?

Call to undefined method Illuminate\Support\Facades\Cache::remember()

this is my codes:

 $config =  \Cache::remember('key', 60, function () {
                return \App\SiteConfig::select(['title', 'meta', 'description'])->first();

            });

   view()->composer('layouts.app', function($view) use ($config){

          $view->with(compact('config'));
   });



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire