Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
fix model with additional flag creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Aug 28, 2019
1 parent 8507fc8 commit ae2e04b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 deletions.
20 changes: 11 additions & 9 deletions src/Commands/Database/MigrationMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ class MigrationMakeCommand extends MakeMigration
/**
* Create a new migration install command instance.
*
* @param Illuminate\Filesystem\Filesystem $creator
* @param \Illuminate\Database\Migrations\MigrationCreator $creator
* @param \Illuminate\Support\Composer $composer
* @return void
* @param Illuminate\Filesystem\Filesystem $creator
* @param \Illuminate\Database\Migrations\MigrationCreator $creator
* @param \Illuminate\Support\Composer $composer
*/
public function __construct(Filesystem $files, MigrationCreator $creator, Composer $composer)
{
Expand All @@ -50,23 +49,24 @@ public function __construct(Filesystem $files, MigrationCreator $creator, Compos
*/
protected function getMigrationPath()
{
$path = $this->basePath().'database/migrations';
$path = $this->basePath() . 'database/migrations';

if (! is_null($targetPath = $this->input->getOption('path'))) {
$path = ! $this->usingRealPath()
? $this->basePath().$targetPath
? $this->basePath() . $targetPath
: $targetPath;
}

$this->makeDirectory($path.'/some_migration.php');
$this->makeDirectory($path . '/some_migration.php');

return $path;
}

/**
* Build the directory for the class if necessary.
*
* @param string $path
* @param string $path
*
* @return string
*/
protected function makeDirectory($path)
Expand All @@ -92,7 +92,9 @@ protected function additionalOptions()

['path', null, InputOption::VALUE_REQUIRED, 'The location where the migration file should be created'],

['realpath', null, InputOption::VALUE_REQUIRED, 'Indicate any provided migration file paths are pre - resolved absolute paths'],
['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre - resolved absolute paths'],

['fullpath', null, InputOption::VALUE_NONE, 'Output the full path of the migration'],
];
}
}
20 changes: 7 additions & 13 deletions src/Commands/Foundation/ModelMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ class ModelMakeCommand extends MakeModel
*/
protected function resolveDirectory()
{
return $this->getDirInput().'src';
return $this->getDirInput() . 'src';
}

/**
* Create a model factory for the model.
*
* @return void
*/
protected function createFactory()
{
Expand All @@ -39,15 +37,13 @@ protected function createFactory()
$this->call('package:factory', [
'name' => "{$factory}Factory",
'--model' => $this->argument('name'),
'--namespace' => $this->rootNamespace(),
'--dir' => $this->basePath(),
'--namespace' => $this->getNamespaceInput(),
'--dir' => $this->getDirInput(),
]);
}

/**
* Create a migration file for the model.
*
* @return void
*/
protected function createMigration()
{
Expand All @@ -56,15 +52,13 @@ protected function createMigration()
$this->call('package:migration', [
'name' => "create_{$table}_table",
'--create' => $table,
'--namespace' => $this->rootNamespace(),
'--dir' => $this->basePath(),
'--namespace' => $this->getNamespaceInput(),
'--dir' => $this->getDirInput(),
]);
}

/**
* Create a controller for the model.
*
* @return void
*/
protected function createController()
{
Expand All @@ -75,8 +69,8 @@ protected function createController()
$this->call('package:controller', [
'name' => "{$controller}Controller",
'--model' => $this->option('resource') ? $modelName : null,
'--namespace' => $this->rootNamespace(),
'--dir' => $this->basePath(),
'--namespace' => $this->getNamespaceInput(),
'--dir' => $this->getDirInput(),
]);
}
}
16 changes: 8 additions & 8 deletions src/Commands/Routing/ControllerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class ControllerMakeCommand extends MakeController
*/
protected function resolveDirectory()
{
// Illuminate\Routing\Controller DummyRootNamespaceHttp\Controllers\Controller;

return $this->getDirInput().'src';
return $this->getDirInput() . 'src';
}

/**
Expand All @@ -40,9 +38,9 @@ protected function buildClass($name)
{
$class = parent::buildClass($name);

if (str_contains($class, $this->rootNamespace().'Http\Controllers\Controller')) {
if (str_contains($class, $this->rootNamespace() . 'Http\Controllers\Controller')) {
return str_replace(
$this->rootNamespace().'Http\Controllers\Controller',
$this->rootNamespace() . 'Http\Controllers\Controller',
'Illuminate\Routing\Controller',
$class
);
Expand Down Expand Up @@ -84,7 +82,8 @@ protected function buildParentReplacements()
/**
* Build the model replacement values.
*
* @param array $replace
* @param array $replace
*
* @return array
*/
protected function buildModelReplacements(array $replace)
Expand All @@ -111,7 +110,8 @@ protected function buildModelReplacements(array $replace)
/**
* Get the fully-qualified model class name.
*
* @param string $model
* @param string $model
*
* @return string
*/
protected function parseModel($model)
Expand All @@ -123,7 +123,7 @@ protected function parseModel($model)
$model = trim(str_replace('/', '\\', $model), '\\');

if (! starts_with($model, $rootNamespace = $this->rootNamespace()) && ! starts_with($model, $this->laravel->getNamespace())) {
$model = $rootNamespace.'\\'.$model;
$model = $rootNamespace . '\\' . $model;
}

return $model;
Expand Down

0 comments on commit ae2e04b

Please sign in to comment.