mirror of
https://github.com/v2board/v2board.git
synced 2025-06-16 22:57:47 +08:00
update: new auth
This commit is contained in:
@ -4,6 +4,7 @@ namespace App\Services;
|
||||
|
||||
use App\Models\Plan;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PlanService
|
||||
{
|
||||
@ -20,4 +21,20 @@ class PlanService
|
||||
$count = User::where('plan_id', $this->plan->plan_id)->count();
|
||||
return $this->plan->capacity_limit - $count;
|
||||
}
|
||||
|
||||
public static function countActiveUsers()
|
||||
{
|
||||
return User::select(
|
||||
DB::raw("plan_id"),
|
||||
DB::raw("count(*) as count")
|
||||
)
|
||||
->where('plan_id', '!=', NULL)
|
||||
->where(function ($query) {
|
||||
$query->where('expired_at', '>=', time())
|
||||
->orWhere('expired_at', NULL);
|
||||
})
|
||||
->groupBy("plan_id")
|
||||
->get()
|
||||
->keyBy('plan_id');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user