【发布时间】:2020-02-11 13:35:31
【问题描述】:
我有一个对象集合 - 其中一些包含空数组。
object(Illuminate\Support\Collection)#34225 (1) {
["items":protected]=>
array(0) {
}
}
object(Illuminate\Support\Collection)#34226 (1) {
["items":protected]=>
array(0) {
}
}
object(Illuminate\Support\Collection)#34227 (1) {
["items":protected]=>
array(0) {
}
}
object(Illuminate\Support\Collection)#34228 (1) {
["items":protected]=>
array(0) {
}
}
object(Illuminate\Database\Eloquent\Collection)#23760 (1) {
["items":protected]=>
array(2) {
[0]=>
object(App\Models\File)#23766 (27) {
["primaryKey":protected]=>
string(6) "FileID"
["table":protected]=>
我可以使用某人的帮助来过滤对象集合,以便包含空数组的对象消失/删除。
所以剩下的就是非空数组的对象
object(Illuminate\Database\Eloquent\Collection)#23760 (1) {
["items":protected]=>
array(2) {
[0]=>
object(App\Models\File)#23766 (27) {
["primaryKey":protected]=>
string(6) "FileID"
我已经使用
填充了集合 $things = $foos->get($thing->ID, collect());
任何帮助将不胜感激
【问题讨论】:
标签: laravel filter collections