samedi 16 novembre 2019

Laravel 5.8 - Eloquent relationship

I have following model structure in a Laravel app and I need to access the user via company as shown

enter image description here

I have tried the hasOneThrough method but later understood its not working for this structure

my plan is using something similar to bellow within item controller

        $item->whereHas('user', function ($query) use ($filters) {
            // this sell_diamonds represents the model Item::sell_diamonds
            $query->where('status', 'A');
        });

Please suggest me the best method to achieve this goal. Many thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire