mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-18 13:35:06 +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.
|
||||
*
|
||||
* @param \Closure $search
|
||||
* @return \Gloudemans\Shoppingcart\CartItem|\Illuminate\Support\Collection
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function search(Closure $search)
|
||||
{
|
||||
$content = $this->getContent();
|
||||
|
||||
$found = $content->filter($search);
|
||||
|
||||
if($found->count() === 1) return $found->first();
|
||||
|
||||
return $found;
|
||||
return $content->filter($search);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user