Files
water_new/modules/User/Models/IdentityLog.php
2023-03-08 09:16:04 +08:00

46 lines
1013 B
PHP

<?php
namespace Modules\User\Models;
use App\Models\Model;
use App\Traits\OrderByIdDesc;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Modules\User\Traits\BelongsToUser;
class IdentityLog extends Model
{
use BelongsToUser, OrderByIdDesc;
protected $table = 'user_identity_logs';
protected $casts = [
'source' => 'json',
];
const CHANNEL_AUTO = 'Auto';
const CHANNEL_REG = 'Reg';
const CHANNEL_SYSTEM = 'System';
const CHANNEL_MAP = [
self::CHANNEL_AUTO => '自动变更',
self::CHANNEL_REG => '注册默认',
self::CHANNEL_SYSTEM => '后台变更',
];
public function before_identity(): BelongsTo
{
return $this->belongsTo(Identity::class, 'before')->withDefault([
'name' => '已删除',
]);
}
public function after_identity(): BelongsTo
{
return $this->belongsTo(Identity::class, 'after')->withDefault([
'name' => '已删除',
]);
}
}