Merge branch 'master' of https://gitee.com/paddy_technology/dcat-admin
commit
f90cdc1e78
|
|
@ -9,7 +9,6 @@ use Peidikeji\Goods\Filters\GoodsFilter;
|
|||
|
||||
class Goods extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use Filterable;
|
||||
|
||||
protected $table = 'goods';
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ class CreateGoodsTable extends Migration
|
|||
$table->json('spec')->nullable()->comment('规格[{name, values: [{name, value}]}]');
|
||||
$table->json('part')->nullable()->comment('配件[{name, values: [{name, value}]}]');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->foreign('category_id')->references('id')->on('goods_category');
|
||||
$table->foreign('type_id')->references('id')->on('goods_type');
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ class AdminServiceProvider extends ServiceProvider
|
|||
Console\ExtensionDiableCommand::class,
|
||||
Console\ExtensionUpdateCommand::class,
|
||||
Console\UpdateCommand::class,
|
||||
Console\ModelFillable::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Dcat\Admin\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ModelFillable extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'model:fillable {table}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'get model fillable ';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$table = $this->argument('table');
|
||||
$except = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
if (Schema::hasTable($table)) {
|
||||
if (DB::getDefaultConnection() === 'mysql') {
|
||||
$list = DB::table('information_schema.columns')->where(['table_schema' => config('database.connections.mysql.database'), 'table_name' => $table])->pluck('COLUMN_NAME')->all();
|
||||
} else {
|
||||
$list = Schema::getColumnListing($table);
|
||||
}
|
||||
$list = array_filter($list, fn($v) => !in_array($v, $except));
|
||||
$this->info("protected \$fillable = ['".implode('\', \'', $list)."'];");
|
||||
} else {
|
||||
$this->error('table ' . $table . ' is not exists');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue