1.laravel 使用已有数据库自动创建model
php artisan make:command create_model
app/Console/Console/Commandscreate_model.php
protected $signature = 'my:create_model';
public function handle()
{
$tables = DB::select(DB::raw('show tables'));
foreach ($tables as $table) {
foreach ($table as $v) {
$table_names[] = $v;
$this->call('make:model', ['name'=>$v]);
}
}
}
app/Console/Console/Kernel.php
protected $commands = [
Commandscreate_model::class
];