weixin_33692284 2017-05-24 14:10 采纳率: 0%
浏览 123

将PHP数据放入HTML元素

I want to get my authenticated $userId as a value in an html element from the moment the function is executed (from the moment the user logs in) and place it in an input element in index.html

my AuthorizedAccessTokenController.php

class AuthorizedAccessTokenController
{
    public function getUser(Request $request)
    {
        //this is the key I want to place in my input
        $userId =  $request->user()->getKey();
        return $userId;
    }
}

this is the input in my index.html

<input type="text" value="the $userId">
  • 写回答

3条回答 默认 最新

  • weixin_33734785 2017-05-24 14:12
    关注

    To get authenticated user's ID you can use id() method with auth() helper or Auth facade:

    <input type="text" value="{{ auth()->id() }}">
    

    Or:

    <input type="text" value="{{ Auth::id() }}">
    
    评论

报告相同问题?