Files
hyperf_rbac_framework_serve…/app/Model/AdminUserLoginLog.php
2025-09-16 18:07:10 +08:00

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','admin_user_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();
}
}
}