lundi 24 octobre 2016

Laravel login users with two model

Hi this is my users model structure,

'name' => 'required|max:255',
'phone' => 'required|numeric',
'email' => 'required|email|max:255|unique:users',

And this is Profile model structure

'username' => 'required|max:255',
'password' => 'required|min:6|confirmed',

I need keep up on this structure and login with username and password , because some users can not have login and cant take user and password .

I change Auth to this

public function create(array $data)
{
     $user = User::create([
         'email' => $data['email'],
         'phone' => $data['phone'],
     ]);
     $user->profile()->create(['name' => $data['name'],'password' =>bcrypt($data['password'])]);
     return $user;
}

and now how can i do login :| ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire