我有一个模型Images
其中拉的属性,如hidden
将始终是1
或0
。哪里收集的条款总是返回空
我已经试过:
$all_images = Image::all();
var_dump($all_images->first()->hidden);
dd([
$all_images->where('hidden', "0")->count(),
$all_images->where('hidden', 0)->count(),
$all_images->where('hidden', 1)->count(),
$all_images->where('hidden', "1")->count()
]);
/* output
sController.php:219:string '1' (length=1)
array:4 [▼
0 => 0
1 => 0
2 => 0
3 => 0
]*/
但它总是返回0。
但是,如果我用做原料查询数据库SQLite的:
17 rows returned in 0ms from: SELECT * FROM
图像0隐藏= '0';
集合类确实有一个地方方法; https://laravel.com/api/5.3/Illuminate/Support/Collection.html#method_where – sisve
哦。对不起,我不知道。很好的发现。 – devk