Laravel刀片 - 获取属性

时间:2017-02-07 13:32:37

标签: laravel eloquent attributes blade


我怎么能在我看来这样做:$ tva = $ order-> OrderLine-> Model-> Product-> Tva-> value?

@foreach ($orders as $order)
     <tr>
          <td>{{$order->id}}</td>                                            
          <td>{{$order->statut}}</td>  
          <td>{{Carbon\Carbon::parse($order->created_at)->format('d-m-Y h:i:s')}}</td>
          <?php $prixHT=0 ?>
          @foreach ($order->OrderLine as $line)
                <?php $priceHT += ($line->model->priceHT * $line->quantite) ?>                                                
         @endforeach
    <!-- $tva = $order->OrderLine->Model->Product->Tva->value -->
     <td>{{$prixHT * ($tva/100)}}</td>

[orders] 1,n()1,1 [order_lines] 1,1()1,n [models] 1,1()1,n [products] 1,1()0,n [tvas]

1 个答案:

答案 0 :(得分:1)

要在Blate中指定变量,可以执行

<?php $tva = $order->OrderLine->Model->Product->Tva->value; ?>

或者

{{--*/ $tva = $order->OrderLine->Model->Product->Tva->value /*--}}