Skip to content

Commit 10c6a9c

Browse files
Fix broken tests :
- explicitly set the order of items in testWithBelongsTo - fix a possible bug in Model::belongsToMany due to recent changes in Laravel Core
1 parent 5d3343b commit 10c6a9c

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/Jenssegers/Eloquent/Model.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,7 @@ public function belongsToMany($related, $collection = null, $foreignKey = null,
191191
// title of this relation since that is a great convention to apply.
192192
if (is_null($relation))
193193
{
194-
$caller = $this->getBelongsToManyCaller();
195-
196-
$name = $caller['function'];
194+
$relation = $this->getBelongsToManyCaller();
197195
}
198196

199197
// First, we'll need to determine the foreign key and "other key" for the

tests/RelationsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testWithBelongsTo()
6868
Item::create(array('type' => 'sword', 'user_id' => $user->_id));
6969
Item::create(array('type' => 'bag', 'user_id' => null));
7070

71-
$items = Item::with('user')->get();
71+
$items = Item::with('user')->orderBy('user_id', 'desc')->get();
7272

7373
$user = $items[0]->getRelation('user');
7474
$this->assertInstanceOf('User', $user);

0 commit comments

Comments
 (0)