forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow table-qualified columns in pluck operations
- Loading branch information
1 parent
bce8cb7
commit 597a0af
Showing
2 changed files
with
20 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,6 +179,20 @@ public function testPluck() | |
$this->assertEquals([1 => '[email protected]', 2 => '[email protected]'], $keyed); | ||
} | ||
|
||
public function testPluckWithJoin() | ||
{ | ||
$user1 = EloquentTestUser::create(['id' => 1, 'email' => '[email protected]']); | ||
$user2 = EloquentTestUser::create(['id' => 2, 'email' => '[email protected]']); | ||
|
||
$user2->posts()->create(['id' => 1, 'name' => 'First post']); | ||
$user1->posts()->create(['id' => 2, 'name' => 'Second post']); | ||
|
||
$query = EloquentTestUser::join('posts', 'users.id', '=', 'posts.user_id'); | ||
|
||
$this->assertEquals([1 => 'First post', 2 => 'Second post'], $query->pluck('name', 'posts.id')->all()); | ||
$this->assertEquals([2 => 'First post', 1 => 'Second post'], $query->pluck('name', 'users.id')->all()); | ||
} | ||
|
||
public function testFindOrFail() | ||
{ | ||
EloquentTestUser::create(['id' => 1, 'email' => '[email protected]']); | ||
|