I have two entities; Part and PartStock. There is a one-to-one relationship between them:
Part model:
public function partStock()
{
return $this->hasOne('App\PartStock');
}
PartStock model:
public function part()
{
return $this->belongsTo('App\Part');
}
How can I write a global scope for Part that has a where filter for values on the PartStock relation and Part entity itself?
$query->where(???, '>', 'reorder');
$query->whereHas('partStock', function($q) {
$q->where('count', '>', ???);
});
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire