我有一个变量可以返回一个带有数据数组的集合,但是如果它是空的,它只会将一个字符串赋给同一个变量。目前,我的视图有foreach
期望变量为数组。在运行刀片foreach
之前,有没有办法检查集合?
$twitterResults = Manual::where('account_id', Auth::user()->account)
->where('twitter_followers', '>=', 0)
->where('twitter_posts', '>=', 0)
->where('twitter_reach', '>=', 0)
->where('date_recorded', '>=', Carbon::today()->subMonths(6))
->select('twitter_followers', 'twitter_posts', 'twitter_reach', 'date_recorded')
->orderBy('date_recorded', 'ASC')
->get();
if ($twitterResults->isEmpty()){
$twitterResults = "We don't have enough data, to display any results yet.";
} else {
}