Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

foreach and forelse empty

@foreach ($products as $item)
     <tr>
         <th>{{ $item->id }}</th>
         <td>{{ $item->title }}</td>
         <td>${{ number_format($item->price,2) }}</td>
         <td>{{ $item->cat->title }}</td>
     </tr>
     @if($item->price > 15) @break @endif
 @endforeach
 
 //-------
 @forelse ($products as $item)
     <tr>
         <th>{{ $item->id }}</th>
         <td>{{ $item->title }}</td>
         <td>${{ number_format($item->price,2) }}</td>
         <td>{{ $item->cat->title }}</td>
     </tr>
 @empty
     <div class="alert alert-danger">No Products Added</div>
 @endforelse
Source by www.etharshrouf.com #
 
PREVIOUS NEXT
Tagged: #foreach #forelse #empty
ADD COMMENT
Topic
Name
3+7 =