Skip to content

Commit

Permalink
[5.4] Check if Collection is empty and prevent exception on fresh met…
Browse files Browse the repository at this point in the history
…hod. (laravel#19671)

* Add fresh method on Eloquent/Collection.

* Rewrite completely the method to avoid multiple database calls.
Add full tests for Model::fresh() and Collection::fresh() methods.

* Update tests for php5.6 and Carbon v1.20.0

* Check if collection is empty and prevent exception.

* styleCI
  • Loading branch information
mathieutu authored and chrishardinge committed Jun 21, 2017
1 parent e306fdb commit dcbb61a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/Database/DatabaseEloquentCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ public function testQueueableCollectionImplementationThrowsExceptionOnMultipleMo
$c = new Collection([new TestEloquentCollectionModel, (object) ['id' => 'something']]);
$c->getQueueableClass();
}

public function testEmptyCollectionStayEmptyOnFresh()
{
$c = new Collection();
$this->assertEquals($c, $c->fresh());
}
}

class TestEloquentCollectionModel extends \Illuminate\Database\Eloquent\Model
Expand Down

0 comments on commit dcbb61a

Please sign in to comment.