mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-24 07:55:35 +00:00
Always return a Collection when searching
This commit is contained in:
@@ -285,17 +285,13 @@ class Cart
|
|||||||
* Search the cart content for a cart item matching the given search closure.
|
* Search the cart content for a cart item matching the given search closure.
|
||||||
*
|
*
|
||||||
* @param \Closure $search
|
* @param \Closure $search
|
||||||
* @return \Gloudemans\Shoppingcart\CartItem|\Illuminate\Support\Collection
|
* @return \Illuminate\Support\Collection
|
||||||
*/
|
*/
|
||||||
public function search(Closure $search)
|
public function search(Closure $search)
|
||||||
{
|
{
|
||||||
$content = $this->getContent();
|
$content = $this->getContent();
|
||||||
|
|
||||||
$found = $content->filter($search);
|
return $content->filter($search);
|
||||||
|
|
||||||
if($found->count() === 1) return $found->first();
|
|
||||||
|
|
||||||
return $found;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user