#How do Controller know what model is it using ?

9 messages · Page 1 of 1 (latest)

vague basin
#

this is the validate code i found on the website


 public function customLogin(Request $request)
    {
        $request->validate([
            'email' => 'required',
            'password' => 'required',
        ]);
   
        $credentials = $request->only('email', 'password');
        if (Auth::attempt($credentials)) {
            return redirect()->intended('dashboard')
                        ->withSuccess('Signed in');
        }
  
        return redirect("login")->withSuccess('Login details are not valid');
    }
smoky juniper
#

Per my response in the general channel: The controller doesn't know. The Auth::attempt uses the model defined in config/auth.php if I remember correctly

wise bridge
#

@vague basin Please format your code as per the #rules

crisp portal
#

Could you format it like this
```php
// Your PHP Code
```

```js
// Your JavaScript Code
```

And also how does controller know what model is it using for what?

vague basin
wind musk
#

i believe, if you look into the Auth source code, it will try to make reference into user model

#

because, usually a website only needs to authorize from user data. like login or regist

random arrow