dimanche 18 novembre 2018

How to retrieve data through model?

I have Order model with another relation OrderPhoto:

public function OrderPhoto()
{
  return $this->hasMany('App\OrderPhoto');
}

In turn OrderPhoto model has relation:

public function Photo()
{
  return $this->belongsToMany('App\Photo');
}

So, how to get data from OrderModel with related data from third model Photo?

I guess this:

Order::with("OrderPhoto.Photo")->get();

to retrieve only data from Photo model for each Order



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire