Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/laracademy/generators
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael McMullen committed Nov 14, 2019
2 parents 1ed0b2f + d9ffb41 commit fc19a29
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/Commands/ModelFromTableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,19 +283,23 @@ public function getOptions()
// connection
$this->options['connection'] = ($this->option('connection')) ? $this->option('connection') : '';

// folder
// first check for namespace
if(! $this->option('namespace')) {
// set the namespace to the folder
$this->options['namespace'] = Str::studly($this->option('folder'));
// namespace with possible folder
// if there is no folder specified and no namespace
if(! $this->option('folder') && ! $this->option('namespace')) {
// assume default APP
$this->options['namespace'] = 'App';
} else {
// default namespace
$this->options['namespace'] = ($this->option('namespace')) ? str_replace('app', 'App', $this->option('namespace')) : 'App';
// remove trailing slash if exists
$this->options['namespace'] = rtrim($this->options['namespace'], '/');
// fix slashes
$this->options['namespace'] = str_replace('/', '\\', $this->options['namespace']);
// if we have a namespace, use it first
if($this->option('namespace')) {
$this->options['namespace'] = str_replace('/', '\\', $this->option('namespace'));
} else {
if($this->option('folder')) {
$folder = $this->option('folder');
$this->options['namespace'] = str_replace('/', '\\', $folder);
}
}
}

// finish setting up folder
$this->options['folder'] = ($this->option('folder')) ? base_path($this->option('folder')) : app()->path();
// trim trailing slashes
Expand Down

0 comments on commit fc19a29

Please sign in to comment.