3 years ago

Returning a value from a array.

Posted 3 years ago by jsrosas

Hi All, I am trying to retrieve the id of the subscription of a User in my controller and return it to the view. So my controller code looks like this:

public function stripe_info(){
        $stripe_info = Stripe::customers()->find($this->stripe_id);
        $subscription = $stripe_info['subscriptions']['data']['0']['plan']['id'];

I am using Cartalyst's Laravel library because it gives me more options. So when I DD the result It works fine, but when I return $subscription I get :

Undefined offset: 0 (View: C:\inetpub\wwwroot\cybertrack\resources\views\admin\membershow.blade.php) But DD returns to view the actual value I am looking for, of course it breaks the rest of the page. Why does the result change when I return?

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