Methods 方法addSelect不存在
当我尝试在Laravel 5.2中执行addSelect方法时,收到此错误消息 有什么想法吗 Macroable.php第74行中的BadMethodCallException: 方法addSelect不存在 这是我的控制器中的函数 成员的公共功能摘要 { 我的刀片: 总计为{{$memberCount}Methods 方法addSelect不存在,methods,controller,laravel-5.2,Methods,Controller,Laravel 5.2,当我尝试在Laravel 5.2中执行addSelect方法时,收到此错误消息 有什么想法吗 Macroable.php第74行中的BadMethodCallException: 方法addSelect不存在 这是我的控制器中的函数 成员的公共功能摘要 { 我的刀片: 总计为{{$memberCount} 您得到的是一个集合,而不是一个对象。addSelect方法属于生成器对象,而不是集合。因此,从查询中删除get就可以了 $members = MotherProfile::select('l
您得到的是一个集合,而不是一个对象。addSelect方法属于生成器对象,而不是集合。因此,从查询中删除get就可以了
$members = MotherProfile::select('last_name')
->orderBy('last_name','ASC')
->distinct()
->get();
在获取任何代码之前?调用addSelect的代码?以及此addSelect调用的位置?发送您的代码。当然,现在将编辑此代码。我认为这是一个常见的laravel问题。谢谢您的解决方案。有没有办法让我知道哪些方法属于集合,哪些方法属于对象生成器?谢谢,我想我可以找到您的答案t、 再次感谢@Rodrane,你太棒了!
@foreach ($fullnames as $fullname)
{{ $fullname }}<br>
@endforeach
<hr>
<div class="page-header" style="text-align:center;">
<h3 class="pageHeader">
List of Members
<br>
</h3>
</div>
<div class="row">
<table class="table table-bordered" style="text-align: left;">
<tr>
<th></th>
<th>Full Name (Last, First, Middle)</th>
<th>KLC</th>
<th>Category</th>
<th>Mem Type</th>
<th>Mem Status</th>
<th>Date Baptized</th>
<th>Mother in Spirit</th>
<th>Encoder</th>
</tr>
<tbody>
</tbody>
</table></div>
$members = MotherProfile::select('last_name')
->orderBy('last_name','ASC')
->distinct()
->get();
$members = MotherProfile::select('id','last_name')
->orderBy('last_name','ASC')
->distinct()
->addSelect(DB::raw("'value' as nameFake"))->get();