Skip to content

Instantly share code, notes, and snippets.

@peterfox
Created March 3, 2019 01:31
<?php
namespace App\Console\Commands;
use Illuminate\Foundation\Console\ModelMakeCommand as BaseCommand;
use Illuminate\Support\Str;
class ModelMakeCommand extends BaseCommand
{
/**
* Create a migration file for the model.
*
* @return void
*/
protected function createMigration()
{
$table = Str::snake(class_basename($this->argument('name')));
if ($this->option('pivot')) {
$table = Str::singular($table);
}
$this->call('make:migration', [
'name' => "create_{$table}_table",
'--create' => $table,
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment