Skip to content

alessiovietri/team-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TeamAuth

A simple multi-auth package for Laravel 5.5/6

Table of Contents

Installation

composer require alextigaer/team-auth

Basic usage

To create a new role, just run the command:

php artisan team-auth:create RoleName

This command will:

  • Create 5 controllers inside the App\Http\Controllers\RoleName directory:
    • ForgotPasswordController
    • LoginController
    • RegisterController
    • ResetPasswordController
    • RoleNameController
  • Create 5 (+ 1 if the layouts\app.blade.php file is missing) views inside the resources\views\role_name directory:
    • passwords\email.blade.php
    • passwords\reset.blade.php
    • dashboard.blade.php
    • login.blade.php
    • register.blade.php
  • Create RoleName's model inside models' directory
  • Edit config\auth.php file to add the guard, the provider and the password resets for the role
  • Create 2 migrations:
    • create_role_names_table
    • create_role_names_password_resets_table
  • Create RoleNameSeeder and update DatabaseSeeder to call the generated seeder
  • Edit routes\web.php file to add the routes for the role

Options

If you want, you can use these options to customize the creation:

--r (default=y)

This option allows to choose if the users will be able to register to this role. Choosing the 'n' value, the RegisterController file and the register blade file won't be created and the register routes won't be added to the routes\web file.

Possible values: y (default), n

Description:

{--r=y : Choose if users can register to this role, or not [y/n]}

Usage:

// Create the role excluding the possibility to register
php artisan team-auth:create RoleName --r=n

--controllers (default=y)

This option allows to choose if the controllers should be created.

Possible values: y (default), n

Description:

{--controllers=y : Choose whether to create controllers, or not [y/n]}

Usage:

// Create the role without creating the controllers
php artisan team-auth:create RoleName --controllers=n

--views (default=y)

This option allows to choose if the views should be created.

Possible values: y (default), n

Description:

{--views=y : Choose whether to create views, or not [y/n]}

Usage:

// Create the role without creating the views
php artisan team-auth:create RoleName --views=n

--model (default=y)

This option allows to choose if the model should be created.

Possible values: y (default), n

Description:

{--model=y : Choose whether to create model, or not [y/n]}

Usage:

// Create the role without creating the model
php artisan team-auth:create RoleName --model=n

--config-auth (default=y)

This option allows to choose if the config\auth file should be edited.

Possible values: y (default), n

Description:

{--config-auth=y : Choose whether to edit config\auth file, or not [y/n]}

Usage:

// Create the role without editing the config\auth file
php artisan team-auth:create RoleName --config-auth=n

--migrations (default=y)

This option allows to choose if the migrations should be created.

Possible values: y (default), n

Description:

{--migrations=y : Choose whether to create migrations, or not [y/n]}

Usage:

// Create the role without creating the migrations
php artisan team-auth:create RoleName --migrations=n

--m (default=n)

This option allows to choose if the migrate should be run.

Possible values: y, n (default)

Description:

{--m=y : Choose whether to run the command migrate, or not [y/n]}

Usage:

// Create the role running the migrate command
php artisan team-auth:create RoleName --m=y

--seeder (default=y)

This option allows to choose if the seeder should be created.

Possible values: y (default), n

Description:

{--seeder=y : Choose whether to create seeder, or not [y/n]}

Usage:

// Create the role without creating the seeder
php artisan team-auth:create RoleName --seeder=n

--s (default=n)

This option allows to choose if the db:seed should be run.

Possible values: y, n (default)

Description:

{--s=y : Choose whether to run the command db:seed, or not [y/n]}

Usage:

// Create the role running the db:seed command
php artisan team-auth:create RoleName --s=y

--routes-web (default=y)

This option allows to choose if the routes\web file should be edited.

Possible values: y (default), n

Description:

{--routes-web=y : Choose whether to edit routes\web file, or not [y/n]}

Usage:

// Create the role without editing the routes\web file
php artisan team-auth:create RoleName --routes-web=n

Config

This package has its own configuration file. Inside that file, you'll find:

  • An entry to specify where your models are
  • The default values for the options. These values will be overwritten if you use the options by command line

Usage examples

  1. Create a role called 'Admin' without creating the seeder, but running the migrations:
php artisan team-auth:create Admin --m=y --seeder=n
  1. Create a role called 'Mod' preventing the users to register to this role:
php artisan team-auth:create Mod --r=n
  1. Create a role called 'SuperUser' creating only the model:
php artisan team-auth:create SuperUser --controllers=n --views=n --config-auth=n --migrations=n --seeder=n --routes-web=n

Contributing

Feel free to suggest anything! Use pulls or contact me :)

License

TeamAuth is licensed under the MIT license. Made with love, let's share it! :)

About

A simple multi-auth package for Laravel 5.5/6

Resources

License

Stars

Watchers

Forks

Packages

No packages published