如何更改 laravel 中的值更改文本
how to change value change text in laravel
我想在更改TVA值时更改文本但最后结果相同
它们在两种情况下都显示为“NET TTC”
函数:
public function invoice()
{
return $this->belongsTo(Invoice::class, 'invoice_id', 'id');
}
public function tvaText(){
if( $this->TVA_value == 0 ){
$this->tva_text='NET TTC';
}elseif($this->TVA_value != 0){
$this->tva_text='Total TTC';
}
return $this->tva_text;
}
显示:
@foreach($invoice->details as $item)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $item->product_name }}</td>
<td>{{ $item->quantity }}</td>
<td>{{ $item->unit_price }}</td>
<td>{{ $item->row_sub_total }}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3"></td>
<th colspan="2">TVA value </th>
<td>{{ $invoice->TVA_value }}</td>
</tr>
<tr>
<td colspan="3"></td>
<th colspan="2">sub total</th>
<td>{{ $invoice->sub_total }}</td>
</tr>
<tr>
<td colspan="3"></td>
<th colspan="2">TVA total</th>
<td>{{ $invoice->TVA_total }}</td>
</tr>
<tr>
<td colspan="3"></td>
<th colspan="2">{{ $item->**tvaText()** }}</th>
<td>{{ $invoice->TTC_total }}</td>
</tr>
@endforeach
请看图片,以便您清楚我的意思
有谁知道如何更改文本或任何其他方法来实现?
你可以在 blade 上轻松做到。
@if($invoice->TVA_value == 0 )
<td>NET TTC</td>
@else
<td> Total TTC </td>
@endif
我想在更改TVA值时更改文本但最后结果相同 它们在两种情况下都显示为“NET TTC”
函数:
public function invoice()
{
return $this->belongsTo(Invoice::class, 'invoice_id', 'id');
}
public function tvaText(){
if( $this->TVA_value == 0 ){
$this->tva_text='NET TTC';
}elseif($this->TVA_value != 0){
$this->tva_text='Total TTC';
}
return $this->tva_text;
}
显示:
@foreach($invoice->details as $item)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $item->product_name }}</td>
<td>{{ $item->quantity }}</td>
<td>{{ $item->unit_price }}</td>
<td>{{ $item->row_sub_total }}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3"></td>
<th colspan="2">TVA value </th>
<td>{{ $invoice->TVA_value }}</td>
</tr>
<tr>
<td colspan="3"></td>
<th colspan="2">sub total</th>
<td>{{ $invoice->sub_total }}</td>
</tr>
<tr>
<td colspan="3"></td>
<th colspan="2">TVA total</th>
<td>{{ $invoice->TVA_total }}</td>
</tr>
<tr>
<td colspan="3"></td>
<th colspan="2">{{ $item->**tvaText()** }}</th>
<td>{{ $invoice->TTC_total }}</td>
</tr>
@endforeach
请看图片,以便您清楚我的意思 有谁知道如何更改文本或任何其他方法来实现?
你可以在 blade 上轻松做到。
@if($invoice->TVA_value == 0 )
<td>NET TTC</td>
@else
<td> Total TTC </td>
@endif