fix orders datatables on profile, fix deliveries for profile (public & active)
This commit is contained in:
@@ -5,16 +5,14 @@ namespace App\Repositories\Shop;
|
||||
use App\Datatables\Shop\CustomerOrdersDataTable;
|
||||
use App\Models\Shop\Customer;
|
||||
use App\Repositories\Core\File;
|
||||
use App\Traits\Model\Basic;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravolt\Avatar\Avatar;
|
||||
|
||||
class Customers
|
||||
{
|
||||
public static function count()
|
||||
{
|
||||
return Customer::count();
|
||||
}
|
||||
use Basic;
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
@@ -24,11 +22,11 @@ class Customers
|
||||
public static function editProfile($id = false)
|
||||
{
|
||||
$id = $id ? $id : self::getId();
|
||||
$orders_datatable = new CustomerOrdersDataTable();
|
||||
$datatableOrders = new CustomerOrdersDataTable();
|
||||
$data = [
|
||||
'customer' => self::get($id, ['addresses', 'deliveries', 'orders'])->toArray(),
|
||||
'deliveries' => Deliveries::getAll('sale_channel')->toArray(),
|
||||
'orders' => $orders_datatable->html(),
|
||||
'customer' => self::get($id, ['addresses', 'deliveries'])->toArray(),
|
||||
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
|
||||
'orders' => $datatableOrders->html(),
|
||||
];
|
||||
|
||||
return $data;
|
||||
@@ -111,13 +109,6 @@ class Customers
|
||||
return self::guard()->check();
|
||||
}
|
||||
|
||||
public static function get($id = false, $relations = false)
|
||||
{
|
||||
$id = $id ? $id : self::getId();
|
||||
|
||||
return $id ? ($relations ? Customer::with($relations)->findOrFail($id) : Customer::findOrFail($id)) : false;
|
||||
}
|
||||
|
||||
public static function edit($id)
|
||||
{
|
||||
$customer = self::get($id, 'addresses');
|
||||
@@ -140,11 +131,6 @@ class Customers
|
||||
return $customer->id;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
return ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
||||
}
|
||||
|
||||
public static function storeDeliveries($customer, $deliveries)
|
||||
{
|
||||
if (! $deliveries) {
|
||||
@@ -188,20 +174,6 @@ class Customers
|
||||
return $user;
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$customer = self::get($id);
|
||||
$customer->update($data);
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
public static function delete($id)
|
||||
{
|
||||
return Customer::destroy($id);
|
||||
}
|
||||
|
||||
public static function getStorage($filename = false)
|
||||
{
|
||||
$path = '/app/public/Customers/';
|
||||
@@ -220,4 +192,9 @@ class Customers
|
||||
{
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return Customer::query();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Delivery;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class Deliveries
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Delivery::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
|
||||
return Delivery::orderBy('name', 'asc')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll($relations = false)
|
||||
@@ -23,40 +26,13 @@ class Deliveries
|
||||
return Delivery::orderBy('name', 'asc')->active()->public()->with('sale_channel')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Delivery::find($id);
|
||||
}
|
||||
|
||||
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 Delivery::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 Delivery::destroy($id);
|
||||
}
|
||||
|
||||
public static function toggle_active($id, $active)
|
||||
{
|
||||
return self::update(['active' => $active], $id);
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return Delivery::query();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user