![](/img/trans.png)
[英]Laravel:Undefined property: Illuminate\Database\Eloquent\Collection::$id
[英]Laravel Illuminate\Database\Eloquent\Collection
我通常使用 Eloquent Laravel 单独选择我的项目
$b = Booking::where("id","=",$id)->get();
使用toArray()
函数,您就可以开始了,
$bs = Booking::where("date","=",$today)->get()->toArray();
现在,您将拥有从DB返回的数据数组。
你可以这样做:
$bs = Booking::where("date","=",$today)->get();
foreach ($bs as $i=>$b) {
$bs2[] = collect([$b]);
}
这将为您提供一组Illuminate\\Support\\Collection
集合,每个集合只有一个。
如果需要Illuminate\\Database\\Eloquent\\Collection
集合:
$bs2[] = new \Illuminate\Database\Eloquent\Collection([$b]);
$bs = Booking::where("date","=",$today)->get();
$new_bs = $bs->toArray;
试试这个,它的工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.