删除 app/Console/ModelFillable.php
parent
94d63048a5
commit
0d81745906
|
|
@ -1,54 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class ModelFillable extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'model:fillable {table} {--connection}';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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');
|
|
||||||
$ignore = ['id', 'created_at', 'updated_at', 'deleted_at'];
|
|
||||||
$connection = $this->option('connection');
|
|
||||||
if (! $connection) {
|
|
||||||
$connection = config('database.default');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Schema::connection($connection)->hasTable($table)) {
|
|
||||||
$list = Schema::connection($connection)->getColumnListing($table);
|
|
||||||
$list = array_filter($list, function ($value) use ($ignore) {
|
|
||||||
return ! in_array($value, $ignore);
|
|
||||||
});
|
|
||||||
$this->info("protected \$fillable = ['".implode('\', \'', $list)."'];");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue