@thedocrow0124 Did you just copy-paste the code into your AppServiceProvider? If so, remember that you have to qualify Builder, otherwise it won’t recognise the class. Do you have a use Illuminate\Database\Query\Builder statement at the top of the file?
Edit: Also, there’s a return statement missing in the macro. Should be:
public function boot() {
Builder::macro('whereRelationIn', function ($relation, $column, $array) {
return $this->whereHas(
$relation, fn($q) => $q->whereIn($column, $array)
);
});
}
Without the return statement, running the macro will return nothing, and then you end up trying to call ->get() on nothing.