From 466c8e1041f4a4cd42c2ab0798248ee7afc657dd Mon Sep 17 00:00:00 2001 From: tiagomichaelsousa Date: Tue, 7 Apr 2020 18:12:59 +0100 Subject: [PATCH] Apply fixes from StyleCI (#24) --- src/Commands/ResourceCommand.php | 9 ++++----- src/Generators/FactoryGenerator.php | 2 +- src/Generators/MigrationGenerator.php | 6 ++++-- src/Generators/SeederGenerator.php | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Commands/ResourceCommand.php b/src/Commands/ResourceCommand.php index 8542854..c59854e 100644 --- a/src/Commands/ResourceCommand.php +++ b/src/Commands/ResourceCommand.php @@ -71,7 +71,7 @@ class ResourceCommand extends Command */ private function modelExists() { - return File::exists(base_path(lcfirst(str_replace('\\', '/', config('laravel-resources.models.namespace')))) . "/{$this->model}.php"); + return File::exists(base_path(lcfirst(str_replace('\\', '/', config('laravel-resources.models.namespace'))))."/{$this->model}.php"); } /** @@ -82,7 +82,6 @@ private function modelExists() private function createModelResources() { foreach ($this->modelResources as $resource => $generator) { - if ($this->confirm("Should I create the {$resource} for {$this->model}?", true)) { array_push($this->resources, $generator); } @@ -96,7 +95,7 @@ private function createModelResources() */ private function createResources() { - $this->info('Creating ' . count($this->resources) . ' resources ...'); + $this->info('Creating '.count($this->resources).' resources ...'); $this->line(''); $bar = $this->getOutput()->createProgressBar(count($this->resources)); @@ -128,10 +127,10 @@ public function handle() $this->model = $this->argument('model'); - if (!$this->modelExists($this->model)) { + if (! $this->modelExists($this->model)) { $this->info("The model {$this->model} does not exists."); - if (!$this->confirm('Should I create it?', true)) { + if (! $this->confirm('Should I create it?', true)) { return; } diff --git a/src/Generators/FactoryGenerator.php b/src/Generators/FactoryGenerator.php index 4efdb28..b459467 100644 --- a/src/Generators/FactoryGenerator.php +++ b/src/Generators/FactoryGenerator.php @@ -31,7 +31,7 @@ public function __construct($model) */ public function getStub() { - return File::get(__DIR__ . '/../stubs/factories/factory.stub'); + return File::get(__DIR__.'/../stubs/factories/factory.stub'); } /** diff --git a/src/Generators/MigrationGenerator.php b/src/Generators/MigrationGenerator.php index 38567c6..2f638f2 100644 --- a/src/Generators/MigrationGenerator.php +++ b/src/Generators/MigrationGenerator.php @@ -33,7 +33,7 @@ public function __construct($model) */ public function getStub() { - return File::get(__DIR__ . '/../stubs/migrations/migration.stub'); + return File::get(__DIR__.'/../stubs/migrations/migration.stub'); } /** @@ -79,6 +79,7 @@ public function directoryExists($path) public function className() { $name = Str::plural($this->model); + return "Create{$name}Table"; } @@ -89,8 +90,9 @@ public function className() */ public function fileName() { - $date = Carbon::now()->format("Y_m_d_Hms"); + $date = Carbon::now()->format('Y_m_d_Hms'); $name = Str::lower(Str::snake($this->className())); + return "{$date}_{$name}.php"; } diff --git a/src/Generators/SeederGenerator.php b/src/Generators/SeederGenerator.php index 1bb18c4..8e96de3 100644 --- a/src/Generators/SeederGenerator.php +++ b/src/Generators/SeederGenerator.php @@ -32,7 +32,7 @@ public function __construct($model) */ public function getStub() { - return File::get(__DIR__ . '/../stubs/seeds/seed.stub'); + return File::get(__DIR__.'/../stubs/seeds/seed.stub'); } /** @@ -80,6 +80,7 @@ public function directoryExists($path) public function className() { $plural = Str::plural($this->model); + return "{$plural}TableSeeder"; }