From 28889f2e4223fa16ab7bde76bc495588ec4c0bd0 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Fri, 20 Jul 2018 09:56:25 +0800 Subject: [PATCH] Change nameLink method to name_link attribute --- src/stubs/model.stub | 2 +- src/stubs/test-unit.stub | 4 ++-- src/stubs/view-index-full.stub | 2 +- tests/Generators/ModelGeneratorTest.php | 4 ++-- tests/Generators/ModelTestGeneratorTest.php | 8 ++++---- tests/Generators/ViewsGeneratorTest.php | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/stubs/model.stub b/src/stubs/model.stub index 761c0a7..0eab126 100644 --- a/src/stubs/model.stub +++ b/src/stubs/model.stub @@ -9,7 +9,7 @@ class Master extends Model { protected $fillable = ['name', 'description', 'creator_id']; - public function nameLink() + public function getNameLinkAttribute() { return link_to_route('masters.show', $this->name, [$this], [ 'title' => trans( diff --git a/src/stubs/test-unit.stub b/src/stubs/test-unit.stub index 6f4ab8b..54b3217 100644 --- a/src/stubs/test-unit.stub +++ b/src/stubs/test-unit.stub @@ -12,7 +12,7 @@ class MasterTest extends TestCase use DatabaseMigrations; /** @test */ - public function a_master_has_name_link_method() + public function a_master_has_name_link_attribute() { $singleMstr = factory(Master::class)->create(); @@ -22,7 +22,7 @@ class MasterTest extends TestCase 'app.show_detail_title', ['name' => $singleMstr->name, 'type' => trans('master.master')] ), - ]), $singleMstr->nameLink() + ]), $singleMstr->name_link ); } diff --git a/src/stubs/view-index-full.stub b/src/stubs/view-index-full.stub index 5a24ce3..7c40250 100644 --- a/src/stubs/view-index-full.stub +++ b/src/stubs/view-index-full.stub @@ -35,7 +35,7 @@ @foreach($mstrCollections as $key => $singleMstr) {{ $mstrCollections->firstItem() + $key }} - {{ $singleMstr->nameLink() }} + {{ $singleMstr->name_link }} {{ $singleMstr->description }} @can('view', $singleMstr) diff --git a/tests/Generators/ModelGeneratorTest.php b/tests/Generators/ModelGeneratorTest.php index 1f71dd8..324eb8c 100644 --- a/tests/Generators/ModelGeneratorTest.php +++ b/tests/Generators/ModelGeneratorTest.php @@ -24,7 +24,7 @@ class {$this->model_name} extends Model { protected \$fillable = ['name', 'description', 'creator_id']; - public function nameLink() + public function getNameLinkAttribute() { return link_to_route('{$this->table_name}.show', \$this->name, [\$this], [ 'title' => trans( @@ -61,7 +61,7 @@ class Category extends Model { protected \$fillable = ['name', 'description', 'creator_id']; - public function nameLink() + public function getNameLinkAttribute() { return link_to_route('categories.show', \$this->name, [\$this], [ 'title' => trans( diff --git a/tests/Generators/ModelTestGeneratorTest.php b/tests/Generators/ModelTestGeneratorTest.php index ecd3591..cfdd224 100644 --- a/tests/Generators/ModelTestGeneratorTest.php +++ b/tests/Generators/ModelTestGeneratorTest.php @@ -27,7 +27,7 @@ class {$this->model_name}Test extends TestCase use DatabaseMigrations; /** @test */ - public function a_{$this->lang_name}_has_name_link_method() + public function a_{$this->lang_name}_has_name_link_attribute() { \${$this->single_model_var_name} = factory({$this->model_name}::class)->create(); @@ -37,7 +37,7 @@ class {$this->model_name}Test extends TestCase 'app.show_detail_title', ['name' => \${$this->single_model_var_name}->name, 'type' => trans('{$this->lang_name}.{$this->lang_name}')] ), - ]), \${$this->single_model_var_name}->nameLink() + ]), \${$this->single_model_var_name}->name_link ); } @@ -78,7 +78,7 @@ class {$this->model_name}Test extends TestCase use DatabaseMigrations; /** @test */ - public function a_{$this->lang_name}_has_name_link_method() + public function a_{$this->lang_name}_has_name_link_attribute() { \${$this->single_model_var_name} = factory({$this->model_name}::class)->create(); @@ -88,7 +88,7 @@ class {$this->model_name}Test extends TestCase 'app.show_detail_title', ['name' => \${$this->single_model_var_name}->name, 'type' => trans('{$this->lang_name}.{$this->lang_name}')] ), - ]), \${$this->single_model_var_name}->nameLink() + ]), \${$this->single_model_var_name}->name_link ); } diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index ea12688..4001506 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -51,7 +51,7 @@ class ViewsGeneratorTest extends TestCase @foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name}) {{ \${$this->collection_model_var_name}->firstItem() + \$key }} - {{ \${$this->single_model_var_name}->nameLink() }} + {{ \${$this->single_model_var_name}->name_link }} {{ \${$this->single_model_var_name}->description }} @can('view', \${$this->single_model_var_name})