vendredi 2 novembre 2018

Using Foreach in Laravel Controller with array not giving values

Working with Laravel I've been trying to display all price values for a particular product. Product has a particular value for each country:

Product 1: US-> 130usd Product 1: CL-> 159usd and so on.

In my controller:

    public function details($id)
    {
    $product = $this->product->getProductById($id);

    $countryIso = array('US', 'AR', 'CL');

    foreach ($countryIso as $isocode){
    $productDDP = $this->product->getPriceAmount($product = $product, $countryIso = $isocode);
}

    return view('products.view',compact('productDDP'));
    }

I would like to display in my view all the price values associated to each country for this product.

I tried using foreach on blade but with no success.

Just a comment: If I replace

$countryIso = 'US' 
$productDDP = $this->product->getPriceAmount($product = $product, $countryIso = $countryIso); 

instead of using an array, 'getPriceAmount' return the value of the product for that location ok.

any help appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire