本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::whereNotExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::whereNotExists方法的具体用法?PHP Builder::whereNotExists怎么用?PHP Builder::whereNotExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::whereNotExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find
/**
* @param User $actor
* @param Builder $query
*/
public function find(User $actor, Builder $query)
{
// Hide discussions which have tags that the user is not allowed to see.
$query->whereNotExists(function ($query) use($actor) {
return $query->select(new Expression(1))->from('discussions_tags')->whereIn('tag_id', Tag::getIdsWhereCannot($actor, 'viewDiscussions'))->where('discussions.id', new Expression('discussion_id'));
});
}
示例2: scopeExceptGeneral
/**
* 扩展查询,获取排除通识素质课的课程数据
* @author FuRongxin
* @date 2016-03-09
* @version 2.0
* @param \Illuminate\Database\Eloquent\Builder $query 查询对象
* @return \Illuminate\Database\Eloquent\Builder 查询对象
*/
public function scopeExceptGeneral($query)
{
return $query->whereNotExists(function ($query) {
$query->from('pk_kczy AS a')->whereRaw('t_a.nd = t_pk_kczy.nd AND t_a.xq = t_pk_kczy.xq AND t_a.zsjj = t_pk_kczy.zsjj AND t_a.kcxh = t_pk_kczy.kcxh')->wherePt('T')->where(function ($query) {
$query->whereXz('W')->orWhere('xz', '=', 'I')->orWhere('xz', '=', 'Y')->orWhere('xz', '=', 'Q');
});
});
}
示例3: find
/**
* @param User $actor
* @param Builder $query
*/
public function find(User $actor, Builder $query)
{
// Hide discussions which have tags that the user is not allowed to see.
$query->whereNotExists(function ($query) use($actor) {
return $query->select(new Expression(1))->from('discussions_tags')->whereIn('tag_id', Tag::getIdsWhereCannot($actor, 'viewDiscussions'))->where('discussions.id', new Expression('discussion_id'));
});
// Hide discussions with no tags if the user doesn't have that global
// permission.
if (!$actor->hasPermission('viewDiscussions')) {
$query->has('tags');
}
}