title: Cannot use object of type stdClass as array Laravel Error
body: <p>So I get this error "Cannot use object of type stdClass as array" when I am trying to retrieve data from DB with array </p>
  
  <p>My controller</p>
  
  <pre><code>public function openingPage($id) {
  
        $this-&gt;getCaseData($id);
  
        return view('caseopener', ['cases' =&gt; $cases]);
  
      }
  
      private function getCaseData($id) {
          $cases = DB::table('cases')-&gt;where('id', $id)-&gt;first();
          $data = @$cases[0] ? $cases[0] : array();
          if(isset($data-&gt;items)) {
              $data-&gt;items = json_decode($data-&gt;items, true);
          }
  
          $this-&gt;data = $data;
      }
  </code></pre>
  
  <p>Also I see that the problem comes from this line:</p>
  
  <pre><code> $data = @$cases[0] ? $cases[0] : array();
  </code></pre>