0
I wonder if the way I am working with cache is correct and if you have something more practical for it.
Follows the code:
<?php
namespace App\Modules\Admin\Controllers;
use Cache;
use Auth;
class Network extends Controller
{
public function teste()
{
if( ! Cache::has('user') ) {
$user = Auth::user();
Cache::store('file')->put('user', $user, 10);
} else {
$user = Cache::get('user');
}
return view('cms::user', [
'user' => $user
]);
}
}
Grateful for the understanding.
That’s right @Raank! , only changes a little when you want to use database data !
$value = Cache::get('key', function() {
 return DB::table(...)->get();
});
that would be so!– novic
I see no problem in using the cache, the only thing I would do is change the location where you do this check and apply the PSR-4 defaults.
– Rafael Berro