Laravel 5 eloquent - add child field to parent model
问题 I have a user model which has a child relationship called teacher. How can I add a field from the related teacher model to the dataset returned of the parent user model? I would like the user model returned to have a structure like below: user.firstname user.lastname user.teacher.address I have tried using the following and variations thereof with no success: $query->select('firstname', 'lastname') ->addSelect( \DB::raw('teachers.address AS address') ); user.php model: use Notifiable; use