fix shipping
This commit is contained in:
@@ -3,30 +3,18 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\CustomerAddress;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class CustomerAddresses
|
||||
{
|
||||
public static function getOptions()
|
||||
{
|
||||
return CustomerAddress::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
use Basic;
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return CustomerAddress::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return CustomerAddress::find($id);
|
||||
}
|
||||
|
||||
public static function add($user_id, $data)
|
||||
public static function add($userId, $data)
|
||||
{
|
||||
$name = $data['company'] ? $data['company'] : $data['first_name'].' '.$data['last_name'];
|
||||
if ($data['use_for_delivery'] ?? false) {
|
||||
return self::store([
|
||||
'customer_id' => $user_id,
|
||||
'customer_id' => $userId,
|
||||
'name' => $name,
|
||||
'address' => $data['delivery_address'],
|
||||
'address2' => $data['delivery_address2'],
|
||||
@@ -35,7 +23,7 @@ class CustomerAddresses
|
||||
]);
|
||||
} else {
|
||||
return self::store([
|
||||
'customer_id' => $user_id,
|
||||
'customer_id' => $userId,
|
||||
'name' => $name,
|
||||
'address' => $data['address'],
|
||||
'address2' => $data['address2'],
|
||||
@@ -45,35 +33,13 @@ class CustomerAddresses
|
||||
}
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = $data['id'] ?? false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return CustomerAddress::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$delivery = self::get($id);
|
||||
$delivery->update($data);
|
||||
|
||||
return $delivery;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return CustomerAddress::destroy($id);
|
||||
}
|
||||
|
||||
public static function toggle_active($id, $active)
|
||||
public static function toggleActive($id, $active)
|
||||
{
|
||||
return self::update(['active' => $active], $id);
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return CustomerAddress::query();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user