mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-23 07:31:31 +00:00
Added a search function
This commit is contained in:
@@ -211,7 +211,7 @@ class Cart {
|
||||
* @param Array $options Array of additional options, such as 'size' or 'color'
|
||||
* @return boolean
|
||||
*/
|
||||
protected function generateRowId($id, $options)
|
||||
public function generateRowId($id, $options)
|
||||
{
|
||||
return md5($id . serialize($options));
|
||||
}
|
||||
@@ -344,4 +344,16 @@ class Cart {
|
||||
return $this->updateRow($rowId, $attributes);
|
||||
}
|
||||
|
||||
public function search($search)
|
||||
{
|
||||
foreach($this->getContent() as $item)
|
||||
{
|
||||
$rowId = $this->generateRowId($search['id'], $search['options']);
|
||||
|
||||
if($rowId === $item->rowid) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user