I have one table championships and one table users. Also I have same models (championship and user).
In one championship may be one main judge, main secretary and judge operator. All of them also are roles in my application and stored in roles table.
I have created new a resource Championship with 3 belongsTo fields. All of them searchable.
BelongsTo::make('Main judge', 'mainJudge', User::class)
->onFormsAndDetail()
->searchable(),
BelongsTo::make('Main secreatary', 'mainSecretary', User::class)
->onFormsAndDetail()
->searchable(),
BelongsTo::make('Judge operator', 'judgeOperator', User::class)
->onFormsAndDetail()
->searchable(),
During the search I need filter query in order to search give only users with same roles.
For example, during the search main judge I have to include next filter into query
select *
from users u
join users_roles ur on u.id = ur.user_id
join roles r on ur.role_id = r.id
where r.alias = 'judge'
I have found some methods into app/Nova/Resource.php such as relatableQuery but how can I use it inside User resource if I have 3 fields with User.