Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jul 10, 2017
1 parent ad13897 commit a7094c2
Showing 1 changed file with 12 additions and 28 deletions.
40 changes: 12 additions & 28 deletions src/Illuminate/Foundation/Console/PolicyMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,32 @@ class PolicyMakeCommand extends GeneratorCommand
*/
protected function buildClass($name)
{
$stub = parent::buildClass($name);

$stub = $this->replaceUserModelNamespace($stub);
$stub = $this->replaceUserNamespace(
parent::buildClass($name)
);

$model = $this->option('model');

return $model ? $this->replaceModel($stub, $model) : $stub;
}

/**
* Replace the user model namespace for the given stub.
* Replace the User model namespace.
*
* @param string $stub
* @return string
*/
protected function replaceUserModelNamespace($stub)
protected function replaceUserNamespace($stub)
{
if ($this->getDefaultUserNamespace() != $this->getRealUserNamespace()) {
return str_replace($this->getDefaultUserNamespace(), $this->getRealUserNamespace(), $stub);
if (! config('auth.providers.users.model')) {
return $stub;
}

return $stub;
}

/**
* Get the default namespace for the user model.
*
* @return string
*/
public function getDefaultUserNamespace()
{
return $this->rootNamespace().'User';
}

/**
* Get the real namespace for the user model.
*
* @return string
*/
public function getRealUserNamespace()
{
return config('auth.providers.users.model');
return str_replace(
$this->rootNamespace().'User',
config('auth.providers.users.model'),
$stub
);
}

/**
Expand Down

0 comments on commit a7094c2

Please sign in to comment.