November 18, 2025

Laravel MultiPersona: Simple Context Switching for Users

package
Laravel MultiPersona: Simple Context Switching for Users

Most apps need users to wear multiple hats — admin, client, company A, company B… Instead of creating multiple accounts or hacking guards, Laravel MultiPersona By @GrazuleX gives you a clean way to switch contexts with one user.

A “persona” is just a context: role, company ID, permissions, whatever you need. Users can have many personas, and they can switch instantly.

What it gives you

  • A HasPersonas trait for the User model
  • Middleware to enforce persona context
  • A Persona Manager service
  • Helper functions like persona()
  • Full event system for persona lifecycle

Why it’s useful

  • Perfect for multi-tenant SaaS
  • Great for role/state switching
  • No UI forced on you — pure backend logic
  • No extra login sessions or guard gymnastics

Quick example

$current = persona(); $all = auth()->user()->personas; auth()->user()->switchToPersona($persona);

Simple, clean, and built for real-world apps.

Did you find this article helpful? Share it!