How to set company_id in role_user table

I'm able to assign roles and everything works great, but the currently logged in company_id (multi-tenancy) doesn't get saved to the pivot table (remains null)

Is there a way to set the pivot table with the currently logged in company_id when assigning roles to a user?

I'm using a UserResource to do this, and I just add the roles selector component using:

Forms\Components\Select::make('roles') ->label(__('Role(s) (Must select at least 1)')) ->required() ->relationship( name: 'roles', titleAttribute: 'name', modifyQueryUsing: fn (Builder $query) => $query->whereNotIn('perm_name', array('admin', 'super-admin')), ) ->native(false) ->multiple() ->searchable() ->preload(),

The company itself will be assigning the roles (not a site admin)
Was this page helpful?