This commit is contained in:
63
app/Model/OperatorLogs.php
Normal file
63
app/Model/OperatorLogs.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/5
|
||||
* Time: 下午7:33
|
||||
* Description:
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use Hyperf\Database\Model\Builder;
|
||||
use Hyperf\Database\Model\SoftDeletingScope;
|
||||
|
||||
class OperatorLogs extends Model
|
||||
{
|
||||
protected ?string $table = 'operator_logs';
|
||||
|
||||
protected array $fillable = [
|
||||
'company_id',
|
||||
'location',
|
||||
'type',
|
||||
'log_title',
|
||||
'route',
|
||||
'params',
|
||||
'ip',
|
||||
'source',
|
||||
'timer',
|
||||
'agent',
|
||||
'remark',
|
||||
'creator_id',
|
||||
'creator_name',
|
||||
];
|
||||
|
||||
protected array $casts = [
|
||||
'created_at' => 'datetime:Y-m-d H:i:s',
|
||||
'updated_at' => 'datetime:Y-m-d H:i:s',
|
||||
'params' => 'json',
|
||||
];
|
||||
|
||||
public function setIpAttribute(mixed $value): void
|
||||
{
|
||||
$this->attributes['ip'] = sprintf('%u', ip2long($value));
|
||||
}
|
||||
|
||||
public function getIpAttribute(mixed $value): string
|
||||
{
|
||||
return long2ip($value);
|
||||
}
|
||||
|
||||
// 忽略软删除
|
||||
public function newQuery(bool $cache = false): Builder
|
||||
{
|
||||
$builder = parent::newQuery();
|
||||
return $builder->withoutGlobalScope(SoftDeletingScope::class);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user