【问题标题】:I want to change color to Red when updating status as Re-order level in laravel 8. how i do that?在 laravel 8 中将状态更新为重新订购级别时,我想将颜色更改为红色。我该怎么做?
【发布时间】:2021-04-16 09:01:37
【问题描述】:

这是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';}
  
  }

这是产品视图。它显示产品的所有详细信息和产品的状态。在这里,我想在状态变为重新订购级别时以红色显示状态。

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

【问题讨论】:

  • 欢迎来到 SO ... 你能发布到目前为止你为完成工作所做的努力吗?并且不要发布不必要的代码很难找到解决方案
  • @KamleshPaul 我删除了不必要的细节。你能找到解决办法吗?
  • 请检查我发布的答案
  • @KamleshPaul 谢谢
  • 欢迎您:D ...

标签: laravel eloquent laravel-8


【解决方案1】:

您可以添加带有条件的内联样式

在刀片中

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

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

【讨论】:

    【解决方案2】:

    三元运算符将在 laravel Blade 中完成这项工作。

    你的文件.blade.php

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

    你的.css

    .red { color: red }
    

    【讨论】:

      猜你喜欢
      • 2022-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-16
      • 1970-01-01
      • 2015-03-05
      • 2017-02-22
      • 2021-10-26
      相关资源
      最近更新 更多