调整数据库表的单复数
This commit is contained in:
@@ -11,7 +11,7 @@ class Department extends Model
|
||||
{
|
||||
use ModelTrait, SoftDeletes;
|
||||
|
||||
protected $table = 'auth_departments';
|
||||
protected $table = 'auth_department';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
|
||||
@@ -11,7 +11,7 @@ class Permission extends Model
|
||||
{
|
||||
use ModelTrait, SoftDeletes;
|
||||
|
||||
protected $table = 'auth_permissions';
|
||||
protected $table = 'auth_permission';
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
|
||||
@@ -11,7 +11,7 @@ class Role extends Model
|
||||
{
|
||||
use ModelTrait, SoftDeletes;
|
||||
|
||||
protected $table = 'auth_roles';
|
||||
protected $table = 'auth_role';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
|
||||
@@ -14,7 +14,7 @@ class User extends Authenticatable implements JWTSubject
|
||||
{
|
||||
use ModelTrait, SoftDeletes;
|
||||
|
||||
protected $table = 'auth_users';
|
||||
protected $table = 'auth_user';
|
||||
|
||||
protected $fillable = [
|
||||
'username',
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class Config extends Model
|
||||
{
|
||||
use ModelTrait, SoftDeletes;
|
||||
|
||||
protected $table = 'system_configs';
|
||||
protected $table = 'system_setting';
|
||||
|
||||
protected $fillable = [
|
||||
'group',
|
||||
|
||||
@@ -11,7 +11,7 @@ class Dictionary extends Model
|
||||
{
|
||||
use ModelTrait, SoftDeletes;
|
||||
|
||||
protected $table = 'system_dictionaries';
|
||||
protected $table = 'system_dictionary';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -11,7 +11,7 @@ class Notification extends Model
|
||||
{
|
||||
use ModelTrait, SoftDeletes;
|
||||
|
||||
protected $table = 'system_notifications';
|
||||
protected $table = 'system_notification';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
|
||||
@@ -10,7 +10,7 @@ class Task extends Model
|
||||
{
|
||||
use ModelTrait, SoftDeletes;
|
||||
|
||||
protected $table = 'system_tasks';
|
||||
protected $table = 'system_task';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
|
||||
Reference in New Issue
Block a user