I want to change color to Red when updating status as Re-order level in laravel 8. how i do that?

This is productObserver.

public function updating(product $product)
   if ($product->Qty <= $product->ReOrderLevel){
      $product->Status='Reorder level';}

   else if ($product->Qty >$product->ReOrderLevel ){
      $product->Status='In Stock';}  

   if ($product->Qty <= 0) {
      $product->Status = 'Out of Stock';}

This is product view. It displays all details of the product and the Status of the product. Here, I want to display status in red colour when status changes into re-order level.

            <tr >
              <th >@sortablelink('Name')</th>
              <th >Product View</th>
              <th >Brand</th>
              <th >@sortablelink('Price')</th>
              <th >@sortablelink('Qty')</th>
              <th >Status</th>
              <th >Action</th>
            @foreach($products as $product)
              <td> <img src="{{asset('uploads/product/'.$product->image)  }}"
              class="img-circle" width="100px;" height="100px;" alt="Product-Image">  </td>
How I change text colour to red when updating product status as Reorder level ?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You can add inline style with condition

in blade

<td @if($product['Status'] =='Reorder level')  style="color: red;" @endif>{{$product['Status']}}</td>

use @if($product['Status'] =='Reorder level') style="color: red;" @endif

Method 2

Ternary operator will do the job at laravel blade.


<p class="{{ $product->Status == 'Reorder level' ? 'red' : '' }}"> some text </p>


.red { color: red }

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x