【发布时间】:2021-07-29 08:51:27
【问题描述】:
我想在更改 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
请查看图片,以便您清楚我的意思 有谁知道如何更改文本或任何其他方法来实现?
【问题讨论】:
-
你能添加代码来改变 $this->tva_text 的值吗?您显示 tvaText 的逻辑是正确的,但似乎值没有更新,您应该检查值
标签: laravel laravel-blade