The issue is that the role_id_custom foreign key is not defined in the role model. To fix this, add the role_id_custom foreign key to the role model's belongsToMany relationship method. Here's an updated version of the role model:
class role extends Model
{
protected $collection = 'roles';
public function users(){
return $this->belongsToMany(user::class, null, null, null, 'role_id_custom');
}
}
Note that the fourth parameter of the belongsToMany method is for the name of the pivot table, which is not needed in this case since the package uses a convention for naming pivot tables. The fifth parameter is for the name of the foreign key on the pivot table, which is set to role_id_custom to match the foreign key in the user model.
Also, make sure that the role_id_custom foreign key is set correctly in the users collection in MongoDB.
With these changes, the index method in the home controller should return the roles for the user with ID 1.