初始化项目
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\System;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class City extends Model
|
||||
{
|
||||
protected $table = 'system_cities';
|
||||
|
||||
protected $fillable = [
|
||||
'parent_id',
|
||||
'name',
|
||||
'code',
|
||||
'pinyin',
|
||||
'pinyin_short',
|
||||
'level',
|
||||
'sort',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'parent_id' => 'integer',
|
||||
'level' => 'integer',
|
||||
'sort' => 'integer',
|
||||
'status' => 'boolean',
|
||||
];
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(City::class, 'parent_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\System;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Config extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'system_configs';
|
||||
|
||||
protected $fillable = [
|
||||
'group',
|
||||
'key',
|
||||
'name',
|
||||
'type',
|
||||
'options',
|
||||
'value',
|
||||
'default_value',
|
||||
'description',
|
||||
'validation',
|
||||
'sort',
|
||||
'is_system',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'options' => 'array',
|
||||
'is_system' => 'boolean',
|
||||
'status' => 'boolean',
|
||||
];
|
||||
|
||||
public function getOptionsAttribute($value)
|
||||
{
|
||||
if (is_string($value)) {
|
||||
return json_decode($value, true) ?? [];
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function setOptionsAttribute($value)
|
||||
{
|
||||
$this->attributes['options'] = is_array($value) ? json_encode($value) : $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\System;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Dictionary extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'system_dictionaries';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'code',
|
||||
'description',
|
||||
'status',
|
||||
'sort',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'status' => 'boolean',
|
||||
];
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(DictionaryItem::class, 'dictionary_id')->orderBy('sort');
|
||||
}
|
||||
|
||||
public function activeItems(): HasMany
|
||||
{
|
||||
return $this->hasMany(DictionaryItem::class, 'dictionary_id')
|
||||
->where('status', true)
|
||||
->orderBy('sort');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\System;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class DictionaryItem extends Model
|
||||
{
|
||||
protected $table = 'system_dictionary_items';
|
||||
|
||||
protected $fillable = [
|
||||
'dictionary_id',
|
||||
'label',
|
||||
'value',
|
||||
'color',
|
||||
'description',
|
||||
'is_default',
|
||||
'status',
|
||||
'sort',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_default' => 'boolean',
|
||||
'status' => 'boolean',
|
||||
];
|
||||
|
||||
public function dictionary(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Dictionary::class, 'dictionary_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\System;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Log extends Model
|
||||
{
|
||||
protected $table = 'system_logs';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'username',
|
||||
'module',
|
||||
'action',
|
||||
'method',
|
||||
'url',
|
||||
'ip',
|
||||
'user_agent',
|
||||
'params',
|
||||
'result',
|
||||
'status_code',
|
||||
'status',
|
||||
'error_message',
|
||||
'execution_time',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'params' => 'array',
|
||||
'execution_time' => 'integer',
|
||||
'status_code' => 'integer',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Auth\User::class, 'user_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\System;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Task extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'system_tasks';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'command',
|
||||
'description',
|
||||
'type',
|
||||
'expression',
|
||||
'timezone',
|
||||
'is_active',
|
||||
'run_in_background',
|
||||
'without_overlapping',
|
||||
'only_one',
|
||||
'last_run_at',
|
||||
'next_run_at',
|
||||
'last_output',
|
||||
'run_count',
|
||||
'failed_count',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'run_in_background' => 'boolean',
|
||||
'without_overlapping' => 'boolean',
|
||||
'only_one' => 'boolean',
|
||||
'last_run_at' => 'datetime',
|
||||
'next_run_at' => 'datetime',
|
||||
'run_count' => 'integer',
|
||||
'failed_count' => 'integer',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user