1. Use Laravel ORM's associated model. For example, the student table has university_id, University::find(1)->hasManyStudent. In this case, * is obtained instead of the school's data. I want to obtain all of these two models. Data is like MYSQL's innerjoin
我想大声告诉你2017-05-16 16:52:04
class University
{
...
public function students()
{
return $this->hasMany(Student::class);
}
...
}
$university = University::with('students')->find(1);
dd($university);
You can see that both types of data are available, students
是放在university
in the relationships