An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# Laravel Nova Ban

![cog-laravel-nova-ban](https://user-images.githubusercontent.com/1849174/44558292-ffc0a080-a74b-11e8-8699-a79de865910d.png)


Releases
StyleCI
License

## Introduction

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

![laravel-nova-ban-preview](https://user-images.githubusercontent.com/1849174/44547881-1b648080-a725-11e8-9472-bad1486c06f0.png)

## 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

| ![@antonkomarev](https://avatars.githubusercontent.com/u/1849174?s=110)
Anton Komarev
| ![@ sergiy-petrov ](https://avatars.githubusercontent.com/u/8986207?s=110)
Sergiy Petrov
| ![@mvdnbrk](https://avatars.githubusercontent.com/u/802681?s=110)
Mark van den Broek
| ![@tooshay](https://avatars.githubusercontent.com/u/703589?s=110)
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)

CyberCog

[Anton Komarev]: https://komarev.com
[CyberCog]: https://cybercog.su