class User extends Eloquent
{
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function profile()
{
if ($this->role == 'doctor') {
return $this->hasOne('App\Doctor', 'user_id', 'id')
->withDefault();
}
if ($this->role == 'pacient') {
return $this->hasOne('App\Pacient', 'user_id', 'id')
->withDefault();
}
return null;
}
}