Package Data | |
---|---|
Maintainer Username: | antonkomarev |
Maintainer Contact: | anton@komarev.com (Anton Komarev) |
Package Create Date: | 2018-08-23 |
Package Last Update: | 2022-08-26 |
Home Page: | https://komarev.com/sources/laravel-nova-ban |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-18 03:01:01 |
Package Statistics | |
---|---|
Total Downloads: | 179,056 |
Monthly Downloads: | 1,097 |
Daily Downloads: | 9 |
Total Stars: | 40 |
Total Watchers: | 4 |
Total Forks: | 6 |
Total Open Issues: | 2 |
Behind the scenes cybercog/laravel-ban is used.
Pull in the package through Composer.
$ composer require cybercog/laravel-nova-ban
use Cog\Contracts\Ban\Bannable as BannableContract;
use Cog\Laravel\Ban\Traits\Bannable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements BannableContract
{
use Bannable;
}
Bannable model must have nullable timestamp
column named banned_at
. This value used as flag and simplify checks if user was banned. If you are trying to make default Laravel User model to be bannable you can use example below.
$ php artisan make:migration add_banned_at_column_to_users_table
Then insert the following code into migration file:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddBannedAtColumnToUsersTable extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->timestamp('banned_at')->nullable();
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('banned_at');
});
}
}
Apply new migration.
Register Ban
and Unban
actions inside your Bannable
Model's Resource.
public function actions(Request $request)
{
return [
new \Cog\Laravel\Nova\Ban\Actions\Ban(),
new \Cog\Laravel\Nova\Ban\Actions\Unban(),
];
}
Please see CONTRIBUTING for details.
Run the tests with:
$ vendor/bin/phpunit
If you discover any security related issues, please email open@cybercog.su instead of using the issue tracker.
| Anton Komarev | | :---: |
Laravel Nova Ban contributors list
Feel free to add more alternatives as Pull Request.
Laravel Nova Ban
package is open-sourced software licensed under the MIT License by Anton Komarev.Fat Boss In Jail
image licensed under Creative Commons 3.0 by Gan Khoon Lay.CyberCog is a Social Unity of enthusiasts. Research best solutions in product & software development is our passion.