tyler36/isadmin

A simple way to define an administator, with a auth.admin middleware

0.2 2020-03-09 01:16 UTC

This package is auto-updated.

Last update: 2024-11-13 00:24:22 UTC


README

Latest Version on Packagist Total Downloads Build Status StyleCI

This is where your description should go. Take a look at contributing.md to see a to do list.

Installation

Via Composer

$ composer require tyler36/isadmin

Update your .ENV file to include the administators email. Use a comma-separated string if there are multuple accounts.

AUTH_ADMINS_ADMINISTRATORS=admin@example.com

The default configuration might not be suitable for everyone. To change it, publish the configuration using the following command.

$ php artiasn vendor:publish --provider=Tyler36\isAdmin\isAdminServiceProvider

Usage: Middleware

  1. Register the middleware in the app/Http/Kernel.php. You can change the middleware short name by replacing auth.admin.
    protected $routeMiddleware = [
        ...
        'auth.admin'    => \tyler36\isAdmin\isAdminMiddleware::class,
        ...
    ];

Usage: Trait

  1. Add the trait to your user model
class User extends Authenticatable
{
    use Tyler36\isAdmin\isAdminTrait;
    ....
  1. You can know verify users on a model
$user = new User();

// Check if user is an admin
$user->isAdmin();

// Check if user is verified
$user->isVerified();

// Check if another user model ($someone) is an admin
$user->isAdmin($someone);

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.