本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::orWhereHas方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::orWhereHas方法的具体用法?PHP Builder::orWhereHas怎么用?PHP Builder::orWhereHas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::orWhereHas方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: constrainUsers
/**
* Constrain the given users query by the provided permission.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $permission
* @param \Illuminate\Database\Eloquent\Model|string|null $model
* @return \Illuminate\Database\Eloquent\Builder
*/
public function constrainUsers($query, $permission, $model = null)
{
return $query->where(function ($query) use($permission, $model) {
$query->whereHas('permissions', $this->getPermissionConstraint($permission, $model));
$query->orWhereHas('roles', $this->getRoleConstraint($permission, $model));
});
}
示例2: constrainUsers
/**
* Constrain the given users query by the provided ability.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $ability
* @param \Illuminate\Database\Eloquent\Model|string|null $model
* @return \Illuminate\Database\Eloquent\Builder
*/
public function constrainUsers($query, $ability, $model = null)
{
return $query->where(function ($query) use($ability, $model) {
$query->whereHas('abilities', $this->getAbilityConstraint($ability, $model));
$query->orWhereHas('roles', $this->getRoleConstraint($ability, $model));
});
}
示例3: orWhereHas
/**
* Add a relationship count condition to the query with where clauses and an "or".
*
* @param string $relation
* @param \Closure $callback
* @param string $operator
* @param int $count
* @return \Illuminate\Database\Eloquent\Builder|static
* @static
*/
public static function orWhereHas($relation, $callback, $operator = '>=', $count = 1)
{
return \Illuminate\Database\Eloquent\Builder::orWhereHas($relation, $callback, $operator, $count);
}
示例4: buildWildcardQueryFilters
/**
* Build wildcard query filters.
*
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param array $fields
* @param array $keyword
* @param string $group
*
* @return void
*/
protected function buildWildcardQueryFilters($query, array $fields, array $keyword = [])
{
foreach ($fields as $field) {
if (Str::contains($field, '.') && $query instanceof Builder) {
list($relation, $field) = explode('.', $field, 2);
$query->orWhereHas($relation, function ($query) use($field, $keyword) {
$this->buildWildcardQueryFilterWithKeyword($query, $field, $keyword, 'where');
});
} else {
$this->buildWildcardQueryFilterWithKeyword($query, $field, $keyword, 'orWhere');
}
}
}