vendredi 2 juillet 2021

how to get relation model inside the relation Laravel Eloquent

I want to get the object of the relationship object inside the relationship in laravel i.e

public function skills() {
        return $this->hasMany("App\JobSkill", "object_id", "id")->where('object_type','=', 'j');
    }
    $query->with(['skills' => function ($sql) {
           echo "<pre>";
           print_r($sql->get()->toArray());
           die;
    }])

I use this method but I get all the data of this table instead of this relation object which I defined.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire