From 310abe796dd85ef5156f41b1fb812fe964f83e96 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Tue, 17 Nov 2015 12:31:33 +0530 Subject: [PATCH] apply more cs fixes --- src/Traits/BelongsToThrough.php | 2 -- tests/BelongsToThroughTest.php | 43 ++++++++++++++++----------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/Traits/BelongsToThrough.php b/src/Traits/BelongsToThrough.php index 1d0ece0..bc7938d 100644 --- a/src/Traits/BelongsToThrough.php +++ b/src/Traits/BelongsToThrough.php @@ -22,8 +22,6 @@ trait BelongsToThrough * @param string|null $localKey * * @return \Znck\Eloquent\Relations\BelongsToThrough - * - * @throws \Exception */ public function belongsToThrough($related, $through, $localKey = null) { diff --git a/tests/BelongsToThroughTest.php b/tests/BelongsToThroughTest.php index fe8f9e7..35c4faa 100644 --- a/tests/BelongsToThroughTest.php +++ b/tests/BelongsToThroughTest.php @@ -1,33 +1,30 @@ set('database.default', 'testbench'); $app['config']->set('database.connections.testbench', [ - 'driver' => 'sqlite', - 'database' => __DIR__ . '/database.sqlite', - 'prefix' => '', + 'driver' => 'sqlite', + 'database' => __DIR__.'/database.sqlite', + 'prefix' => '', ]); } - public function test_through_one() { $district = Stub_Test_Model_District::where('id', 1)->first(); @@ -36,7 +33,6 @@ public function test_through_one() $this->assertEquals(1, $district->country->id); } - public function test_through_two() { $city = Stub_Test_Model_City::where('id', 1)->first(); @@ -45,7 +41,6 @@ public function test_through_two() $this->assertEquals(1, $city->country->id); } - public function test_eager_loading() { $cities = Stub_Test_Model_City::with('country')->where('id', '<', 17)->get(); @@ -57,7 +52,8 @@ public function test_eager_loading() } } - public function test_has_relation() { + public function test_has_relation() + { $cities_with_country = Stub_Test_Model_City::has('country')->get(); $all_cities = Stub_Test_Model_City::all(); @@ -66,16 +62,20 @@ public function test_has_relation() { } } -class Stub_Parent_Model extends Eloquent { - public function getForeignKey() { - return Str::singular($this->getTable()).'_id'; - } +class Stub_Parent_Model extends Eloquent +{ + public function getForeignKey() + { + return Str::singular($this->getTable()).'_id'; + } } -class Stub_Test_Model_Contient extends Stub_Parent_Model { +class Stub_Test_Model_Contient extends Stub_Parent_Model +{ protected $table = 'continents'; - public function countries() { + public function countries() + { return $this->hasMany(Stub_Test_Model_Country::class); } } @@ -84,7 +84,8 @@ class Stub_Test_Model_Country extends Stub_Parent_Model { protected $table = 'countries'; - public function continent() { + public function continent() + { return $this->belongsTo(Stub_Test_Model_Contient::class); } } @@ -96,7 +97,6 @@ class Stub_Test_Model_State extends Stub_Parent_Model class Stub_Test_Model_District extends Stub_Parent_Model { - use BelongsToThrough; protected $table = 'districts'; @@ -109,13 +109,12 @@ public function country() class Stub_Test_Model_City extends Stub_Parent_Model { - use BelongsToThrough; protected $table = 'cities'; public function country() { - return $this->belongsToThrough(Stub_Test_Model_Country::class, [ Stub_Test_Model_State::class, Stub_Test_Model_District::class ]); + return $this->belongsToThrough(Stub_Test_Model_Country::class, [Stub_Test_Model_State::class, Stub_Test_Model_District::class]); } }