调整数据库表的单复数

This commit is contained in:
2026-02-19 10:39:38 +08:00
parent 736a41a718
commit d310a29c03
56 changed files with 45577 additions and 506 deletions

View File

@@ -9,40 +9,35 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
class City extends Model
{
use ModelTrait;
protected $table = 'system_cities';
protected $table = 'system_city';
protected $fillable = [
'parent_id',
'name',
'title',
'code',
'pinyin',
'pinyin_short',
'level',
'sort',
'status',
];
protected $casts = [
'parent_id' => 'integer',
'level' => 'integer',
'sort' => 'integer',
'status' => 'boolean',
'parent_code',
];
/**
* 子级城市
*/
public function children(): HasMany
{
return $this->hasMany(City::class, 'parent_id')->orderBy('sort');
}
public function activeChildren(): HasMany
{
return $this->hasMany(City::class, 'parent_id')
->where('status', true)
->orderBy('sort');
return $this->hasMany(City::class, 'parent_code', 'code');
}
/**
* 父级城市
*/
public function parent()
{
return $this->belongsTo(City::class, 'parent_id');
return $this->belongsTo(City::class, 'parent_code', 'code');
}
/**
* 判断是否是顶级城市(省/直辖市/自治区)
*/
public function isTopLevel(): bool
{
return empty($this->parent_code);
}
}

View File

@@ -10,7 +10,7 @@ class Config extends Model
{
use ModelTrait, SoftDeletes;
protected $table = 'system_configs';
protected $table = 'system_setting';
protected $fillable = [
'group',

View File

@@ -11,7 +11,7 @@ class Dictionary extends Model
{
use ModelTrait, SoftDeletes;
protected $table = 'system_dictionaries';
protected $table = 'system_dictionary';
protected $fillable = [
'name',

View File

@@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
class DictionaryItem extends Model
{
use ModelTrait;
protected $table = 'system_dictionary_items';
protected $table = 'system_dictionary_item';
protected $fillable = [
'dictionary_id',

View File

@@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Log extends Model
{
use ModelTrait;
protected $table = 'system_logs';
protected $table = 'system_log';
protected $fillable = [
'user_id',

View File

@@ -11,7 +11,7 @@ class Notification extends Model
{
use ModelTrait, SoftDeletes;
protected $table = 'system_notifications';
protected $table = 'system_notification';
protected $fillable = [
'user_id',

View File

@@ -10,7 +10,7 @@ class Task extends Model
{
use ModelTrait, SoftDeletes;
protected $table = 'system_tasks';
protected $table = 'system_task';
protected $fillable = [
'name',