New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

26b/laravel-account-status

Laravel package for account statuses
2,269 1
Install
composer require 26b/laravel-account-status
Latest Version:v1.0.1
PHP:^7.4 || ^8.0
Laravel:8 · 9
License:MIT
Last Updated:Apr 12, 2023
Links: GitHub  ·  Packagist
Maintainer: csrui

Laravel Account Status

Configurable statuses for your user accounts.

  • Handle access to application conditionally.
  • Artisan command to toggle status for given user.
  • Artisan command to activate X accounts.

Getting started

Require the package

composer require 26b/laravel-account-status

To setup your database using the builtin migration.

php artisan vendor:publish --tag=account-status-migrations
php artisan migrate

Now that you have migrated, you might want to set your existing users to the ACTIVE state. You can do this X at a time.

php artisan account-status:activate 100

Usage

To protect your routes and redirect to the account status page you can add the builtin middleware to your kernel or individually to your routes.

    \TwentySixB\LaravelAccountStatus\Http\Middleware\EnsureAccountActive::class,

Commands

Toggle You can change the status for a given user ID like this.

php artisan account-status:toggle ID SUSPENDED

Activate When you have, for example, QUEUED users you can change their status to ACTIVE by running the command

php artisan account-status:activate 50

Factories

You can add some states to your factories to test your app.

$user = User::factory()->queued()->make();
use TwentySixB\LaravelAccountStatus\AccountStatus;

...

/**
 * Indicate that the model's is in a queued state.
 *
 * @return \Illuminate\Database\Eloquent\Factories\Factory
 */
public function queued()
{
    return $this->state(
        function (array $attributes) {
            return [
                'status' => AccountStatus::QUEUED,
            ];
        }
    );
}

Customizing

Publish the configuration file should you need to customise it.

php artisan vendor:publish --tag=account-status-config

To customize the "account blocked template" you can publish the views and change them at your will.

php artisan vendor:publish --tag=account-status-views

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

660,512,042 9,702
laravel/framework

The Laravel Framework.

625,568,548 34,998
laravel/tinker

Powerful REPL for the Laravel framework.

531,591,559 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

450,320,528 608
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

424,642,029 4,662

Version History

Version Released PHP Laravel License
v1.0.1 ^7.4 || ^8.0 ^8.0 || ^9.0 MIT
v1.0.0 ^7.4 || ^8.0 ^8.0 || ^9.0 MIT