Php Laravel雄辩查询-无法转换为int
我试图使用Pulk对Eloquent进行查询,但出于某种原因,返回给我的消息是:Php Laravel雄辩查询-无法转换为int,php,laravel,Php,Laravel,我试图使用Pulk对Eloquent进行查询,但出于某种原因,返回给我的消息是: Object of class Illuminate\Support\Collection could not be converted to int (View: /Applications/MAMP/htdocs/Housing_around/resources/views/admin/tasks/create.blade.php) 有人能告诉我发生了什么事吗 控制器方法: $house = House::
Object of class Illuminate\Support\Collection could not be converted to int (View: /Applications/MAMP/htdocs/Housing_around/resources/views/admin/tasks/create.blade.php)
有人能告诉我发生了什么事吗
控制器方法:
$house = House::findOrFail(Auth::user()->house->id);
$jobs = Job::pluck('name', 'id')->all();
$categories = Category::pluck('name', 'id')->all();
$users = User::where('house_id', $house)->pluck('name', 'id');
我的观点似乎很正常:
<div class="form-group">
<div class="col-md-6">
{!! Form::select('user_id',[''=>'Chose user'] + $users,null,['class'=>'form-control']) !!}
</div>
</div>
{!!Form::select('user_id',['=>'selected user']+$users,null,['class'=>'Form-control'])
您正在尝试包含一个集合和一个数组。因此,改变这一点:
[''=>'Chose user'] + $users
致:
[''=>'Chose user'] + $users->toArray()