Last active
May 15, 2023 12:33
-
-
Save nataliaconde/a638ba8a9adb9ed2cf0aebf820a34405 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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