dimanche 5 septembre 2021

What's the proper way to use IF condition in Laravel Blade file?

Table Header:

@if($products->subcategory->name == 'Image')
  <th>Demo</th>
@else

@endif

Table Column under forelse loop:

@forelse ($products as $item)
  <tr>
      @if($item->subcategory->name == 'Image')
         <td>
            <p></p>
         </td>
        @else
      @endif 
 </tr>
@endforelse

The problem is: IF condition works inside the forelse loop but not working outside. I want to hide/show a column if the subcategory name is "Image".

what's the proper way for writing this condition.



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

Aucun commentaire:

Enregistrer un commentaire