add new metrics, graph metrics, prepare basket to storage
This commit is contained in:
43
app/Repositories/Shop/BasketStores.php
Normal file
43
app/Repositories/Shop/BasketStores.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Basket;
|
||||
use Darryldecode\Cart\CartCollection;
|
||||
|
||||
class BasketStores
|
||||
{
|
||||
public function has($key)
|
||||
{
|
||||
return Basket::find($key);
|
||||
}
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
if($this->has($key))
|
||||
{
|
||||
return new CartCollection(Basket::find($key)->cart_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function put($key, $value)
|
||||
{
|
||||
if($row = Basket::find($key))
|
||||
{
|
||||
// update
|
||||
$row->cart_data = $value;
|
||||
$row->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
Basket::create([
|
||||
'id' => $key,
|
||||
'cart_data' => $value
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user