title: Laravel how to return JSON when not in controller?
body: <p>Is there some way to return JSON from laravel by using something similar to <code>abort()</code> function.</p>
  
  <p>From controller returning JSON is easy we can just call</p>
  
  <p><code>return response()-&gt;json(['message' =&gt; 'my mesage'], 200);</code></p>
  
  <p>But from some other place (custom class for  example) to return JSON I have to create a return chain to the contoller.</p>
  
  <p>Is there a way to return json without resorting to a return chain.
  Like using <code>abort()</code> function.
  I would like to use something similar to <code>abort(400, 'my message')</code> but insted of returning html like abort does return JSON.</p>
  
  <p>or is there a way to overwrite <code>abort</code> to return JSON.</p>
  
  <p>I would be thankfull solution that works for laravel 5.3 and up.</p>