I would like to know if the way I'm working with cache is correct and if there is anything more practical for it.
Follow 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
]);
}
}
Thank you for understanding.