You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
657 B
PHP

<?php
namespace App\Scopes;
trait CommonPromoteScopes
{
/**
* 查询属于某个推广员的玩家
* @param $query
* @param $promote 推广员
* @param $containSubPromotes 是否包含所有下级
*/
public function scopeOfPromote($query, $promote, $containSubPromotes = true)
{
if ($containSubPromotes) {
$query->whereHas('promote', function ($query) use ($promote) {
$query->ofParent($promote)->orWhere('promote_id', $promote->id);
});
} else {
$query->where('promote_id', $promote->id);
}
return $query;
}
}