title: How to get calculated data from Controller to View and display it (laravel)?
body: <p>i have a question again.. So, this time I need to send calculated data from my controller to view. 
  I have no problem with send simple data, like:</p>
  
  <pre><code>// Controller
  public function index() {
    $page = Page::whereAlias('products');
    $products = Product::all();
    $data = compact('page', 'products');
    return View::make('products', $data);
  }
  
  //View
  @foreach ($products as $product)
  {{ $product-&gt;title }}
  @endforeach
  </code></pre>
  
  <p>But in my project I need calculate for every products discount, if discounts date is correct, show it as discounted product.
  Also calculate rating of this product, reviews count and so on. I have all correct relations and models.</p>
  
  <p>And in my project I have next code (i think it's not correct):</p>
  
  <pre><code>// Controller
  public function index() {
    $page = Page::whereAlias('products');
    $products = Product::all();
    $data = compact('page', 'products');
    return View::make('products', $data);
  }
  
  //View
  &lt;?php 
  $discount_count = 0;
  $rating_count = 0;
  $reviews_count = 0;
  ?&gt;
  
  @foreach ($products as $product)
      {{ $product-&gt;title }}
      &lt;?php 
      foreach ($product-&gt;rating as $rating) { $rating_count++; }
      ?&gt;
      {{ $rating_count }}
      &lt;?php 
      foreach ($product-&gt;reviews as $review) { $review_count++; }
      ?&gt;
      {{ $review_count }}
      @if ($product-&gt;discount_date_start &gt; $current_date &lt; $discount_date_end)
      {{ $product-&gt;price - $product-discount }} 
      {{ round($product-&gt;discount / ($product-&gt;price / 100)); }}% // discount in percents
      @else
      {{ $product-&gt;price }}
      @endif
  @endforeach
  </code></pre>
  
  <p>As I understand all calculations must be in controller? But how..?
  Thank you.</p>