https://github.com/cybercog/laravel-nova-ban
Laravel Nova Ban simplify blocking and banning Eloquent models.
https://github.com/cybercog/laravel-nova-ban
access arrest ban block cog forbid jail justice laravel laravel-nova nova prison restrict security user
Last synced: 2 months ago
JSON representation
Laravel Nova Ban simplify blocking and banning Eloquent models.
- Host: GitHub
- URL: https://github.com/cybercog/laravel-nova-ban
- Owner: cybercog
- License: mit
- Created: 2018-08-23T15:39:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-26T04:19:21.000Z (about 3 years ago)
- Last Synced: 2024-08-08T23:16:14.288Z (about 1 year ago)
- Topics: access, arrest, ban, block, cog, forbid, jail, justice, laravel, laravel-nova, nova, prison, restrict, security, user
- Language: PHP
- Homepage: https://komarev.com/sources/laravel-nova-ban
- Size: 31.3 KB
- Stars: 40
- Watchers: 4
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Laravel Nova Ban

## Introduction
Behind the scenes [cybercog/laravel-ban](https://github.com/cybercog/laravel-ban) is used.

## Contents
- [Installation](#installation)
- [Usage](#usage)
- [Prepare bannable model](#prepare-bannable-model)
- [Prepare bannable model database table](#prepare-bannable-model-database-table)
- [Register Ban Actions in Nova Resource](#register-ban-actions-in-nova-resource)
- [Contributing](#contributing)
- [Testing](#testing)
- [Security](#security)
- [Contributors](#contributors)
- [Alternatives](#alternatives)
- [License](#license)
- [About CyberCog](#about-cybercog)## Installation
Pull in the package through Composer.
```shell script
composer require cybercog/laravel-nova-ban
```## Usage
### Prepare bannable model
```php
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;
}
```### Prepare bannable model database table
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.
#### Create a new migration file
```shell script
php artisan make:migration add_banned_at_column_to_users_table
```Then insert the following code into migration file:
```php
timestamp('banned_at')->nullable();
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('banned_at');
});
}
}
```Apply new migration.
### Register Ban Actions in Nova Resource
Register `Ban` and `Unban` actions inside your `Bannable` Model's Resource.
```php
public function actions(Request $request)
{
return [
new \Cog\Laravel\Nova\Ban\Actions\Ban(),
new \Cog\Laravel\Nova\Ban\Actions\Unban(),
];
}
```## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Testing
Run the tests with:
```shell script
vendor/bin/phpunit
```## Security
If you discover any security related issues, please email open@cybercog.su instead of using the issue tracker.
## Contributors
| 
Anton Komarev | 
Sergiy Petrov | 
Mark van den Broek | 
Roy Shay |
| :---: | :---: | :---: | :---: |[Laravel Nova Ban contributors list](../../contributors)
## Alternatives
*Feel free to add more alternatives as Pull Request.*
## License
- `Laravel Nova Ban` package is open-sourced software licensed under the [MIT License](LICENSE) by [Anton Komarev].
- `Fat Boss In Jail` image licensed under [Creative Commons 3.0](https://creativecommons.org/licenses/by/3.0/us/) by Gan Khoon Lay.## About CyberCog
[CyberCog] is a Social Unity of enthusiasts. Research best solutions in product & software development is our passion.
- [Follow us on Twitter](https://twitter.com/cybercog)
[Anton Komarev]: https://komarev.com
[CyberCog]: https://cybercog.su