Skip to content

Instantly share code, notes, and snippets.

@vinicius73
Created March 11, 2016 20:12
Show Gist options
  • Save vinicius73/911884bdbd03d80413ea to your computer and use it in GitHub Desktop.
Save vinicius73/911884bdbd03d80413ea to your computer and use it in GitHub Desktop.
Para vc não precisar fazer um loop nas suas permissões :p
<?php
namespace App\Core\Providers;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Support\ServiceProvider;
use App\Domains\Users\User;
class AuthServiceProvider extends ServiceProvider
{
public function boot(GateContract $gate)
{
$gate->before(function ($user, $permission, $args) use ($gate) {
// GATE not have this ability
if ($user instanceof User && !$gate->has($permission)) {
// return $user->canDo($permission)
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment