This package is abandoned and no longer maintained. The author suggests using the artisanry/doorkeeper package instead.

Compare the amount of relations with specified rules.

2.1.0 2019-06-04 07:17 UTC


Build Status PHP from Packagist Latest Version License

This package counts the amount of records on a relationship and compares them with a given set of limits. This can be useful to determine if a user has reached the limit of files he can upload or something similar.


Require this package, with Composer, in the root directory of your project.

$ composer require artisanry/doorkeeper



namespace App;

use Artisanry\Doorkeeper\Traits\Doorkeeper;
use Artisanry\Doorkeeper\Contracts\DoorkeeperContract;

class User extends Model implements DoorkeeperContract
    use Doorkeeper;

    public $limits = [
        'posts' => 5,
        'files' => 10,

    public function posts() {
        return $this->hasMany('App\Post');

    public function files() {
        return $this->hasMany('App\File');


namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

class ReachedLimits

    public function handle($request, Closure $next)
        $user = Auth::check();

        if ( $user->limits($user->subscription->limits)->fails() ) {
            return redirect()->route('billing');

        return $next($request);


namespace App\Http\Controllers;

class DashboardController

    public function __construct()

    public function index()
        return view('dashboard');


Perform checks with custom limits.


Perform a check and see if it passes.


Perform a check and see if it fails.


Get all limits.


Get a specific limit.


Get the current counter.


Get a specific counter.


Check if the overall limit has been reached.


Check if a specific limit has been reached.



$ phpunit


If you discover a security vulnerability within this package, please send an e-mail to hello@basecode.sh. All security vulnerabilities will be promptly addressed.


This project exists thanks to all the people who contribute.


Mozilla Public License Version 2.0 (MPL-2.0).