I'm using JWT (Json Web Token) auth in my Laravel 5.2 app. How can I get user_id from the token inside JavaScript tags in my blade ??
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can use JWTAuth like Auth:
After you authenticate, get the user
$user = JWTAuth::user();
then pass data to view:
return view('posts', ['user' => $user]);
and you can use the data in blade:
{{ echo $user->id; }}