[英]How to get count value in laravel 5.6 blade?
I want to show the count according to rta_id and deleted_at..I have rta_id and deleted_at column in issuer table. 我想根据rta_id和Deleted_at显示计数。我在发行者表中有rta_id和Deleted_at列。
<?php
$issuer = DB::table('issuer')
->where(['rta_id'=> $rtaData->rta_id])
->get();
?>
<td style="text-align: center;">
<a href="{{ url('/admin/view-issuer/'.$rtaData->rta_id ) }}" class="btn btn-primary btn-mini" >
{{ count($issuer) }}
</td>
This is my code. 这是我的代码。 i have displayed the count value according to rta_id but i also want to show count value according to deleted_at when it is null means only count the rows where the deleted_at is equals to NULL.
我已经根据rta_id显示了计数值,但是当它为null时,我也想根据Deleted_at显示计数值,这意味着仅对Deleted_at等于NULL的行进行计数。
Please help to count the rows according ton rta_id and deleted_at value in the same query.... 请帮助根据同一查询中的ton rta_id和Deleted_at值对行进行计数。...
In controller get those records having deleted_at = null like shown below and send to view. 在控制器中,获取具有delete_at = null的记录,如下所示,然后发送至视图。
$issuer= DB::table('issuer')->where(['rta_id'=> $rtaData->rta_id])->where('deleted_at',null)->get();
then in blade view 然后在刀片视图中
{{count($issuer)}}
Use Count eloquent 用计数口才
$count = DB::table('issuer')
->where('rta_id', '=', $rtaData->rta_id)
->where('deleted_at', '=', null)
->count();
And you need to add this lines in your controller and then send it in your view using compact
并且您需要在控制器中添加此行,然后使用
compact
发送到视图中
In your blade 在您的刀片中
<td style="text-align: center;">
<a href="{{ url('/admin/view-issuer/'.$rtaData->rta_id ) }}" class="btn btn-primary btn-mini" >
{{ $issuer }}
</a>
</td>
Do it like this 像这样做
<?php
$issuer = DB::table('issuer')
->where(['rta_id'=> $rtaData->rta_id])
->where('deleted_at', null)
->count();
?>
<td style="text-align: center;">
<a href="{{ url('/admin/view-issuer/'.$rtaData->rta_id ) }}" class="btn btn-primary btn-mini" >
{{ $issuer }}</a>
</td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.