我尝试在ServiceProvider中获取用户ID,但成功登录后Auth :: user()返回null,这是哪里出了问题?
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use View;
use App\Offer;
use Auth;
class MasterPageProfileServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
dd(Auth::user()); // => null
$offersTrashed = Offer::onlyTrashed()->where('user_id',Auth::user()->id)->get();
View::share('offersTrashed', $offersTrashed);
}
}