0

The Controller code is as follows:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\View;

use DarthSoup\Whmcs\Facades\Whmcs;
use DarthSoup\Whmcs\WhmcsServiceProvider;

class GetProductController extends Controller
{
public function show(){
    $products = Whmcs::GetProducts([
        'pid'=>'pid',
        'name' =>'name',
        'price' =>'price',
        'description' =>'description'


    ]);

    return view('main.SME_Hosting',['products'=>$products]);


    }
}

And in Views I have written code using foreach as follows:

         @foreach ($products as $product)
               <td> {{$product->'pid'}}</td>
               <td> {{$product->'name'}}</td>
               <td> {{$product->'price'}}</td>
               <td> {{$product->'description'}}</td>

 @endforeach

My Json data is given below: I have attached the screenshot of JSON data and suggest a way to print all these datas using foreach loop.

1
  • 2
    And the problem or question is? Commented Mar 27, 2018 at 13:20

2 Answers 2

1

You can use:

@foreach ($products as $product)
     <pre>{{ $product | json }}</pre>
@endforeach

It will print all product data in json.

Sign up to request clarification or add additional context in comments.

Comments

1

You can have json form of your passed data using @json directive

var products = @json($products);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.