本文整理匯總了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');
}
}