where('type', $type) ->when($type == 1, function ($builder) { $user = Auth::user(); if ($user instanceof AdminUser && ! $user->isAdministrator() && ! $user->view_all_bases) { $builder->whereRaw("id in (select base_id from admin_user_bases where user_id = {$user->id})"); } }); } public function parent($parent) { return $this->where('parent_id', $parent); } public function name($name) { return $this->where('name', 'like', '%'.$name.'%'); } public function industry($industry){ return $this->where('industry_key', $industry); } }