i have three table
tours (id , body) -> assume a record is (id: 1, body: somethings)
metas (id , key)-> assume a record is (id: 1, key: tour_price)
metables (meta_id , metable_id, metable_type, value) -> assume a record is: (meta_id: 1, metable_id: 1 , metable_type: App\Tour , value : 250000)
i want filter results with meta value like this :
where tour_price is 250000 ?
also my Tour model has function like this :
public function metas()
{
return $this->morphToMany('App\Meta', 'metable')->withPivot('value');
}
i tried this :
$tours = Tour::whereHas('metas', function($q){
$q->where('key','tour_price');
})->get()
it just return tours with tour_price key in pivot table. i want something like this :
$tours = Tour::whereHas('metas', function($q){
$q->where('key.tour_price','250000');
})->get()
but it did not work .
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire