34 lines
761 B
PHP
34 lines
761 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace Modules\Core\Auth\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* One row per login (see Modules\Core\Auth\Services\UserOtpService::
|
||
|
|
* validate()) — see that table's own migration docblock for why this
|
||
|
|
* exists independent of the actual session-store driver.
|
||
|
|
*/
|
||
|
|
class UserSession extends Model
|
||
|
|
{
|
||
|
|
protected $guarded = [];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'last_used_at' => 'datetime',
|
||
|
|
'revoked_at' => 'datetime',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function user(): BelongsTo
|
||
|
|
{
|
||
|
|
$model = config('auth.providers.users.model');
|
||
|
|
|
||
|
|
return $this->belongsTo($model);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function isRevoked(): bool
|
||
|
|
{
|
||
|
|
return $this->revoked_at !== null;
|
||
|
|
}
|
||
|
|
}
|