2017-11-25 04:09
采纳率: 100%
浏览 79

Laravel:$ request-> password中的'密码'是什么?

This question related to article Laravel 5.4: Login with Username or Email. There, it was suggested the next method of custom authentication:

protected function credentials(Request $request){
    $field = filter_var($request->get($this->username()), FILTER_VALIDATE_EMAIL)
        ? $this->username()
        : 'username';

    return [
        $field => $request->get($this->username()),
        'password' => $request->password,

What means '->password' in $request->password? Field's name attribute? What if my password field's name is passoword1, for example?

<input type="password" name="password1" required>

图片转代码服务由CSDN问答提供 功能建议

此问题与文章 Laravel 5.4:使用用户名或电子邮件登录。 在那里,建议使用下一种自定义身份验证方法:

 $ field = filter_var($ request-&gt; get($  this-&gt; username()),FILTER_VALIDATE_EMAIL)
?  $ this-&gt; username()
 return [
 $ field =&gt;  $ request-&gt; get($ this-&gt; username()),
'password'=&gt;  $ request-&gt;密码,

$ request-&gt; password <中的' - &gt;密码'是什么意思 /代码>? Field的 name 属性? 如果我的密码字段的 name passoword1 ,例如?

 &lt; input type =“password”name = 需要“password1”&gt; 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douquanqiao6788 2017-11-25 04:25

    In Laravel 5.4 you can get input from the $request using


    for input like

    <input type='text' name='password'>

    For your example with name="password1" you would use $request->input('password1').

    Here are some helpful documentation links :)

    解决 无用
    打赏 举报
  • doufei0933 2017-11-25 07:24

    It is called dynamic input properties. Whatever parameters exist in the request can be accessed from Laravel Request instance Illuminate\Http\Request. In this case the input parameters exist on this object as props. They are dynamic props so you get the point. The Request instance has all sorts of method to deal with all kind of things.

    A couple ways to get input data, like

    <input type="text" name="a">
    <input type="text" name="b">
    public function methodName(Request $request){
       $a = $request->a;
       $a = $request->b;
       // Or
       $input_params = $request->all(); // input parameters array ['a' => 'some value', 'b' => 'some other value']
       // Or
       $input_a = $request->input('a');
       // check if input exists

    There are very nice examples and clear details here Illuminate\Http\Request

    解决 无用
    打赏 举报

相关推荐 更多相似问题