title: Cannot access offset of type string on string, laravel
body: <p>I get this error <strong>&quot;Cannot access offset of type string on string&quot;</strong>, how do I fix this error?</p>
  <p>this error occurs in my resource file, this is the code in my resource</p>
  <pre><code>&lt;?php
  
  namespace App\Http\Resources;
  use Illuminate\Http\Resources\Json\JsonResource;
  class InvoiceResource extends JsonResource
  {
      /**
       * Transform the resource into an array.
       *
       * @param  \Illuminate\Http\Request  $request
       * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
       */
      public function toArray($request)
      {
          return [
              'id' =&gt; $this-&gt;id,
              'bank' =&gt; $this-&gt;payment_type == 'bank_transfer' ? [
                  'name' =&gt; $this-&gt;payment_info['bank']['name'],
                  'va_number' =&gt; $this-&gt;payment_info['bank']['va_number'],
              ] : null,
          ];
          
      }
  }
  </code></pre>
  <p>the error is in this line</p>
  <pre><code>'name' =&gt; $this-&gt;payment_info['bank']['name'],
  </code></pre>
  <p>what do you think I should do? please help me fix this error ;((</p>