Thank you for your response.
The BelongsToMany field by default is of select type, or after adding searchable() parameter it is searchable.
I would like to replace this field with a regular email address field, I don't want others to see what email addresses are in the database.
When the user enters an email address, the system checks if such an address exists in the database, if so it writes a relation to the database. If the email does not exist in the database then a message is returned, e.g. "The user does not exist".
Code snippet:
BelongsToMany::make(__('Instructors'), 'teamInstructors', 'App\Nova\User')
->searchable()
->hideFromIndex()
->hideFromDetail(function (NovaRequest $request) {
$user = $request->user();
if ($user->isAdmin() || $user->id == $this->user_id) {
return false;
}
return true;
})
->display('email'),