How to return 403 response in JSON format in Laravel 5.2? : <p>I am trying to develop a RESTful API with Laravel 5.2. I am stumbled on how to return failed authorization in JSON format. Currently, it is throwing the 403 page error instead of JSON.</p>

<p>Controller: <code>TenantController.php</code></p>

<pre><code>class TenantController extends Controller
{
    public function show($id)
    {
        $tenant = Tenant::find($id);
        if($tenant == null) return response()-&gt;json(['error' =&gt; "Invalid tenant ID."],400);
        $this-&gt;authorize('show',$tenant);
        return $tenant;
    }
}
</code></pre>

<p>Policy: <code>TenantPolicy.php</code></p>

<pre><code>class TenantPolicy
{
    use HandlesAuthorization;
    public function show(User $user, Tenant $tenant)
    {
        $users = $tenant-&gt;users();
        return $tenant-&gt;users-&gt;contains($user-&gt;id);
    }
}
</code></pre>

<p>The authorization is currently working fine but it is showing up a 403 forbidden page instead of returning json error. Is it possible to return it as JSON for the 403? And, is it possible to make it global for all failed authorizations (not just in this controller)?</p>
