GithubHelp home page GithubHelp logo

jeffersonsimaogoncalves / laravel-nova-ban Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cybercog/laravel-nova-ban

0.0 0.0 0.0 32 KB

Laravel Nova Ban simplify blocking and banning Eloquent models.

Home Page: https://komarev.com/sources/laravel-nova-ban

License: MIT License

PHP 100.00%

laravel-nova-ban's Introduction

Laravel Nova Ban

cog-laravel-nova-ban

Releases StyleCI License

Introduction

Behind the scenes cybercog/laravel-ban is used.

laravel-nova-ban-preview

Contents

Installation

Pull in the package through Composer.

composer require cybercog/laravel-nova-ban

Usage

Prepare bannable model

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

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 Actions in Nova Resource

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(),
    ];
}

Contributing

Please see CONTRIBUTING for details.

Testing

Run the tests with:

vendor/bin/phpunit

Security

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

Contributors

@antonkomarev
Anton Komarev
@ sergiy-petrov
Sergiy Petrov
@mvdnbrk
Mark van den Broek
@tooshay
Roy Shay

Laravel Nova Ban contributors list

Alternatives

Feel free to add more alternatives as Pull Request.

License

About CyberCog

CyberCog is a Social Unity of enthusiasts. Research best solutions in product & software development is our passion.

CyberCog

laravel-nova-ban's People

Contributors

antonkomarev avatar jeffersonsimaogoncalves avatar mvdnbrk avatar tooshay avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.