PHPackages                             vildanbina/laravel-blocker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. vildanbina/laravel-blocker

ActivePackage[Authentication &amp; Authorization](/categories/authentication)

vildanbina/laravel-blocker
==========================

00Blade

Since Aug 30Pushed 4y ago1 watchersCompare

[ Source](https://github.com/vildanbina/laravel-blocker)[ Packagist](https://packagist.org/packages/vildanbina/laravel-blocker)[ RSS](/packages/vildanbina-laravel-blocker/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Blocker
===============

[](#laravel-blocker)

[![Latest Stable Version](https://camo.githubusercontent.com/8451171ea7fd0e92773027ad4a207008a2604e6a3ff7d6196d4b6980e3ad5e14/68747470733a2f2f706f7365722e707567782e6f72672f76696c64616e62696e612f6c61726176656c2d626c6f636b65722f762f737461626c652e737667)](https://packagist.org/packages/vildanbina/laravel-blocker)[![Total Downloads](https://camo.githubusercontent.com/4cbafbe3c10e77fbf6ba0aeca89de54f9e558b05e763d4ed3e22d34e1aa5bb52/68747470733a2f2f706f7365722e707567782e6f72672f76696c64616e62696e612f6c61726176656c2d626c6f636b65722f642f746f74616c2e737667)](https://packagist.org/packages/vildanbina/laravel-blocker)[![Travis-CI Build](https://camo.githubusercontent.com/9ed52f8566dad74bbb02aa4b56e9692879743f8e9fb89d87323be9e7aa045bbd/68747470733a2f2f7472617669732d63692e6f72672f76696c64616e62696e612f6c61726176656c2d626c6f636b65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vildanbina/laravel-blocker)[![StyleCI](https://camo.githubusercontent.com/1ab92c0e3c5352c41c2b48b83569cd5c9c5c645d216a444355d3b4072554a931/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137313339303630372f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/171390607)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1e2d6f44f98773ab66063859f922ebd772ec4ca561d9fd1ba6fd99d70a28a5e8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f76696c64616e62696e612f6c61726176656c2d626c6f636b65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/vildanbina/laravel-blocker/?branch=master)[![Latest Unstable Version](https://camo.githubusercontent.com/54483833c2dd0436fcfa6569b31d774c1cf220f8fcae384d91191f1a3a5a8541/68747470733a2f2f706f7365722e707567782e6f72672f76696c64616e62696e612f6c61726176656c2d626c6f636b65722f762f756e737461626c65)](https://packagist.org/packages/vildanbina/laravel-blocker)[![All Contributors](https://camo.githubusercontent.com/4e96de37ea680371089642c8762ee051f42043eb64b50c4119a4e48970a2d434/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f616c6c5f636f6e7472696275746f72732d312d6f72616e67652e7376673f7374796c653d666c61742d737175617265)](#contributors)[![License](https://camo.githubusercontent.com/b733aa17395800258437d3b53857627d8cb4a109c61fed802a6415f2be4de5d2/68747470733a2f2f706f7365722e707567782e6f72672f76696c64616e62696e612f6c61726176656c2d626c6f636b65722f6c6963656e7365)](https://packagist.org/packages/vildanbina/laravel-blocker)

- [About](#about)
- [Features](#features)
- [Requirements](#requirements)
    - [Required Packages](#required-packages)
- [Installation Instructions](#installation-instructions)
    - [Publish All Assets](#publish-all-assets)
    - [Publish Specific Assets](#publish-specific-assets)
- [Usage](#usage)
- [Configuration](#configuration)
    - [Environment File](#environment-file)
- [Routes](#routes)
- [Screenshots](#screenshots)
- [File Tree](#file-tree)
- [License](#license)

### About

[](#about)

Laravel Blocker (LaravelBlocker) is a middleware interface to block users, emails, ip addresses, domain names, cities, states, countries, continents, and regions from using your application, logging in, or registering. The types of items to be blocked can be extended to what you think via a seed. The items you are blocking have a CRUD interface along with a softdeletes interface.

Can work out the box with or without the following roles packages:

- [vildanbina/laravel-roles](https://github.com/vildanbina/laravel-roles)
- [spatie/laravel-permission](https://github.com/spatie/laravel-permission)
- [Zizaco/entrust](https://github.com/Zizaco/entrust)
- [romanbican/roles](https://github.com/romanbican/roles)
- [ultraware/roles](https://github.com/ultraware/roles)

### Features

[](#features)

LaravelBlocker FeaturesEasy to use middlware that can be applied directly to controller and/or routesFull CRUD (Create, Read, Update, Delete) interface for adding blocked itemsLots of easily customizable options through .env file variablesSeeded blocked types with ability to add own published seedsSeeded blocked items with ability to add own published seedsSoftdeletes with easy to use restore and destroy interfaceUses [laravelcollective/html](https://github.com/LaravelCollective/html) package for secure HTML formsUses [eklundkristoffer/seedster](https://github.com/eklundkristoffer/seedster) for optional default seedsMakes use of proper custom request classes structureCan use pagination if desired for dashboardsFront end Bootstrap version can be changedUses [localization](https://laravel.com/docs/5.8/localization) language filesAjax search for blocked itemsConfigurable blocked action### Requirements

[](#requirements)

- [Laravel 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, or 5.8+](https://laravel.com/docs/installation)

#### Required Packages

[](#required-packages)

(included in this package)

- [laravelcollective/html](https://packagist.org/packages/laravelcollective/html)
- [eklundkristoffer/seedster](https://github.com/eklundkristoffer/seedster)

### Installation Instructions

[](#installation-instructions)

1. From your projects root folder in terminal run:

    Laravel 5.8+ use:

    ```
        composer require vildanbina/laravel-blocker
    ```

    Laravel 5.7 and below use:

    ```
        composer require vildanbina/laravel-blocker:v1.0.6

    ```
2. Register the package

- Laravel 5.5 and up Uses package auto discovery feature, no need to edit the `config/app.php` file.
- Laravel 5.4 and below Register the package with laravel in `config/app.php` under `providers` with the following:

```
    'providers' => [
        Collective\Html\HtmlServiceProvider::class,
        vildanbina\LaravelBlocker\LaravelBlockerServiceProvider::class,,
    ];
```

In `config/app.php` section under `aliases` with the following:

```
    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class,
```

3. Publish the packages views, config file, assets, and language files by running the following from your projects root folder:

#### Publish All Assets

[](#publish-all-assets)

```
    php artisan vendor:publish --provider="vildanbina\LaravelBlocker\LaravelBlockerServiceProvider"
```

#### Publish Specific Assets

[](#publish-specific-assets)

```
    php artisan vendor:publish --tag=laravelblocker-config
    php artisan vendor:publish --tag=laravelblocker-views
    php artisan vendor:publish --tag=laravelblocker-lang
    php artisan vendor:publish --tag=laravelblocker-migrations
    php artisan vendor:publish --tag=laravelblocker-seeds
```

### Usage

[](#usage)

##### From Route File:

[](#from-route-file)

- You can include the `checkblocked` in a route groups or on individual routes.

###### Route Group Example:

[](#route-group-example)

```
    Route::group(['middleware' => ['web', 'checkblocked']], function () {
        Route::get('/', 'WelcomeController@welcome');
    });
```

###### Individual Route Examples:

[](#individual-route-examples)

```
    Route::get('/', 'WelcomeController@welcome')->middleware('checkblocked');
    Route::match(['post'], '/test', 'Testing\TestingController@runTest')->middleware('checkblocked');
```

##### From Controller File:

[](#from-controller-file)

- You can include the `checkblocked` in the contructor of your controller file.

###### Controller File Example:

[](#controller-file-example)

```
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
       $this->middleware('checkblocked');
    }
```

### Configuration

[](#configuration)

There are many configurable options which have all been extended to be able to configured via `.env` file variables. Editing the configuration file directly is not needed becuase of this.

- See config file: [laravelblocker.php](https://github.com/vildanbina/LaravelBlocker/blob/development/src/config/laravelblocker.php).
- See default Types Seed: [DefaultBlockedTypeTableSeeder.php](https://github.com/vildanbina/LaravelBlocker/blob/development/src/database/seeds/DefaultBlockedTypeTableSeeder.php)
- See default Blocked Items seed: [DefaultBlockedItemsTableSeeder.php](https://github.com/vildanbina/LaravelBlocker/blob/development/src/database/seeds/DefaultBlockedItemsTableSeeder.php)

```
