Files

38 lines
960 B
PHP
Raw Permalink Normal View History

2026-08-31 13:16:46 +08:00
<?php
declare(strict_types=1);
namespace plugin\produce\app\model;
use app\model\system\Admin;
use core\base\BaseModel as CoreBaseModel;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
abstract class BaseModel extends CoreBaseModel
{
use SoftDeletes;
protected $appends = ['created_date', 'updated_date', 'created_name', 'updated_name'];
public function createds(): HasOne
{
return $this->hasOne(Admin::class, 'id', 'created_by')->select('id', 'real_name as created_name');
}
public function updateds(): HasOne
{
return $this->hasOne(Admin::class, 'id', 'updated_by')->select('id', 'real_name as updated_name');
}
public function getCreatedNameAttribute(): string
{
return $this->createds?->created_name ?? '';
}
public function getUpdatedNameAttribute(): string
{
return $this->updateds?->updated_name ?? '';
}
}