Skip to content

Instantly share code, notes, and snippets.

@nataliaconde
Last active May 15, 2023 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nataliaconde/a638ba8a9adb9ed2cf0aebf820a34405 to your computer and use it in GitHub Desktop.
Save nataliaconde/a638ba8a9adb9ed2cf0aebf820a34405 to your computer and use it in GitHub Desktop.
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