'decimal:8', 'min_deposit' => 'decimal:8', 'max_amount' => 'decimal:8', 'starts_at' => 'datetime', 'expires_at' => 'datetime', 'rules' => 'array', ]; public function scopeActive($query) { $now = now(); return $query->where('status', 'active') ->when($now, function ($q) use ($now) { $q->where(function ($qq) use ($now) { $qq->whereNull('starts_at')->orWhere('starts_at', '<=', $now); })->where(function ($qq) use ($now) { $qq->whereNull('expires_at')->orWhere('expires_at', '>=', $now); }); }); } }