jeudi 29 mars 2018

I got a json data from whmcs using whmcs api. how to decode the json data and print the data in laravel view template

Find the json data from whmcs API and suggest me a solution to display the mentioned data as I'm getting error as "Trying to non-object and json_decode() expects parameter 1 to be string".

"products": {
"product": [
  {
    "pid": "1",
    "gid": "1",
    "type": "hostingaccount",
    "name": "super lite",
    "description": "1 website",
    "module": "cpanel",
    "paytype": "recurring",
    "pricing": {
      "INR": {
        "prefix": "\u20b9",
        "suffix": "INR",
        "msetupfee": "0.00",
        "qsetupfee": "0.00",
        "ssetupfee": "0.00",
        "asetupfee": "0.00",
        "bsetupfee": "0.00",
        "tsetupfee": "0.00",
        "monthly": "-1.00",
        "quarterly": "-1.00",
        "semiannually": "-1.00",
        "annually": "1668.00",
        "biennially": "3096.00",
        "triennially": "3924.00"
      }

This is my controller code

class GetProductController extends Controller
{
public function show(){

    $products = Whmcs::GetProducts([
        'pid',
        'name',
        'price',
        'description'
   ]);

    $products = json_decode($products, true);

        return view('main.SME_Hosting',compact('products'));

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

    }

This is my view code

 @foreach ($products as $product)
                        


@endforeach



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2GlCqYH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire