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