mykelcodex
5 months ago
288
3
Laravel

Illegal string offset 'customer'

Posted 5 months ago by mykelcodex

I have this in my controller

public function transactions(){
        $subs = Rave::listSubscriptions();
        $sub = $subs->data->plansubscriptions;
        
        return view('transactions',compact('subs'));
    }

I am trying to display this in my blade view like this

      @foreach ($subs as $sub)
                <tr>
                   <td>{{ $loop->iteration }}</td>
                   <td class="font-size-sm">{{ $sub['customer']['customer_email'] }}</td>
        </tr>
         @endforeach

but i keep getting "Illegal string offset 'customer'"

public function transactions(){
        $subs = Rave::listSubscriptions();
        $sub = $subs->data->plansubscriptions;
        dd($sub)
        return view('transactions',compact('sub'));
    }
array:10 [▼
  0 => {#482 ▼
    +"id": 3840
    +"amount": 1000
    +"customer": {#483 ▼
      +"id": 67773583
      +"customer_email": "[email protected]"
    }
    +"plan": 3249
    +"status": "cancelled"
    +"date_created": "2019-08-29T03:37:12.000Z"
  }
  1 => {#484 ▼
    +"id": 3839
    +"amount": 1000
    +"customer": {#485 ▶}
    +"plan": 3249
    +"status": "active"
    +"date_created": "2019-08-29T03:30:36.000Z"
  }
  2 => {#486 ▶}
  3 => {#488 ▶}
  4 => {#490 ▶}
  5 => {#492 ▶}
  6 => {#494 ▶}
  7 => {#496 ▶}
  8 => {#498 ▶}
  9 => {#500 ▶}
]

Please, how can i resolve this?

Please sign in or create an account to participate in this conversation.