how to start laravel project

how to start laravel project

Laravel 5.6 had a procedure where it would return false for unauthenticated users. In Laravel 5.7, we can allow guests to pass authorization checks using a special Nullable type hint in the specified controller as given below −

<?php
Gate::define('view-post', function (?User $user) {
   // Guests
});

Explanation of the Code

Using the NULL type hint, the $user variable will be NULL when the guest user is passed to the strobe. You can then decide to authorize the action. If you allow empty types and return true, then the guest will have authorization. If you do not use nullable type hint, guests will automatically receive a 403 response for Laravel 5.7 which is shown below −

The difference between 403 and 404 errors is that a 404 is displayed when a user tries to access an unknown resource or URL, and a 403 error, as mentioned in the snapshot above, is displayed if an unauthorized user accesses a website.