depart_id = $depart_id; $this->is_main = $is_main; $this->user_id = $user_id; } public function apply(Builder $builder, Model $model) { if(! $this->is_main) { $depart_id = $this->depart_id; $user_id = $this->user_id; $builder->where(function ($query) use ($depart_id,$user_id){ $query->whereIn('depart_id', $depart_id) ->orWhere('crt_id', $user_id); }); } } }