Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

This is a valid hasManyThrough relationship.
To get the garage you can do

security->car->garage;

or add a shortcut in the model

class Securities extends Eloquent
{
    public function cars()
    {
        return $this->hasOne('cars');
    }

    public function garage()
    {
        return $this->car->garage;
    }
}

when eager loading (do it) make this

Security::with('car', 'car.garage')->...->get();
0

Sign in to participate in this thread!

Eventy

Your banner here too?

poholack poholack Joined 15 Dec 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.