-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
admin
committed
Apr 14, 2020
1 parent
ae94319
commit e9edd6f
Showing
13 changed files
with
141 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Fico7489\Laravel\EloquentJoin\Relations; | ||
|
||
use Fico7489\Laravel\EloquentJoin\Traits\JoinRelationTrait; | ||
use Illuminate\Database\Eloquent\Relations\BelongsToMany; | ||
|
||
class BelongsToManyJoin extends BelongsToMany | ||
{ | ||
use JoinRelationTrait; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Fico7489\Laravel\EloquentJoin\Tests\Models; | ||
|
||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class Tag extends BaseModel | ||
{ | ||
use SoftDeletes; | ||
|
||
protected $table = 'tags'; | ||
|
||
protected $fillable = ['name']; | ||
|
||
public function sellers() | ||
{ | ||
return $this->morphedByMany(Seller::class, 'taggable'); | ||
} | ||
|
||
public function users() | ||
{ | ||
return $this->morphedByMany(User::class, 'taggable'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Fico7489\Laravel\EloquentJoin\Tests\Tests\Relations; | ||
|
||
use Fico7489\Laravel\EloquentJoin\Tests\Models\City; | ||
use Fico7489\Laravel\EloquentJoin\Tests\TestCase; | ||
|
||
class BelongToManyTest extends TestCase | ||
{ | ||
public function testBelongsToMany() | ||
{ | ||
City::joinRelations('sellers')->get(); | ||
|
||
$queryTest = 'select cities.* from "cities" | ||
left join "locations" on "locations"."city_id" = "cities"."id" | ||
left join "sellers" on "sellers"."id" = "locations"."seller_id" | ||
where "cities"."deleted_at" is null | ||
group by "cities"."id"'; | ||
|
||
$this->assertQueryMatches($queryTest, $this->fetchQuery()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters