I have a model Gallery
it has many Painters
and the painters have many Artworks
how to get the count of all Artworks
in a Gallery
?
This is the relationships for the gallery models:
class Gallery extends Model
{
public function painters()
{
return $this->hasMany('App\Painter');
}
}
The painters model:
class Painter extends Model
{
public function gallery()
{
return $this->belongsTo('App\Gallery');
}
public function artworks()
{
return $this->hasMany('App\Artwork');
}
}
The artwork model:
class Artwork extends Model
{
public function painter()
{
return $this->belongsTo('App\Painter');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire