Skip to content

Commit

Permalink
Merge pull request #7 from ARCANEDEV/patch-1
Browse files Browse the repository at this point in the history
Fixing the Collection whereIn Method
  • Loading branch information
arcanedev-maroc authored Aug 9, 2016
2 parents b756cfb + 18e12e2 commit e02933d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
22 changes: 1 addition & 21 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,14 @@
*/
class Collection extends IlluminateCollection
{
/* ------------------------------------------------------------------------------------------------
| Illuminate Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Filter items by the given key value pair.
*
* @param string $key
* @param array $values
* @param bool $strict
*
* @return static
*/
public function whereIn($key, array $values, $strict = true)
{
return $this->filter(function ($item) use ($key, $values, $strict) {
return in_array(data_get($item, $key), $values, $strict);
});
}

/* ------------------------------------------------------------------------------------------------
| Custom Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Reset the collection.
*
* @return self
* @return static
*/
public function reset()
{
Expand Down
8 changes: 0 additions & 8 deletions tests/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ class CollectionTest extends TestCase
| Test Functions
| ------------------------------------------------------------------------------------------------
*/
/** @test */
public function it_can_use_where_in()
{
$c = new Collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]);

$this->assertEquals([['v' => 1], ['v' => 3]], $c->whereIn('v', [1, 3])->values()->all());
}

/** @test */
public function it_can_reset()
{
Expand Down

0 comments on commit e02933d

Please sign in to comment.