'object' ]; public function scopeManualMethod() { return $this->where('unique_code','LIKE','%MANUAL%'); } public function scopeAutomaticMethod() { return $this->where('unique_code','NOT LIKE','%MANUAL%'); } public function scopeRoutefilter(Builder $q) :Builder{ return $q->when(request()->routeIs('admin.payment.automatic.index'),function($query) { return $query->automaticMethod(); })->when(request()->routeIs('admin.payment.manual.index'),function($query) { return $query->manualMethod(); }); } }