laravel ORM problem
为情所困
为情所困 2017-05-16 16:50:04
0
1
807

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

为情所困
为情所困

reply all(1)
我想大声告诉你
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是放在universityin the relationships

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template