title: Laravel - Star rating - Optimization?
body: <p>It's not a problem in fact, but I would like to know if it is possible to optimise the code below.</p>
  
  <p>It's a simple code to show the star rating mark which is in the db.</p>
  
  <p>I searched and tried with @foreach, but can't figure it out.</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;span class="review-stars" style="color: #1e88e5;"&gt;
  &lt;!-- ////////////// STAR RATE CHECKER ////////////// --&gt;
      @if($review-&gt;rate &lt;= 0)
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
      @elseif($review-&gt;rate === 1)
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
      @elseif($review-&gt;rate === 2)
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
      @elseif($review-&gt;rate === 3)
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
      @elseif($review-&gt;rate === 4)
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star-o" aria-hidden="true"&gt;&lt;/i&gt;
      @elseif($review-&gt;rate &gt;= 5)
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
          &lt;i class="fa fa-star" aria-hidden="true"&gt;&lt;/i&gt;
      @endif
      &lt;!-- ///////////////////////////////////////////// --&gt;
  &lt;/span&gt;
  </code></pre>
  
  <p>When <code>$review-&gt;rate &lt;= 0</code>
  <a href="https://i.stack.imgur.com/5tpXL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5tpXL.png" alt="enter image description here"></a></p>
  
  <p>When <code>$review-&gt;rate === 3</code>
  <a href="https://i.stack.imgur.com/YawGo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YawGo.png" alt="enter image description here"></a></p>
  
  <p>When <code>$review-&gt;rate &gt;= 5</code>
  <a href="https://i.stack.imgur.com/E0fKL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E0fKL.png" alt="enter image description here"></a></p>