|
|
|
@ -62,6 +62,8 @@ class CrudMake extends Command |
|
|
|
public function handle() |
|
|
|
{ |
|
|
|
$this->getModelName(); |
|
|
|
|
|
|
|
if ( ! $this->modelExists()) { |
|
|
|
$this->generateResourceRoute(); |
|
|
|
|
|
|
|
$this->generateModel(); |
|
|
|
@ -75,6 +77,9 @@ class CrudMake extends Command |
|
|
|
$this->info('CRUD files generated successfully!'); |
|
|
|
} |
|
|
|
|
|
|
|
$this->error("{$this->modelNames['model_name']} model already exists."); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Generate class properties for model names in different usage |
|
|
|
* |
|
|
|
@ -93,6 +98,16 @@ class CrudMake extends Command |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Check for Model file existance |
|
|
|
* |
|
|
|
* @return void |
|
|
|
*/ |
|
|
|
public function modelExists() |
|
|
|
{ |
|
|
|
return $this->files->exists(app_path($this->modelNames['model_name'].'.php')); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Generate the model file |
|
|
|
* |
|
|
|
* @return void |
|
|
|
@ -128,7 +143,10 @@ class CrudMake extends Command |
|
|
|
{ |
|
|
|
$prefix = date('Y_m_d_His'); |
|
|
|
$tableName = $this->modelNames['lowercase_plural_model_name']; |
|
|
|
$migrationFilePath = database_path("migrations/{$prefix}_create_{$tableName}_table.php"); |
|
|
|
|
|
|
|
$migrationPath = $this->makeDirectory(database_path('migrations')); |
|
|
|
|
|
|
|
$migrationFilePath = $migrationPath.'/'.$prefix."_create_{$tableName}_table.php"; |
|
|
|
$this->generateFile($migrationFilePath, $this->getMigrationContent()); |
|
|
|
|
|
|
|
$this->info($this->modelNames['model_name'].' table migration generated.'); |
|
|
|
@ -172,7 +190,10 @@ class CrudMake extends Command |
|
|
|
{ |
|
|
|
$modelFactoryPath = $this->makeDirectory(database_path('factories')); |
|
|
|
|
|
|
|
$this->generateFile($modelFactoryPath.'/'.$this->modelNames['model_name'].'Factory.php', $this->getModelFactoryContent()); |
|
|
|
$this->generateFile( |
|
|
|
$modelFactoryPath.'/'.$this->modelNames['model_name'].'Factory.php', |
|
|
|
$this->getModelFactoryContent() |
|
|
|
); |
|
|
|
|
|
|
|
$this->info($this->modelNames['lowercase_single_model_name'].' model factory generated.'); |
|
|
|
} |
|
|
|
|