mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 17:07:49 +08:00
feat : admin log
This commit is contained in:
@@ -6,6 +6,9 @@ namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Events\Creating;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $admin_user_id
|
||||
@@ -20,6 +23,9 @@ namespace App\Model;
|
||||
*/
|
||||
class AdminUserLoginLog extends Model
|
||||
{
|
||||
|
||||
public bool $timestamps = false;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
@@ -28,10 +34,21 @@ class AdminUserLoginLog extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = [];
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user