如何使用雄辩查询Laravel 5.2中的行数


How to query the number of rows in Laravel 5.2 using eloquent?

作为if语句的一部分,我希望查询行数。

我使用的代码如下:

 $company = DB::table('customers')->where('business', 'Auth::user()->name')->value('business');   
@if (count($company==0)
<div class="alert alert-danger" role="alert">
<strong>Please click here to register full company details</strong>
@endif

更新

{{$countCompany = App'customers::where('business', Auth::user()->name)->count()}}
@if ($countCompany==0)
<div class="alert alert-danger" role="alert">
<strong>Please click here to register full company details</strong>
@endif

感谢

使用->count()方法

$count = $company->count();   

这里也有错误,缺少)

@if (count($company==0))

试用Eloquent

$countCompany = App'Customer::where('business', Auth::user()->name)->count();

我已经设法做了一个变通的

<?php
$user = Auth::user()->name;
$company = DB::table('customers')->where('business', $user )->value('business');
?>
@if (is_null($company))
<div class="alert alert-danger" role="alert">
<strong>Please click here to register full company details</strong>
</div>
@endif 

满足我的需求。