Skip to content

Users

Every person who signs in to Reshape is a User — whether they belong to a company, own several, or have no company at all. The User model is the busiest model in the codebase: it composes authentication, authorization, contacts, addresses, comments, reactions, themes, preferences, billing, and search into a single Eloquent model via traits.

The users management table

The User model

app/Models/User.php composes authentication, authorization, contacts, addresses, comments, reactions, themes, preferences, billing, and search via traits — HasAddresses, HasComments, HasContacts, HasCustomers, HasPreferences, HasRolesPermissions, HasSocials, HasThemes, plus Laravel's own Notifiable, SoftDeletes, and Scout's Searchable.

A few relations worth knowing about:

  • profile() — one UserProfile, holding the name, avatar, and banner (see Profile)
  • account() — a polymorphic Account used for billing (see Billing)
  • companies() / ownedCompanies() / currentCompany — see Companies
  • tenant — an accessor that resolves to the user's current company, or the user themselves if they have none

Users are soft-deleted and searchable via Laravel Scout (the database driver locally).

Status

php
enum UserStatus: string
{
    case Active = 'active';
    case Inactive = 'inactive';
    case Pending = 'pending';
}

New registrations start as Pending and flip to Active once their registration code is verified. Inactive is available for administrators to suspend an account without deleting it.

Managing users

Administrators, super administrators, and moderators can list, create, update, and delete users from the management area — the same data the Filament admin panel's Users resource and the frontend's management area both use.

Listing and filtering go through App\Query\UsersQuery, built on spatie/laravel-query-builder — the same pattern used by every other resource in Reshape.

A user's own record is loaded with roles scoped to their current company already attached.

Action

php
// Validate and create a user — assigns the StandardUser role and a billing account...
App\Actions\Fortify\CreateNewUser::create(array $input) : App\Models\User

This is Fortify's own CreatesNewUsers contract, implemented once and reused for both self-registration and admin-created users.

Authorization

Every management endpoint is gated by the role: middleware (super administrator, administrator, or moderator) and an explicit Gate::authorize() call in the controller — see Authorization for how roles and permissions work together.

In the admin panel

The Filament admin panel exposes the same data through a UserResource — see Filament.