relation = $relation; } public function apply($query) { $query->whereIn('contacts.id', $this->relation->pluck('id')->toArray()); } }