How to exlclude user role (customer) in relation manager?

The case is want to exclude user customers in the list

I tried this but not working

whole code

<?php

namespace App\Filament\Admin\Resources\MerchantResource\RelationManagers;

use Filament\Forms;
use Filament\Tables;
use App\Enums\User\Role;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Resources\RelationManagers\RelationManager;

class UsersRelationManager extends RelationManager
{
    protected static string $relationship = 'users';

    public static function getEloquentQuery(): Builder
    {
        return static::getEloquentQuery()->where('role', '!=', Role::Customer->value);
    }

    //I just removed the table for this question
}
Solution
Solved:

instead I add this to the table

->modifyQueryUsing(fn (Builder $query) => $query->where('role','!=', Role::Customer->value))
Was this page helpful?