mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 11:22:10 +08:00
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
use Hyperf\Database\Model\Events\Creating;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property int $admin_user_id
|
|
* @property string $username
|
|
* @property string $ip
|
|
* @property string $os
|
|
* @property string $browser
|
|
* @property int $status
|
|
* @property string $message
|
|
* @property string $login_time
|
|
* @property string $remark
|
|
*/
|
|
class AdminUserLoginLog extends Model
|
|
{
|
|
|
|
public bool $timestamps = false;
|
|
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'admin_user_login_log';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = ['id', 'username', 'ip', 'os', 'browser', 'status', 'message', 'login_time', 'remark'];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*/
|
|
protected array $casts = ['id' => 'integer', 'admin_user_id' => 'integer', 'status' => 'integer'];
|
|
|
|
/**
|
|
* @param Creating $event
|
|
* @return void
|
|
*/
|
|
public function creating(Creating $event): void
|
|
{
|
|
if ($event->getModel()->login_time === null) {
|
|
$event->getModel()->login_time = Carbon::now();
|
|
}
|
|
}
|
|
}
|