Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/Commands/PolicyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PolicyCommand extends GeneratorCommand

public function handle()
{
if (parent::handle() === false && !$this->option('force')) {
if (parent::handle() === false && ! $this->option('force')) {
return false;
}
}
Expand Down Expand Up @@ -42,15 +42,14 @@ protected function replaceModel($stub)

protected function replaceQualifiedModel($stub)
{

return str_replace('{{ modelQualified }}', $this->guessQualifiedModel(), $stub);
}

protected function guessQualifiedModel(): string
{
$model = Str::singular(class_basename(Str::beforeLast($this->getNameInput(), 'Policy')));

return str_replace('/', '\\', $this->rootNamespace() . 'Models/' . $model);
return str_replace('/', '\\', $this->rootNamespace().'Models/'.$model);
}

protected function guessPolicyName()
Expand All @@ -66,7 +65,7 @@ protected function guessPolicyName()

protected function getPath($name)
{
return $this->laravel['path'] . '/Policies/' . $this->guessPolicyName() . '.php';
return $this->laravel['path'].'/Policies/'.$this->guessPolicyName().'.php';
}

/**
Expand All @@ -76,7 +75,7 @@ protected function getPath($name)
*/
protected function getStub()
{
return __DIR__ . '/stubs/policy.stub';
return __DIR__.'/stubs/policy.stub';
}

/**
Expand All @@ -87,7 +86,7 @@ protected function getStub()
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace . '\Policies';
return $rootNamespace.'\Policies';
}

/**
Expand Down