Skip to content

Instantly share code, notes, and snippets.

Last active May 15, 2023 12:33
What would you like to do?
use App\Models\Post;
use App\Models\User;
use Illuminate\Support\Facades\Gate;
* Register all authorization and authentication services.
public function boot(): void
//Only users with admin role will be allowed to create a post
Gate::define('can_post', function($user) {
return $user->role == 'admin';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment