How can I get the result as just
100.0%
in Laravel blade.php? When I use code raw expression in laravel 5.5 below:
$
The ->get()
method of \Illuminate\Database\Query\Builder
return instance of \Illuminate\Support\Collection
, In your case need get only one result. For this use ->first() method instead of ->get()
. ->first()
method return instance of stdClass
and you can directly get your needed attribute
For your case corrected code is.
$jml_status_ap_all_pr = DB::table('aps')
->select(DB::raw('ROUND((COUNT(STATUS)/(SELECT COUNT(*) FROM aps))*100,1) as calc'))
->first()
->calc;