本文整理汇总了PHP中Illuminate\Support\Collection::whereLoose方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::whereLoose方法的具体用法?PHP Collection::whereLoose怎么用?PHP Collection::whereLoose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Collection
的用法示例。
在下文中一共展示了Collection::whereLoose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWhereLoose
public function testWhereLoose()
{
$c = new Collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]);
$this->assertEquals([['v' => 3], ['v' => '3']], $c->whereLoose('v', 3)->values()->all());
}
示例2: attachVotesShortInfo
private function attachVotesShortInfo(Answer &$model, \Illuminate\Support\Collection $votes)
{
$likes = $votes->whereLoose('sign', 1)->count();
$dislikes = $votes->count() - $likes;
$rating = $likes - $dislikes;
$users_vote = $votes->where('user_id', Auth::user()->id)->first();
$model->vote_likes = $likes;
$model->vote_dislikes = $dislikes;
$model->vote_value = $rating;
if ($users_vote) {
$model->vote = $users_vote;
}
}