Installs: 1 250

Dependents: 18

Suggesters: 0

Security: 0

Type:package

0.4.19 2024-03-01 17:36 UTC

This package is auto-updated.

Last update: 2024-03-01 17:37:30 UTC


README

Package adds users, basic auth, users CRUD.

Installation

1. Require package in your composer.json:

composer require studiocreativateam/auth

2. Run below command to overwrite config/auth.php settings. To use User model from auth package

php artisan vendor:publish --provider="SCTeam\Auth\SCTeamServiceProvider" --tag="config-auth" --force

3. Run revisions migration:

php artisan migrate

4. Compile views:

npm run dev

6. (Optional) run seeds:

php artisan db:seed --class "SCTeam\Auth\Database\Seeders\PermissionsAndRolesSeeder"
php artisan db:seed --class "SCTeam\Auth\Database\Seeders\UsersSeeder"

Publishing

You can publish file by using command

php artisan vendor:publish --provider="SCTeam\Auth\SCTeamServiceProvider" --tag="{{tag1|tag2}}"

Available tags:

  • migrations
  • breadcrumbs
  • views
  • config

Config

Roles

You can add roles for package by setting roles array in config.php

    'roles' => [
        SCTeam\Auth\Enums\UserRole::Admin => SCTeam\Auth\Enums\UserRole::class,
        SCTeam\Auth\Enums\UserRole::User => SCTeam\Auth\Enums\UserRole::class,
    ],

Permissions

You can add permissions for package by setting permissions per user role array in config.php. Key in array has to be a role name and values can be either specific value from permission enum or whole enum class.

    'permissions' => [
        UserRole::Admin => [
            UserPermissions::class, //enum class gives permissions to all values
        ],
        UserRole::User => [
            UserPermissions::UserReadSelf, //gives permission to specific value
            UserPermissions::UserUpdateSelf,
            UserPermissions::UserDeleteSelf,
            UserPermissions::UserChangeStatusSelf,
        ]
    ],

Features

SCTeamAuth facade

  • List of all available roles: \SCTeamAuth::userRoles()
  • List of all available roles as select array: \SCTeamAuth::userRolesAsSelectArray()