title: PHP Laravel - Eloquent is returning boolean fields randomly sometimes as 0 1 and others as true false when calling the method json
body: <p>I am using Laravel Eloquent to write a REST API. When calling <code>json</code> from <code>response()</code> to return the object, boolean fields are returned as 0/1 sometimes and as false/true others. I would like to unify the format and make it all as 0,1 or as false,true instead of it being random</p>
  
  <p>here is the code sample:</p>
  
  <pre><code>public function show($id)
  {
      $obj = MyObject::findOrFail($id);
      return response()-&gt;json($obj,200);
  }
  </code></pre>
  
  <p>this return 0,1</p>
  
  <p>and this code when the object is created return true, false not only for the status but for the boolean values in the <code>$obj</code></p>
  
  <pre><code>return response()-&gt;json([
          'status' =&gt; (bool) $obj,
          'data'   =&gt; $obj,
          'message' =&gt; $obj ? 'new obj created!' : 'an error has occurred'
      ], 201); 
  </code></pre>
  
  <p>So, how to make them all 0 and 1 or all true or false?</p>