A live authorization is what consumes a Wi-Fi device slot
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ec3REU4LQmhuchRRn6dZHk
This commit is contained in:
@@ -23,6 +23,23 @@ class PortalSession extends Model
|
|||||||
return $this->belongsTo(\App\Models\User::class);
|
return $this->belongsTo(\App\Models\User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The rows that consume a device slot.
|
||||||
|
*
|
||||||
|
* Presence on the network is deliberately NOT part of this. UniFi holds an
|
||||||
|
* authorization for its full window whether or not the device is in the
|
||||||
|
* building, so a phone that went home still owns its slot — freeing it here
|
||||||
|
* is what let one person hold two authorizations against a one-device quota.
|
||||||
|
*
|
||||||
|
* A NULL expires_at is not live: it predates this being enforced.
|
||||||
|
*/
|
||||||
|
public function scopeLive($query)
|
||||||
|
{
|
||||||
|
return $query->where('is_active', true)
|
||||||
|
->whereNotNull('expires_at')
|
||||||
|
->where('expires_at', '>', now());
|
||||||
|
}
|
||||||
|
|
||||||
public function setMacAddressAttribute($value)
|
public function setMacAddressAttribute($value)
|
||||||
{
|
{
|
||||||
$this->attributes['mac_address'] = strtolower($value);
|
$this->attributes['mac_address'] = strtolower($value);
|
||||||
|
|||||||
Reference in New Issue
Block a user