bmatovu / multi-auth
Laravel Multi Authentication
Installs: 23 535
Dependents: 0
Suggesters: 0
Security: 0
Stars: 179
Watchers: 10
Forks: 25
Open Issues: 6
Requires
- php: ^8.1
- illuminate/auth: ^10.0|^11.0
- illuminate/console: ^10.0|^11.0
- illuminate/notifications: ^10.0|^11.0
- illuminate/routing: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.14
- orchestra/testbench: ^8.0|^9.0
- phpunit/phpunit: ^10.0|^11.0
Suggests
- inertiajs/inertia-laravel: The Laravel adapter for Inertia.js.
- laravel/breeze: Min. Laravel auth scaffolding with Blade and Tailwind.
- tightenco/ziggy: Use your Laravel named routes in Javascript
- dev-master / 12.x-dev
- v12.1.0
- v12.0.0
- 11.x-dev
- v11.0.0
- 10.x-dev
- v10.4.0
- v10.3.0
- v10.2.0
- v10.1.0
- v10.0.0
- 9.x-dev
- v9.0.0
- 8.x-dev
- v8.0.0
- 7.x-dev
- v7.3.0
- v7.2.0
- v7.1.0
- v7.0.0
- 6.x-dev
- v6.2.0
- v6.1.0
- v6.0.0
- 5.x-dev
- v5.1.1
- v5.1.0
- v5.0.0
- 4.x-dev
- v4.0.0
- 3.x-dev
- v3.0.0
- 2.x-dev
- v2.1.0
- v2.0.0
- 1.x-dev
- v1.2.0
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-dependabot/composer/guzzlehttp/psr7-2.5.0
This package is auto-updated.
Last update: 2024-11-23 19:53:53 UTC
README
This package gives you the ability to separate user areas in your application.
E.g, an ecommerce application with customers, sellers, and administrators user areas using auth guards
Prerequisite
This package only extends the official laravel/breeze
starter kit, it doesn't regenerate the frontend assets [js, css - tailwind, vite, ...]
Therefore, you need to use it after scaffolding basic auth using Breeze.
Breaking Changes
For old versions (Laravel v9 and below) refer to v11
Installation
composer require bmatovu/multi-auth --dev
Scaffolding
php artisan multi-auth:install admin
Register service provider
config/app.php
'providers' => [
/*
* Package Service Providers...
*/
+ App\Modules\Admins\AdminServiceProvider::class,
],
Register JS entry point in Vite (Inertia - Vue, React)
vite.config.js
export default defineConfig({ plugins: [ laravel({ - input: 'resources/js/app.js', + input: [ + 'resources/js/app.js', + 'resources/js/Admins/app.js', + ], - ssr: 'resources/js/ssr.js', + ssr: [ + 'resources/js/ssr.js', + 'resources/js/Admins/ssr.js', + ], refresh: true, }), ... ], });
Read more about Inertia Server Side Rendering
Recompile frontend assets
npm run build
Run Database Migrations
php artisan migrate
Possible approaches for separating user areas
Using sub-domains
Separate user areas by sub-domains.
I would use separate repos for each sub-domain
Using URLs*
Separate user areas based on URLs. Restricted with auth guards
* What this package offers
Using roles
Restrict access based on the user's roles and permissions
I'd stay away from this approach as it'd more complex to maintain for large projects