xxxxxxxxxx
$this->data['emails'] = Meta::with(['metable' => function($query) {
$query->where('user_id' , 2);
}])->where('key','gmail')->groupBy('value')->get();
xxxxxxxxxx
Order::whereHas( 'meta', function($query) {
$query->where("key" , "gmail");
})->groupBy('meta.value')->get();
xxxxxxxxxx
public function meta(): MorphMany
{
return $this->morphMany($this->getMetaClassName(), 'metable');
}
xxxxxxxxxx
$this->data['emails'] = Meta::whereHasMorph('metable' , Order::class , function($query) {
$query->where('user_id' , 2);
})->where('key','gmail')->groupBy('value')->get();
xxxxxxxxxx
Meta::with('metable')->where('key','gmail')->groupBy('value')->get();
xxxxxxxxxx
$this->data['emails'] = Meta::whereHasMorph('metable' , Order::class , function($query) {
$query->where('user_id' , 2);
})->where('key','gmail')->groupBy('value')->get();