class User extends Eloquent
{
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function profile()
{
return $this->morphTo();
}
}
# создание/сохранение моделей
$doctor = App\Doctor::create();
$user = new App\User();
$user->profile()->associate($doctor);
$user->save();
# Поиск в 5.8
$users = App\User::whereHasMorph('profile', ['App\Doctor'], function($query) {
$query->where('specialism', 'Hirurg');
})->get();