????ShippingTypeRepository.php000064400000002675150072630030012006 0ustar00shippingType->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->shippingType->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function update(string $id, array $data): bool { return $this->shippingType->where('id',$id)->update($data); } public function delete(array $params): bool { // TODO: Implement delete() method. } } OrderDetailRepository.php000064400000005720150072630030011553 0ustar00orderDetail->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->orderDetail->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->orderDetail ->with($relations) ->where($filters) ->when(isset($filters['id']), function ($query) use ($filters) { return $query->where('id', $filters['id']); }) ->when(isset($filters['order_id']), function ($query) use ($filters) { return $query->where('order_id', $filters['order_id']); }) ->when(isset($filters['product_id']), function ($query) use ($filters) { return $query->where('product_id', $filters['product_id']); }) ->when(isset($filters['seller_id']), function ($query) use ($filters) { return $query->where('seller_id', $filters['seller_id']); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->orderDetail->find($id)->update($data); } public function delete(array $params): bool { // TODO: Implement delete() method. } public function updateWhere(array $params, array $data): bool { return $this->orderDetail->where($params)->update($data); } public function getListWhereCount(string $searchValue = null, array $filters = [], array $relations = []): int { return $this->orderDetail->with($relations) ->when(isset($filters['product_id']), function ($query) use ($filters) { return $query->where(['product_id' => $filters['product_id']]); })->count(); } } NotificationRepository.php000064400000004667150072630030012014 0ustar00notification->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->notification->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->notification->with($relations) ->when(isset($filters['send_to']),function ($query)use($filters){ return $query->where('send_to',$filters['send_to']); }) ->when(isset($searchValue),function ($query)use($searchValue){ return $query->where('title', 'like', "%{$searchValue}%"); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getListWhereBetween(array $params = [], array $filters = [], array|string $relations = null, int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->notification->whereBetween('created_at',$params)->where($filters)->whereDoesntHave($relations)->get(); } public function update(string $id, array $data): bool { return $this->notification->find($id)->update($data); } public function delete(array $params): bool { return $this->notification->where($params)->delete(); } } CustomerRepository.php000064400000007406150072630030011161 0ustar00user->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->user->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->user->with($relations)->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->user->with($relations) ->when(empty($filters['withCount']),function ($query)use($filters){ return $query->where($filters); }) ->when($searchValue, function ($query) use ($searchValue) { $query->orWhere('f_name', 'like', "%$searchValue%") ->orWhere('l_name', 'like', "%$searchValue%") ->orWhere('phone', 'like', "%$searchValue%") ->orWhere('email', 'like', "%$searchValue%"); }) ->when(isset($filters['withCount']),function ($query)use($filters){ return $query->withCount($filters['withCount']); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends(['searchValue' => $searchValue]); } public function getListWhereNotIn(array $ids = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->user->whereNotIn('id', $ids)->get(); } public function update(string $id, array $data): bool { return $this->user->where('id', $id)->update($data); } public function delete(array $params): bool { $this->user->where($params)->delete(); return true; } public function getCustomerNameList(object $request, int|string $dataLimit = DEFAULT_DATA_LIMIT): object { $searchValue = explode(' ', $request['searchValue']); return $this->user->where('id','!=',0) ->where(function ($query) use ($searchValue) { foreach ($searchValue as $value) { $query->orWhere('f_name', 'like', "%$value%") ->orWhere('l_name', 'like', "%$value%") ->orWhere('phone', 'like', "%$value%"); } }) ->limit($dataLimit) ->get([DB::raw('id,IF(id <> "0", CONCAT(f_name, " ", l_name, " (", phone ,")"),CONCAT(f_name, " ", l_name)) as text')]); } public function deleteAuthAccessTokens(string|int $id): bool { DB::table('oauth_access_tokens')->where('user_id', $id)->delete(); return true; } } OfflinePaymentMethodRepository.php000064400000004554150072630030013442 0ustar00offlinePaymentMethod->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->offlinePaymentMethod->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->offlinePaymentMethod->with($relations) ->when(isset($filters['status']) && $filters['status'] == 'active' ,function ($query)use($filters){ return $query->where('status',1); }) ->when(isset($filters['status']) && $filters['status'] == 'inactive' ,function ($query)use($filters){ return $query->where('status',0); }) ->when(isset($searchValue),function ($query)use($searchValue){ return $query->where('method_name', 'like', "%{$searchValue}%"); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy),current($orderBy)); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->offlinePaymentMethod->find($id)->update($data); } public function delete(array $params): bool { return $this->offlinePaymentMethod->where($params)->delete(); } } OrderRepository.php000064400000066476150072630030010447 0ustar00order->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->order->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->order ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy), current($orderBy)); })->get(); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->order->with($relations) ->when(isset($filters['seller_is']) && $filters['seller_is'] != 'all', function ($query) use ($filters) { return $query->where('seller_is', $filters['seller_is']); }) ->when(isset($filters['seller_id']) && $filters['seller_id'] != 'all', function ($query) use ($filters) { return $query->where('seller_id', $filters['seller_id']); }) ->when(isset($filters['order_type']) && $filters['order_type'] != 'all', function ($query) use ($filters) { return $query->where('order_type', $filters['order_type']); }) ->when(isset($filters['order_status']) && $filters['order_status'] != 'all', function ($query) use ($filters) { return $query->where('order_status', $filters['order_status']); }) ->when(isset($filters['customer_id']) && $filters['customer_id'] != 'all', function ($query) use ($filters) { return $query->where('customer_id', $filters['customer_id']); }) ->when(isset($filters['is_guest']), function ($query) use ($filters) { return $query->where('is_guest', $filters['is_guest']); }) ->when(isset($filters['customer_type']), function ($query) use ($filters) { return $query->where('is_guest', $filters['customer_type']); }) ->when(isset($filters['coupon_code']), function ($query) use ($filters) { return $query->where('coupon_code', $filters['coupon_code']); }) ->when(isset($filters['checked']), function ($query) use ($filters) { return $query->where('checked', $filters['checked']); }) ->when(isset($filters['filter']), function ($query) use ($filters) { $query->when($filters['filter'] == 'all', function ($query) { return $query; }) ->when($filters['filter'] == 'POS', function ($query) { return $query->where('order_type', 'POS'); }) ->when($filters['filter'] == 'default_type', function ($query) { return $query->where('order_type', 'default_type'); }) ->when($filters['filter'] == 'admin' || $filters['filter'] == 'seller', function ($query) use ($filters) { return $query->whereHas('details', function ($query) use ($filters) { return $query->whereHas('product', function ($query) use ($filters) { return $query->where('added_by', $filters['filter']); }); }); }); }) ->when(isset($filters['date_type']) && $filters['date_type'] == "this_year", function ($query) { $current_start_year = date('Y-01-01'); $current_end_year = date('Y-12-31'); return $query->whereDate('created_at', '>=', $current_start_year) ->whereDate('created_at', '<=', $current_end_year); }) ->when(isset($filters['date_type']) && $filters['date_type'] == "this_month", function ($query) { $current_month_start = date('Y-m-01'); $current_month_end = date('Y-m-t'); return $query->whereDate('created_at', '>=', $current_month_start) ->whereDate('created_at', '<=', $current_month_end); }) ->when(isset($filters['date_type']) && $filters['date_type'] == "this_week", function ($query) { $start_week = Carbon::now()->subDays(7)->startOfWeek()->format('Y-m-d'); $end_week = Carbon::now()->startOfWeek()->format('Y-m-d'); return $query->whereDate('created_at', '>=', $start_week) ->whereDate('created_at', '<=', $end_week); }) ->when(isset($filters['date_type']) && $filters['date_type'] == "custom_date" && isset($filters['from']) && isset($filters['to']), function ($query) use ($filters) { return $query->whereDate('created_at', '>=', $filters['from']) ->whereDate('created_at', '<=', $filters['to']); }) ->when(isset($filters['delivery_man_id']), function ($query) use ($filters) { return $query->where(['delivery_man_id' => $filters['delivery_man_id']]); }) ->when($searchValue, function ($query) use ($searchValue) { return $query->where(function ($query) use ($searchValue) { return $query->where('id', 'like', "%{$searchValue}%") ->orWhere('order_status', 'like', "%{$searchValue}%") ->orWhere('transaction_ref', 'like', "%{$searchValue}%"); }); }) ->when(isset($filters['whereHas_deliveryMan']), function ($query) use($filters) { return $query->whereHas('deliveryMan', function($query) use ($filters){ $query->where('seller_id',$filters['whereHas_deliveryMan']); }); }) ->when(isset($filters['whereIn_order_status']) && $filters['whereIn_order_status'] != 'all', function ($query) use($filters) { $query->whereIn('order_status',$filters['whereIn_order_status']); }) ->when(isset($filters['whereIn_payment_status']) && $filters['whereIn_payment_status'] != 'all', function ($query) use($filters) { $query->whereIn('payment_status',$filters['whereIn_payment_status']); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getListWhereDate(array $filters = [], string $dateType = null, array $filterDate = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->order->with($relations) ->when($filters['order_status'], function ($query) use ($filters) { $query->where(['order_status' => $filters['order_status']]); }) ->when($filters['seller_is'] == 'seller', function ($query) use ($filters) { $query->where(['seller_is' => 'seller', 'seller_id' => $filters['seller_id']]); }) ->when($dateType == 'today', function ($query) use ($filterDate) { $query->whereDate('created_at', Carbon::today()); }) ->when($dateType == 'thisMonth', function ($query) use ($filterDate) { $query->whereMonth('created_at', Carbon::now()); }) ->get(); } public function getListWhereCount(string $searchValue = null, array $filters = [], array $relations = []): int { return $this->order->with($relations) ->when(isset($filters['customer_id']), function ($query) use ($filters) { return $query->where(['customer_id' => $filters['customer_id']]); })->count(); } public function getDeliveryManOrderListWhere(string $addedBy, string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->order->select('id', 'deliveryman_charge', 'order_status', 'delivery_man_id')->where($filters) ->whereHas('deliveryMan', function ($query) use ($addedBy) { $query->when($addedBy === 'seller', function ($subQuery) { $subQuery->where(['seller_id' => auth('seller')->id()]); }); }) ->when($searchValue, function ($query) use ($searchValue) { $query->where('id', 'like', "%$searchValue%"); }) ->latest() ->paginate($dataLimit) ->appends(['searchValue' => $searchValue]); } public function update(string $id, array $data): bool { return $this->order->where('id', $id)->update($data); } public function updateWhere(array $params, array $data): bool { return $this->order->where($params)->update($data); } public function delete(array $params): bool { $this->order->where($params)->delete(); return true; } public function getListWhereNotIn(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], array $nullFields = [], array $whereNotIn = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->order->where($filters) ->when(!empty($searchValue), function ($query) use ($searchValue) { $query->whereHas('order', function ($query) use ($searchValue) { $query->where('id', 'like', "%{$searchValue}%"); }); }) ->when(!empty($whereNotIn), function ($query) use ($whereNotIn) { foreach ($whereNotIn as $key => $whereNotInIndex) { $query->whereNotIn($key, $whereNotInIndex); } }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function updateAmountDate(object $request, string|int $userId, string $userType): bool { $fieldName = $request['field_name']; $fieldValues = $request['field_val']; $cause = $request['cause'] ?? null; if($fieldName == 'deliveryman_charge'){ $fieldValues = currencyConverter(amount: $fieldValues); } try { DB::beginTransaction(); if ($fieldName == 'expected_delivery_date') { $this->orderExpectedDeliveryHistory->create([ 'order_id' => $request['order_id'], 'user_id' => $userId, 'user_type' => $userType, 'expected_delivery_date' => $fieldValues, 'cause' => $cause ]); } $this->order->where(['id' => $request['order_id']])->update([$fieldName => $fieldValues]); DB::commit(); } catch (\Exception $ex) { DB::rollback(); return false; } return true; } public function updateStockOnOrderStatusChange(string|int $orderId, string $status): bool { $order = $this->order->with('details.product')->find($orderId); if ($status == 'returned' || $status == 'failed' || $status == 'canceled') { foreach ($order['details'] as $detail) { if ($detail['is_stock_decreased'] == 1) { $product = $detail->product; $type = $detail['variant']; $variations = []; if($product['variation']){ foreach (json_decode($product['variation'], true) as $variation) { if ($type == $variation['type']) { $variation['qty'] += $detail['qty']; } $variations[] = $variation; } } $this->product->where(['id' => $product['id']])->update([ 'variation' => json_encode($variations), 'current_stock' => $product['current_stock'] + $detail['qty'], ]); $this->orderDetail->where(['id' => $detail['id']])->update([ 'is_stock_decreased' => 0, 'delivery_status' => $status ]); } } } else { foreach ($order['details'] as $detail) { if ($detail['is_stock_decreased'] == 0) { $product = $detail->product; $type = $detail['variant']; $variations = []; foreach (json_decode($product['variation'], true) as $variation) { if ($type == $variation['type']) { $variation['qty'] -= $detail['qty']; } $variations[] = $variation; } $this->product->where(['id' => $product['id']])->update([ 'variation' => json_encode($variations), 'current_stock' => $product['current_stock'] - $detail['qty'], ]); $this->orderDetail->where(['id' => $detail['id']])->update([ 'is_stock_decreased' => 1, 'delivery_status' => $status ]); } } } return true; } public function manageWalletOnOrderStatusChange(object $order, string $receivedBy): bool { $order = $this->order->find($order['id']); $orderSummary = getOrderSummary(order: $order); $orderAmount = $orderSummary['subtotal'] - $orderSummary['total_discount_on_product'] - $order['discount_amount']; $commission = $order['admin_commission']; $shippingModel = $order->shipping_responsibility; $adminWallet = $this->adminWallet->where('admin_id', 1)->first(); if (!$adminWallet) { $adminWalletData = [ 'admin_id' => 1, 'withdrawn' => 0, 'commission_earned' => 0, 'inhouse_earning' => 0, 'delivery_charge_earned' => 0, 'pending_amount' => 0, 'created_at' => now(), 'updated_at' => now(), ]; $this->adminWallet->create($adminWalletData); } $sellerWallet = $this->sellerWallet->where('seller_id', $order['seller_id'])->first(); if (!$sellerWallet) { $sellerWalletData = [ 'seller_id' => $order['seller_id'], 'withdrawn' => 0, 'commission_given' => 0, 'total_earning' => 0, 'pending_withdraw' => 0, 'delivery_charge_earned' => 0, 'collected_cash' => 0, 'created_at' => now(), 'updated_at' => now(), ]; $this->sellerWallet->create($sellerWalletData); } // coupon transaction start if ($order['coupon_code'] && $order['coupon_code'] != '0' && $order['seller_is'] == 'seller' && $order['discount_type'] == 'coupon_discount') { if ($order['coupon_discount_bearer'] == 'inhouse') { $sellerWallet = $this->sellerWallet->where('seller_id', $order['seller_id'])->first(); $sellerWallet['total_earning'] += $order['discount_amount']; $sellerWallet->save(); $paidBy = 'admin'; $payerId = 1; $paymentReceiverId = $order['seller_id']; $paidTo = 'seller'; } elseif ($order->coupon_discount_bearer == 'seller') { $paidBy = 'seller'; $payerId = $order['seller_id']; $paymentReceiverId = $order['seller_id']; $paidTo = 'admin'; } $transaction = [ 'order_id' => $order->id, 'payment_for' => 'coupon_discount', 'payer_id' => $payerId, 'payment_receiver_id' => $paymentReceiverId, 'paid_by' => $paidBy, 'paid_to' => $paidTo, 'payment_status' => 'disburse', 'amount' => $order['discount_amount'], 'transaction_type' => 'expense', ]; $this->transaction->create($transaction); } // coupon transaction end // free delivery over amount transaction start if ($order['is_shipping_free'] && $order['seller_is'] == 'seller') { $sellerWallet = $this->sellerWallet->where('seller_id', $order['seller_id'])->first(); $adminWallet = $this->adminWallet->where('admin_id', 1)->first(); if ($order['free_delivery_bearer'] == 'admin' && $order['shipping_responsibility'] == 'sellerwise_shipping') { $sellerWallet->delivery_charge_earned += $order->extra_discount; $sellerWallet->total_earning += $order->extra_discount; $adminWallet->delivery_charge_earned -= $order->extra_discount; $adminWallet->inhouse_earning -= $order->extra_discount; $paidBy = 'admin'; $payerId = 1; $paymentReceiverId = $order->seller_id; $paidTo = 'seller'; } elseif ($order->free_delivery_bearer == 'seller' && $order->shipping_responsibility == 'inhouse_shipping') { $sellerWallet->delivery_charge_earned -= $order->extra_discount; $sellerWallet->total_earning -= $order->extra_discount; $adminWallet->delivery_charge_earned += $order->extra_discount; $adminWallet->inhouse_earning += $order->extra_discount; $paidBy = 'seller'; $payerId = $order->seller_id; $paymentReceiverId = $order->seller_id; $paidTo = 'admin'; }elseif ($order['free_delivery_bearer'] == 'admin' && $order['shipping_responsibility'] == 'inhouse_shipping') { $paidBy = 'admin'; $payerId = 1; $paymentReceiverId = $order->seller_id; $paidTo = 'admin'; }elseif ($order->free_delivery_bearer == 'seller' && $order->shipping_responsibility == 'sellerwise_shipping') { $paidBy = 'seller'; $payerId = $order->seller_id; $paymentReceiverId = $order->seller_id; $paidTo = 'seller'; } $sellerWallet->save(); $adminWallet->save(); $transaction = [ 'order_id' => $order->id, 'payment_for' => 'free_shipping_over_order_amount', 'payer_id' => $payerId, 'payment_receiver_id' => $paymentReceiverId, 'paid_by' => $paidBy, 'paid_to' => $paidTo, 'payment_status' => 'disburse', 'amount' => $order['discount_amount'], 'transaction_type' => 'expense', ]; $this->transaction->create($transaction); } // free delivery over amount transaction end if ($order['payment_method'] == 'cash_on_delivery' || $order['payment_method'] == 'offline_payment') { $transaction = [ 'transaction_id' => getUniqueId(), 'customer_id' => $order['customer_id'], 'seller_id' => $order['seller_id'], 'seller_is' => $order['seller_is'], 'order_id' => $order['id'], 'order_amount' => $orderAmount, 'seller_amount' => $orderAmount - $commission, 'admin_commission' => $commission, 'received_by' => $receivedBy, 'status' => 'disburse', 'delivery_charge' => $order['shipping_cost'] - ($order['is_shipping_free'] ? $order['extra_discount'] : 0), 'tax' => $orderSummary['total_tax'], 'delivered_by' => $receivedBy, 'payment_method' => $order['payment_method'], 'created_at' => now(), 'updated_at' => now(), ]; $this->orderTransaction->create($transaction); $wallet = $this->adminWallet->where('admin_id', 1)->first(); $wallet->commission_earned += $commission; ($shippingModel == 'inhouse_shipping' && !$order['is_shipping_free']) ? $wallet->delivery_charge_earned += $order['shipping_cost'] : null; $wallet->save(); if ($order['seller_is'] == 'admin') { $wallet = $this->adminWallet->where('admin_id', 1)->first(); $wallet->inhouse_earning += $orderAmount; ($shippingModel == 'sellerwise_shipping' && !$order['is_shipping_free']) ? $wallet->delivery_charge_earned += $order['shipping_cost'] : null; $wallet->total_tax_collected += $orderSummary['total_tax']; $wallet->save(); } else { $wallet = $this->sellerWallet->where('seller_id', $order['seller_id'])->first(); $wallet->commission_given += $commission; $wallet->total_tax_collected += $orderSummary['total_tax']; if ($shippingModel == 'sellerwise_shipping') { !$order['is_shipping_free'] ? $wallet->delivery_charge_earned += $order['shipping_cost'] : null; $wallet->collected_cash += $order['order_amount']; //total order amount } else { $wallet->total_earning += ($orderAmount - $commission) + $orderSummary['total_tax']; } $wallet->save(); } } else { $transaction = $this->orderTransaction->where(['order_id' => $order['id']])->first(); $transaction->status = 'disburse'; $transaction->save(); $wallet = $this->adminWallet->where('admin_id', 1)->first(); $wallet->commission_earned += $commission; $wallet->pending_amount -= $order['order_amount']; ($shippingModel == 'inhouse_shipping' && !$order['is_shipping_free']) ? $wallet->delivery_charge_earned += $order['shipping_cost'] : null; $wallet->save(); if ($order['seller_is'] == 'admin') { $wallet = $this->adminWallet->where('admin_id', 1)->first(); $wallet->inhouse_earning += $orderAmount; ($shippingModel == 'sellerwise_shipping' && !$order['is_shipping_free']) ? $wallet->delivery_charge_earned += $order['shipping_cost'] : null; $wallet->total_tax_collected += $orderSummary['total_tax']; $wallet->save(); } else { $wallet = $this->sellerWallet->where('seller_id', $order['seller_id'])->first(); $wallet->commission_given += $commission; if ($shippingModel == 'sellerwise_shipping') { !$order['is_shipping_free'] ? $wallet->delivery_charge_earned += $order['shipping_cost'] : null; $wallet->total_earning += ($orderAmount - $commission) + $orderSummary['total_tax'] + $order['shipping_cost']; } else { $wallet->total_earning += ($orderAmount - $commission) + $orderSummary['total_tax']; } $wallet->total_tax_collected += $orderSummary['total_tax']; $wallet->save(); } } return true; } public function getListWhereBetween(array $filters = [], string $selectColumn = null, string $whereBetween = null, array $whereBetweenFilters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->order->with($relations)->where($filters) ->when($selectColumn == 'order_amount', function ($query) { $query->select( DB::raw('IFNULL(sum(order_amount),0) as sums'), DB::raw('YEAR(created_at) year, MONTH(created_at) month,DAY(created_at) day,DAYNAME(created_at) day_of_week') ); }) ->whereBetween($whereBetween, $whereBetweenFilters) ->groupby('year', 'month','day_of_week') ->get(); } public function getTopCustomerList(array $filters = [] ,array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->order ->with($relations) ->where($filters) ->select('customer_id', DB::raw('COUNT(customer_id) as count')) ->whereHas('customer', function ($query) { $query->where('id', '!=', 0); }) ->groupBy('customer_id') ->orderBy("count", 'desc'); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getTopVendorListByOrderReceived(array $filters = [] ,array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->order ->with($relations) ->whereHas('seller', function ($query) { return $query; }) ->where('seller_is', 'seller') ->select('seller_id', DB::raw('COUNT(id) as count')) ->groupBy('seller_id') ->orderBy("count", 'desc'); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } } ProductCompareRepository.php000064400000005050150072630030012300 0ustar00productCompare->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->productCompare->with($relations)->where($params)->first(); } public function getCount(array $params): int|null { return $this->productCompare->when(isset($params['product_id']), function ($query) use($params){ return $query->where('product_id', $params['product_id']); })->when(isset($params['customer_id']), function ($query) use($params){ return $query->where('user_id', $params['customer_id']); })->count(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->productCompare->with($relations) ->when(isset($filters['user_id']), function ($query) use ($filters) { return $query->where('user_id', $filters['user_id']); }) ->when(isset($filters['whereHas']), function ($query) use ($filters) { return $query->whereHas($filters['whereHas']); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy), current($orderBy)); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->productCompare->where(['id'=>$id])->update($data); } public function delete(array $params): bool { $this->productCompare->where($params)->delete(); return true; } } EmergencyContactRepository.php000064400000003316150072630030012606 0ustar00emergencyContact->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->emergencyContact->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->emergencyContact->where($filters)->latest()->paginate($dataLimit); } public function update(string $id, array $data): bool { return $this->emergencyContact->find($id)->update($data); } public function updateWhere(array $params, array $data): bool { $this->emergencyContact->where($params)->update($data); return true; } public function delete(array $params): bool { return $this->emergencyContact->where($params)->delete(); } } AdminWalletRepository.php000064400000004327150072630030011560 0ustar00adminWallet->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->adminWallet->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->adminWallet->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->adminWallet ->when($filters['admin_id'], function($query)use($filters){ $query->where('admin_id', $filters['admin_id']); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->adminWallet->where('id', $id)->update($data); } public function updateWhere(array $params, array $data): bool { $this->adminWallet->where($params)->update($data); return true; } public function delete(array $params): bool { $this->adminWallet->where($params)->delete(); return true; } } WishlistRepository.php000064400000005500150072630030011157 0ustar00wishlist->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->wishlist->where($params)->first(); } public function getCount(array $params): int|null { return $this->wishlist->when(isset($params['product_id']), function ($query) use($params){ return $query->where('product_id', $params['product_id']); })->when(isset($params['customer_id']), function ($query) use($params){ return $query->where('customer_id', $params['customer_id']); })->count(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { } public function getListWhere(array $orderBy=[], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->wishlist->whereIn('seller_id', [auth('seller')->id(), '0']) ->when(!empty($searchValue), function ($query) use ($searchValue) { $key = explode(' ', $searchValue); foreach ($key as $value) { $query->where('title', 'like', "%{$value}%") ->orWhere('code', 'like', "%{$value}%") ->orWhere('discount_type', 'like', "%{$value}%"); } }) ->withCount('order')->latest()->paginate($dataLimit)->appends($filters); } public function getListWhereCount(string $searchValue = null, array $filters = [], array $relations = []): int { return $this->wishlist->with($relations) ->when(isset($filters['product_id']), function ($query) use ($filters) { return $query->where(['product_id' => $filters['product_id']]); })->when(isset($filters['customer_id']), function ($query) use ($filters) { return $query->where(['customer_id' => $filters['customer_id']]); })->count(); } public function update(string $id, array $data): bool { return $this->wishlist->where('id', $id)->update($data); } public function delete(array $params): bool { return $this->wishlist->where($params)->delete(); } } RefundStatusRepository.php000064400000002634150072630030012005 0ustar00refundStatus->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { // TODO: Implement getFirstWhere() method. } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { // TODO: Implement delete() method. } } SupportTicketRepository.php000064400000005767150072630030012210 0ustar00supportTicket->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->supportTicket->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->supportTicket->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->supportTicket ->with($relations) ->when($searchValue, function ($query) use($searchValue){ return $query->Where('subject', 'like', "%{$searchValue}%") ->orWhere('type', 'like', "%{$searchValue}%") ->orWhere('description', 'like', "%{$searchValue}%") ->orWhere('status', 'like', "%{$searchValue}%"); }) ->when(isset($filters['id']), function ($query) use ($filters) { $query->where('id', $filters['id']); }) ->when(isset($filters['priority']) && $filters['priority'] != 'all', function ($query) use ($filters) { $query->where('priority', $filters['priority']); }) ->when(isset($filters['status']) && $filters['status'] != 'all', function ($query) use ($filters) { $query->where('status', $filters['status']); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->supportTicket->where('id', $id)->update($data); } public function delete(array $params): bool { $this->supportTicket->where($params)->delete(); return true; } } CurrencyRepository.php000064400000004723150072630030011151 0ustar00currency->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->currency->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->currency ->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere( array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->currency ->when($searchValue, function ($query) use ($searchValue) { return $query->where('name', 'like', "%$searchValue%"); }) ->when($filters && $filters['status'], function ($query) use ($filters) { return $query->where(['status'=>$filters['status']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->currency->where('id', $id)->update($data); } public function delete(array $params): bool { $this->currency->where($params)->delete(); return true; } } LoyaltyPointTransactionRepository.php000064400000013212150072630030014225 0ustar00loyaltyPointTransaction->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { // TODO: Implement getFirstWhere() method. } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->loyaltyPointTransaction ->when((isset($filters['from']) && isset($filters['to'])), function ($query) use ($filters) { $query->whereBetween('created_at', [$filters['from'] . ' 00:00:00', $filters['to'] . ' 23:59:59']); }) ->when(isset($filters['transaction_id']), function ($query) use ($filters) { $query->where('transaction_id', $filters['transaction_id']); }) ->when(isset($filters['transaction_type']) && $filters['transaction_type'] != 'all', function ($query) use ($filters) { $query->where('transaction_type', $filters['transaction_type']); }) ->when(isset($filters['customer_id']) && $filters['customer_id'] != 'all', function ($query) use ($filters) { $query->where('user_id', $filters['customer_id']); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends(['searchValue' => $searchValue]); } public function getListWhereSelect(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->loyaltyPointTransaction->selectRaw('sum(credit) as total_credit, sum(debit) as total_debit') ->when(($filters['from'] && $filters['to']), function ($query) use ($filters) { $query->whereBetween('created_at', [$filters['from'] . ' 00:00:00', $filters['to'] . ' 23:59:59']); }) ->when($filters['transaction_type'], function ($query) use ($filters) { $query->where('transaction_type', $filters['transaction_type']); }) ->when(isset($filters['customer_id']) && $filters['customer_id'] != 'all', function ($query) use ($filters) { $query->where('user_id', $filters['customer_id']); })->latest(); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends(['searchValue' => $searchValue]); } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { $this->loyaltyPointTransaction->where($params)->delete(); return true; } public function addLoyaltyPointTransaction(string|int $userId, string $reference, string|int|float $amount, string $transactionType): bool { $settings = array_column($this->businessSetting->whereIn('type', ['loyalty_point_status', 'loyalty_point_exchange_rate', 'loyalty_point_item_purchase_point'])->get()->toArray(), 'value', 'type'); if ($settings['loyalty_point_status'] != 1) { return true; } $credit = 0; $debit = 0; $user = $this->user->find($userId); if ($transactionType == 'order_place') { $credit = (int)($amount * $settings['loyalty_point_item_purchase_point'] / 100); } else if ($transactionType == 'point_to_wallet') { $debit = $amount; } else if ($transactionType == 'refund_order') { $debit = $amount; } $currentBalance = $user['loyalty_point'] + $credit - $debit; $loyaltyPointTransaction = [ 'user_id' => $user['id'], 'transaction_id' => Str::uuid(), 'transaction_type' => $transactionType, 'reference' => $reference, 'balance' => $currentBalance, 'credit' => $credit, 'debit' => $debit, 'created_at' => now(), 'updated_at' => now(), ]; try { DB::beginTransaction(); $user->loyalty_point = $currentBalance; $user->save(); $this->loyaltyPointTransaction->create($loyaltyPointTransaction); DB::commit(); return true; } catch (Exception $ex) { info($ex); DB::rollback(); } return false; } } ReviewRepository.php000064400000023541150072630030010617 0ustar00review->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->review->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->review->with($relations)->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->review->with($relations) ->when(!empty($searchValue), function ($query) use ($searchValue) { $query->whereHas('order', function ($query) use ($searchValue) { $query->where('id', 'like', "%{$searchValue}%"); }); }) ->when(isset($filters['from']) && isset($filters['to']), function ($query) use ($filters) { $query->whereBetween('created_at', [$filters['from'] . ' 00:00:00', $filters['to'] . ' 23:59:59']); }) ->when(isset($filters['rating']), function ($query) use ($filters) { $query->where(['rating'=>$filters['rating']]); }) ->when(isset($filters['delivery_man_id']), function ($query) use ($filters) { $query->where(['delivery_man_id'=>$filters['delivery_man_id']]); }) ->when(isset($filters['whereNull']), function ($query) use ($filters) { $query->whereNull($filters['whereNull']['column']); }) ->when(isset($filters['product_id']) && $filters['product_id'] != 0, function ($query) use ($filters) { $query->where(['product_id'=>$filters['product_id']]); }) ->when(isset($filters['customer_id']) && $filters['customer_id'] != 'all', function ($query) use ($filters) { $query->where(['customer_id'=>$filters['customer_id']]); }) ->when(isset($filters['status']), function ($query) use ($filters) { $query->where(['status'=>$filters['status']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends(['searchValue' => $searchValue]); } public function getListWhereIn(bool $globalScope = true, array $orderBy = [], string $searchValue = null, array $filters = [], array $whereInFilters = [], array $relations = [], array $nullFields = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->review->with($relations) ->when(!empty($searchValue), function ($query) use ($searchValue) { $query->whereHas('order', function ($query) use ($searchValue) { $query->where('id', 'like', "%{$searchValue}%"); }); }) ->when(isset($filters['added_by']) && $filters['added_by'] == 'seller',function ($query)use($filters){ return $query->whereHas('product',function ($query)use($filters){ return $query->where('added_by',$filters['added_by']); }); }) ->when(!$globalScope,function ($query){ $query->withoutGlobalScopes(); }) ->when(!empty($whereInFilters['product_id']) && $whereInFilters['product_id'] != 0, function ($query) use ($whereInFilters) { $query->whereIn('product_id', $whereInFilters['product_id']); })->when(!empty($whereInFilters['customer_id']) && $whereInFilters['customer_id'] != 0, function ($query) use ($whereInFilters) { $query->whereIn('customer_id', $whereInFilters['customer_id']); }) ->when((isset($whereInFilters['product_id'])&& empty($whereInFilters['product_id']))&& (isset($whereInFilters['customer_id']) && empty($whereInFilters['customer_id'])), function ($query) use ($whereInFilters) { $query->where('id', null); }) ->when(isset($filters['from']) && isset($filters['to']), function ($query) use ($filters) { $query->whereBetween('created_at', [$filters['from'] . ' 00:00:00', $filters['to'] . ' 23:59:59']); }) ->when(isset($filters['product_id']) && $filters['product_id'] != 0, function ($query) use ($filters) { $query->where('product_id', $filters['product_id']); }) ->when(isset($filters['customer_id']) && $filters['customer_id'] != 'all', function ($query) use ($filters) { $query->where('customer_id', $filters['customer_id']); }) ->when(isset($filters['product_user_id']) && $filters['product_user_id'] != '0', function ($query) use ($filters) { $query->whereHas('product', function ($query) use ($filters) { $query->where('user_id', $filters['product_user_id'])->where('added_by', 'seller'); }); }) ->when(isset($filters['status']), function ($query) use ($filters) { $query->where('status', $filters['status']); }) ->when(!empty($nullFields), function ($query) use ($nullFields) { $query->whereNull($nullFields); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getListWhereHas(bool $globalScope = true, string $whereHas, array $whereHasFilter = [] , array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], array $nullFields = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->review->with($relations)->whereHas($whereHas, function ($query) use ($whereHasFilter) { $query->where($whereHasFilter); }) ->when(!$globalScope,function ($query){ $query->withoutGlobalScopes(); }) ->when(!empty($searchValue), function ($query) use ($searchValue) { $query->whereHas('order', function ($query) use ($searchValue) { $query->where('id', 'like', "%{$searchValue}%"); }); }) ->when(isset($filters['from']) && isset($filters['to']), function ($query) use ($filters) { $query->whereBetween('created_at', [$filters['from'] . ' 00:00:00', $filters['to'] . ' 23:59:59']); }) ->when(isset($filters['product_id']) && $filters['product_id'] != 0, function ($query) use ($filters) { $query->where('product_id', $filters['product_id']); }) ->when(isset($filters['customer_id']) && $filters['customer_id'] != 'all', function ($query) use ($filters) { $query->where('customer_id', $filters['customer_id']); }) ->when(isset($filters['status']), function ($query) use ($filters) { $query->where('status', $filters['status']); }) ->when(!empty($nullFields), function ($query) use ($nullFields) { $query->whereNull($nullFields); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getCount(array $params=[], array $whereInFilters=[]): int|null { return $this->review->when(!empty($whereInFilters), function ($query) use ($whereInFilters) { foreach ($whereInFilters as $key => $filterIndex){ $query->orWhereIn($key , $filterIndex); } })->count(); } public function update(string $id, array $data): bool { return $this->review->find($id)->update($data); } public function updateWhere(array $params, array $data): bool { $this->review->where($params)->update($data); return true; } public function updateOrInsert(array $params, array $data): bool { $this->review->updateOrInsert($params, $data); return true; } public function delete(array $params): bool { $this->review->where($params)->delete(); return true; } } AddFundBonusCategoriesRepository.php000064400000004564150072630030013704 0ustar00addFundBonusCategories->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->addFundBonusCategories->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->addFundBonusCategories->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->addFundBonusCategories->where($filters)->with($relations) ->when($searchValue, function ($query) use($searchValue){ $query->where('title', 'like', "%$searchValue%"); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->addFundBonusCategories->where('id', $id)->update($data); } public function delete(array $params): bool { $this->addFundBonusCategories->where($params)->delete(); return true; } } AdminRoleRepository.php000064400000006310150072630030011223 0ustar00adminRole->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->adminRole->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->adminRole->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->adminRole ->when($searchValue, function ($query) use($searchValue){ $query->where('name', 'like', "%$searchValue%"); }) ->when(isset($filters['admin_role_id']) && $filters['admin_role_id'] != 'all', function($query)use ($filters){ $query->where('admin_role_id', $filters['admin_role_id']); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->adminRole->where('id', $id)->update($data); } public function delete(array $params): bool { $this->adminRole->where($params)->delete(); return true; } public function getEmployeeRoleList( array $orderBy = [], string $searchValue = null, array $filters = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null ): Collection|LengthAwarePaginator { $query = $this->adminRole->whereNotIn('id', [1]) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); })->when($searchValue, function ($query) use($searchValue){ $query->where('name', 'like', "%$searchValue%"); }) ->when(isset($filters['admin_role_id']) && $filters['admin_role_id'] != 'all', function($query)use ($filters){ $query->where('admin_role_id', $filters['admin_role_id']); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } } WithdrawalMethodRepository.php000064400000005133150072630030012622 0ustar00withdrawalMethod->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->withdrawalMethod->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->withdrawalMethod->with($relations)->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->withdrawalMethod->where($filters)->with($relations) ->when($searchValue, function ($query) use($searchValue){ $query->where('method_name', 'LIKE', "%$searchValue%"); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { $this->withdrawalMethod->where(['id'=>$id])->update($data); return true; } public function updateWhereNotIn(array $params, array $data): bool { $this->withdrawalMethod->where(function ($query) use ($params) { foreach ($params as $column => $value) { $query->whereNotIn($column, [$value]); } })->update($data); return true; } public function delete(array $params): bool { $this->withdrawalMethod->where($params)->delete(); return true; } } MostDemandedRepository.php000064400000005201150072630030011713 0ustar00mostDemanded->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->mostDemanded->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->mostDemanded->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->mostDemanded->with($relations) ->when($searchValue, function ($query) use ($searchValue) { return $query->whereHas('product', function ($query) use ($searchValue) { return $query->where('name', 'like', "%$searchValue%"); }); })->when(isset($filters['status']), function ($query) use ($filters) { return $query->where(['status' => $filters['status']]); })->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { $this->mostDemanded->where('id', $id)->update($data); return true; } public function updateWhere(array $params, array $data): bool { $this->mostDemanded->where($params)->update($data); return true; } public function delete(array $params): bool { $this->mostDemanded->where($params)->delete(); return true; } } DeliveryManWalletRepository.php000064400000003334150072630030012744 0ustar00deliveryManWallet->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->deliveryManWallet->where($params)->first(); } public function getList(array $orderBy=[] ,array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [],string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function update(string $id, array $data): bool { return $this->deliveryManWallet->where('id', $id)->update($data); } public function delete(array $params): bool { $this->deliveryManWallet->where($params)->delete(); return true; } public function updateWhere(array $params, array $data): bool { return $this->deliveryManWallet->where($params)->update($data); } } BrandRepository.php000064400000005254150072630030010405 0ustar00brand->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->brand->withoutGlobalScope('translate')->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->brand->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy=[], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->brand ->withCount('brandAllProducts')->with(['brandAllProducts'=> function($query){ $query->withCount('orderDetails'); }])->when($searchValue, function ($query) use($searchValue){ $query->Where('name', 'like', "%$searchValue%")->orWhere('id', $searchValue); }) ->when(isset($filters['name']), function ($query) use($filters) { return $query->where(['name' => $filters['name']]); }) ->when(isset($filters['status']), function ($query) use($filters) { return $query->where(['status' => $filters['status']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->brand->where('id', $id)->update($data); } public function delete(array $params): bool { $this->brand->where($params)->delete(); return true; } } TranslationRepository.php000064400000004665150072630030011662 0ustar00lang as $index => $key) { foreach (['name','description','title'] as $type){ if (isset($request[$type][$index]) && $key != 'en') { $this->translation->insert( [ 'translationable_type' => $model, 'translationable_id' => $id, 'locale' => $key, 'key' => $type, 'value' => $request[$type][$index] ] ); } } } return true; } public function update(object $request, string $model, int|string $id): bool { foreach ($request->lang as $index => $key) { foreach (['name','description','title'] as $type){ if (isset($request[$type][$index]) && $key != 'en') { $this->translation->updateOrInsert( [ 'translationable_type' => $model, 'translationable_id' => $id, 'locale' => $key, 'key' => $type ], [ 'value' => $request[$type][$index] ] ); } } } return true; } public function updateData(string $model, string $id, string $lang, string $key, string $value):bool { $this->translation->updateOrInsert( [ 'translationable_type' => $model, 'translationable_id' => $id, 'locale' => $lang, 'key' => $key ], [ 'value' => $value ] ); return true; } public function delete(string $model, int|string $id): bool { $this->translation->where('translationable_type',$model)->where('translationable_id',$id)->delete(); return true; } } RefundTransactionRepository.php000064400000011016150072630030013001 0ustar00refundTransaction->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->refundTransaction->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->refundTransaction->with($relations) ->when(isset($filters['payment_method']),function ($query)use($filters){ return $query->where('payment_method',$filters['payment_method']); }) ->when(isset($searchValue),function ($query)use($searchValue){ $key = explode(' ', $searchValue); foreach ($key as $value) { return $query->orWhere('order_id', 'like', "%{$value}%") ->orWhere('refund_id', 'like', "%{$value}%"); } }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy),current($orderBy)); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getListWhereHas(array $orderBy = [], string $searchValue = null, array $filters = [], string $whereHas = null, array $whereHasFilters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->refundTransaction->whereHas($whereHas, function ($query) use ($whereHasFilters) { return $query->when(isset($whereHasFilters['seller_is']) && $whereHasFilters['seller_is'] == 'admin', function ($query) use ($whereHasFilters) { return $query->where(['seller_is' => $whereHasFilters['seller_is']]); })->when(isset($whereHasFilters['seller_is']) && $whereHasFilters['seller_is'] == 'seller', function ($query) use ($whereHasFilters) { return $query->where(['seller_is' => $whereHasFilters['seller_is']]); }); }) ->when(isset($searchValue), function ($query) use ($searchValue) { $key = explode(' ', $searchValue); $query->where(function ($subQuery) use ($key) { foreach ($key as $value) { $subQuery->orWhere('order_id', 'like', "%{$value}%") ->orWhere('id', 'like', "%{$value}%"); } }); }) ->when(isset($filters['status']), function ($query) use ($filters) { $query->where(['status' => $filters['status']]); }) ->orderBy(key($orderBy), current($orderBy)); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getFirstWhereHas(array $params, string $whereHas = null, array $whereHasFilters = [], array $relations = []): ?Model { return $this->refundTransaction->whereHas($whereHas, function ($query) use ($whereHasFilters) { $query->where($whereHasFilters); })->where($params)->first(); } public function update(string $id, array $data): bool { return $this->refundTransaction->find($id)->update($data); } public function updateWhere(array $params, array $data): bool { $this->refundTransaction->where($params)->update($data); return true; } public function delete(array $params): bool { // TODO: Implement delete() method. } } DeliveryCountryCodeRepository.php000064400000005077150072630030013324 0ustar00deliveryCountryCode->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->deliveryCountryCode->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->deliveryCountryCode->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->deliveryCountryCode ->with($relations) ->when($searchValue, function ($query) use ($searchValue) { $query->orWhere('country_code', 'like', "%$searchValue%"); }) ->when(isset($filters['country_code']), function ($query) use ($filters) { return $query->where(['country_code' => $filters['country_code']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { $this->deliveryCountryCode->where('id', $id)->update($data); return true; } public function delete(array $params): bool { return $this->deliveryCountryCode->where($params)->delete(); } } CartRepository.php000064400000003540150072630030010244 0ustar00cart->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->cart->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { } public function getListWhere(array $orderBy=[], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->cart->whereIn('seller_id', [auth('seller')->id(), '0']) ->when(!empty($searchValue), function ($query) use ($searchValue) { $key = explode(' ', $searchValue); foreach ($key as $value) { $query->where('title', 'like', "%{$value}%") ->orWhere('code', 'like', "%{$value}%") ->orWhere('discount_type', 'like', "%{$value}%"); } }) ->withCount('order')->latest()->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->cart->where('id', $id)->update($data); } public function delete(array $params): bool { return $this->cart->where($params)->delete(); } } ProductTagRepository.php000064400000003337150072630030011433 0ustar00productTag->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { // TODO: Implement getFirstWhere() method. } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { // TODO: Implement delete() method. } public function getIds(string $fieldName = 'tag_id', array $filters = []): \Illuminate\Support\Collection|array { return $this->productTag->when(isset($filters['product_id']), function ($query) use ($filters) { return $query->where('product_id', $filters['product_id']); })->pluck($fieldName); } } CategoryRepository.php000064400000007352150072630030011135 0ustar00category->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->category->where($params)->with($relations)->withoutGlobalScopes()->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->category->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->category->with($relations) ->where($filters) ->when(isset($searchValue), function ($query) use ($searchValue) { $translation_ids = $this->translation->where('translationable_type', 'App\Models\Category') ->where('key', 'name') ->where(function ($q) use ($searchValue) { $q->orWhere('value', 'like', "%$searchValue%"); })->pluck('translationable_id'); $query->where('name', 'like', "%$searchValue%")->orWhereIn('id', $translation_ids); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->category->where('id', $id)->update($data); } public function delete(array $params): bool { $categories = $this->category->where(['id'=>$params['id']])->with(['childes.childes'])->get(); foreach ($categories as $category) { if ($category->childes){ foreach ($category->childes as $child) { if ($child->childes) { foreach ($child->childes as $item) { $this->translation->where('translationable_type', 'App\Models\Category')->where('translationable_id', $item['id'])->delete(); $this->category->where('id', $item['id'])->delete(); } } $this->translation->where('translationable_type', 'App\Models\Category')->where('translationable_id', $child['id'])->delete(); $this->category->where('id', $child['id'])->delete(); } } } $this->translation->where('translationable_type', 'App\Models\Category')->where('translationable_id', $params['id'])->delete(); $this->category->where('id', $params['id'])->delete(); return true; } } SupportTicketConvRepository.php000064400000003415150072630030013022 0ustar00supportTicketConv->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->supportTicketConv->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->supportTicketConv->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { } public function update(string $id, array $data): bool { return $this->supportTicketConv->where('id', $id)->update($data); } public function delete(array $params): bool { $this->supportTicketConv->where($params)->delete(); return true; } } ShopRepository.php000064400000004216150072630030010265 0ustar00shop->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->shop->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function update(string $id, array $data): bool { return $this->shop->find($id)->update($data); } public function delete(array $params): bool { // TODO: Implement delete() method. } public function getListWithScope(array $orderBy = [], string $searchValue = null, string $scope = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->shop->with($relations) ->when(isset($scope) && $scope == 'active', function ($query){ $query->active(); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } } PasswordResetRepository.php000064400000002740150072630030012161 0ustar00passwordReset->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->passwordReset->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { $this->passwordReset->where($params)->delete(); return true; } } SettingRepository.php000064400000010144150072630030010766 0ustar00setting->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->setting->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->setting ->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere( array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->setting ->when($searchValue, function ($query) use ($searchValue) { return $query->where('key_name', 'like', "%$searchValue%"); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getListWhereIn(array $orderBy = [], string $searchValue = null, array $filters = [], array $whereInFilters = [], array $relations = [], array $nullFields = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->setting ->with($relations) ->when($searchValue, function ($query) use($searchValue){ return $query->where('key_name', 'like', "%$searchValue%"); }) ->when(isset($filters['id']) , function ($query) use ($filters){ return $query->where(['id' => $filters['id']]); }) ->when(isset($filters['key_name']) , function ($query) use ($filters){ return $query->where(['key_name' => $filters['key_name']]); }) ->when(!empty($whereInFilters), function ($query) use ($whereInFilters) { foreach ($whereInFilters as $key => $filterIndex){ $query->whereIn($key , $filterIndex); } }) ->when(!empty($nullFields), function ($query) use ($nullFields) { return $query->whereNull($nullFields); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->setting->where('id', $id)->update($data); } public function updateWhere(array $params, array $data): bool { return $this->setting->where($params)->update($data); } public function updateOrInsert(array $params, array $data): bool { $this->setting->updateOrInsert($params, $data); return true; } public function delete(array $params): bool { $this->setting->where($params)->delete(); return true; } } DeliveryManTransactionRepository.php000064400000004470150072630030014003 0ustar00deliveryManTransaction->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->deliveryManTransaction->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->deliveryManTransaction->with($relations) ->when($searchValue, function ($query)use($searchValue){ $query->orWhere('f_name', 'like', "%$searchValue%") ->orWhere('l_name', 'like', "%$searchValue%") ->orWhere('phone', 'like', "%$searchValue%"); }) ->when(isset($filters['delivery_man_id']), function($query) use($filters){ return $query->where(['delivery_man_id' => $filters['delivery_man_id']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { // TODO: Implement delete() method. } } NotificationSeenRepository.php000064400000002716150072630030012620 0ustar00notificationSeen->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function update(string $id, array $data): bool { return $this->notificationSeen->find($id)->update($data); } public function delete(array $params): bool { // TODO: Implement delete() method. } } NotificationMessageRepository.php000064400000002776150072630030013320 0ustar00notificationMessage->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { // TODO: Implement getFirstWhere() method. } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->notificationMessage->with($relations)->where($filters)->get(); } public function update(string $id, array $data): bool { return $this->notificationMessage->where(['id'=>$id])->update($data); } public function delete(array $params): bool { return $this->notificationMessage->where($params)->delete(); } } SellerRepository.php000064400000006042150072630030010601 0ustar00seller->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { // TODO: Implement getFirstWhere() method. } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { // TODO: Implement delete() method. } public function getListWithScope(array $orderBy = [], string $searchValue = null, string $scope = null, array $filters = [], array $whereIn = [], array $whereNotIn = [], array $relations = [], array $withCount = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->seller->with($relations) ->when(isset($withCount['product']), function ($query) use ($withCount) { return $query->withCount($withCount['product']); }) ->when(isset($relations['shop']), function ($query) use($relations){ return $query->with($relations['shop']); })->when(isset($relations['product.reviews']), function ($query) use($relations){ return $query->with($relations['product.reviews']); }) ->when(isset($withCount['product']), function ($query) use ($withCount) { return $query->withCount([$withCount['product'] => function ($query) { return $query->active(); }]); }) ->when(isset($scope) && $scope == 'active', function ($query) { return $query->approved(); })->when(isset($filters['brand_id']), function ($query) use ($filters) { return $query->where(['brand_id' => $filters['brand_id']]); })->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } } ShopFollowerRepository.php000064400000004117150072630030011777 0ustar00shopFollower->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->shopFollower->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->shopFollower->with($relations) ->when(isset($filters['user_id']), function ($query) use ($filters) { return $query->where('user_id', $filters['user_id']); }) ->when(isset($filters['shop_id']), function ($query) use ($filters) { return $query->where('shop_id', $filters['shop_id']); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy), current($orderBy)); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { // TODO: Implement delete() method. } } VendorRegistrationReasonRepository.php000064400000004206150072630030014353 0ustar00vendorRegistrationReason->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->vendorRegistrationReason->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->vendorRegistrationReason ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy),current($orderBy)); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->vendorRegistrationReason->where($filters) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy),current($orderBy)); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->vendorRegistrationReason->find($id)->update($data); } public function delete(array $params): bool { return $this->vendorRegistrationReason->where($params)->delete(); } } OrderTransactionRepository.php000064400000017602150072630030012640 0ustar00orderTransaction->with($relations)->whereNotIn('status', [$status])->paginate($paginateBy); } public function add(array $data): string|object { return $this->orderTransaction->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->orderTransaction->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->orderTransaction->with($relations)->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->orderTransaction->with($relations) ->when(isset($filters['seller_is']), function ($query) use ($filters) { return $query->where('seller_is',$filters['seller_is']); }) ->when(isset($filters['seller_id']), function ($query) use ($filters) { return $query->where('seller_id',$filters['seller_id']); }) ->when(isset($filters['status']) && $filters['status'] != 'all' , function ($query) use ($filters) { return $query->where('status',$filters['status']); }) ->when($searchValue, function ($query) use ($searchValue) { $query->where('order_id', 'like', "%$searchValue%") ->orWhere('transaction_id', 'like', "%$searchValue%"); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getListWhereBetween(array $filters = [], string $selectColumn = null, string $whereBetween = null, array $whereBetweenFilters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->orderTransaction->with($relations)->where($filters) ->when($selectColumn == 'seller_amount', function ($query) { $query->select( DB::raw('IFNULL(sum(seller_amount),0) as sums'), DB::raw('YEAR(created_at) year, MONTH(created_at) month,DAY(created_at) day,DAYNAME(created_at) day_of_week') ); }) ->when($selectColumn == 'admin_commission', function ($query) { $query->select( DB::raw('IFNULL(sum(admin_commission),0) as sums'), DB::raw('YEAR(created_at) year, MONTH(created_at) month,DAY(created_at) day,DAYNAME(created_at) day_of_week') ); }) ->whereBetween($whereBetween, $whereBetweenFilters) ->groupby('year', 'month') ->get(); } public function update(string $id, array $data): bool { return $this->orderTransaction->where(['id' => $id])->update($data); } public function delete(array $params): bool { $this->orderTransaction->where($params)->delete(); return true; } public function getCommissionEarningStatisticsData(string $sellerIs = null, array $dataRange = [], array $groupBy = [], int $dateStart = 1, int $dateEnd = 12): array { $commissionEarningStatisticsData = []; $commissionEarnings = $this->orderTransaction ->when(isset($sellerIs), function ($query) use ($sellerIs) { return $query->where('seller_is', $sellerIs); }) ->where(['status' => 'disburse']) ->select(DB::raw('IFNULL(sum(admin_commission),0) as sums'), DB::raw('YEAR(created_at) year, MONTH(created_at) month, DAY(created_at) day') ) ->when($dataRange, function ($query) use ($dataRange) { return $query->whereBetween('created_at', [$dataRange['from'], $dataRange['to']]); }) ->when($groupBy, function ($query) use ($groupBy) { return $query->groupby($groupBy); })->get()->toArray(); if (in_array('day', $groupBy)) { for ($inc = $dateStart; $inc <= $dateEnd; $inc++) { $commissionEarningStatisticsData[$inc] = 0; foreach ($commissionEarnings as $match) { if ($match['day'] == $inc) { $commissionEarningStatisticsData[$inc] = $match['sums']; } } } } else { for ($inc = $dateStart; $inc <= $dateEnd; $inc++) { $commissionEarningStatisticsData[$inc] = 0; foreach ($commissionEarnings as $match) { if ($match['month'] == $inc) { $commissionEarningStatisticsData[$inc] = $match['sums']; } } } } return $commissionEarningStatisticsData; } public function getEarningStatisticsData(string $sellerIs = null, array $dataRange = [], array $groupBy = [], int $dateStart = 1, int $dateEnd = 12): array { $inhouseEarningStatisticsData = []; $inhouseEarnings = $this->orderTransaction ->when(isset($sellerIs), function ($query) use ($sellerIs) { return $query->where('seller_is', $sellerIs); }) ->where(['status' => 'disburse']) ->select(DB::raw('IFNULL(sum(seller_amount),0) as sums'), DB::raw('YEAR(created_at) year, MONTH(created_at) month, DAY(created_at) day') ) ->when($dataRange, function ($query) use ($dataRange) { return $query->whereBetween('created_at', [$dataRange['from'], $dataRange['to']]); }) ->when($groupBy, function ($query) use ($groupBy) { return $query->groupby($groupBy); }) ->get() ->toArray(); if (in_array('day', $groupBy)) { for ($inc = $dateStart; $inc <= $dateEnd; $inc++) { $inhouseEarningStatisticsData[$inc] = 0; foreach ($inhouseEarnings as $match) { if ($match['day'] == $inc) { $inhouseEarningStatisticsData[$inc] = $match['sums']; } } } } else { for ($inc = $dateStart; $inc <= 12; $inc++) { $inhouseEarningStatisticsData[$inc] = 0; foreach ($inhouseEarnings as $match) { if ($match['month'] == $inc) { $inhouseEarningStatisticsData[$inc] = $match['sums']; } } } } return $inhouseEarningStatisticsData; } } WithdrawRequestRepository.php000064400000011740150072630030012516 0ustar00withdrawRequest->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->withdrawRequest->with($relations)->where($params)->first(); } public function getFirstWhereNotNull(array $params,array $filters = [],array $orderBy = [],array $relations = []): ?Model { return $this->withdrawRequest->where($params)->whereNotNull($filters) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy),current($orderBy)); }) ->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy=[], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->withdrawRequest->with($relations) ->when($searchValue, function ($query) use ($searchValue,$relations) { $query->whereHas(current($relations), function ($query) use ($searchValue) { $searchTerms = explode(' ', $searchValue); foreach ($searchTerms as $term) { $query->where(function ($query) use ($term) { $query->where('f_name', 'like', "%$term%") ->orWhere('l_name', 'like', "%$term%"); }); } }); }) ->when(isset($filters['vendorId']),function ($query)use($filters){ $query->where(['seller_id'=>$filters['vendorId']]); })->when(isset($filters['admin_id']),function ($query)use($filters){ $query->where(['admin_id'=>$filters['admin_id']]); }) ->when(isset($filters['whereNotNull']) && $filters['whereNotNull'] =='delivery_man_id' ,function ($query){ $query->whereNotNull('delivery_man_id'); }) ->when(isset($filters['status']) && $filters['status'] == 'approved', function ($query) { return $query->where('approved', 1); }) ->when(isset($filters['status']) && $filters['status'] == 'denied', function ($query) { return $query->where('approved', 2); }) ->when(isset($filters['status']) && $filters['status'] == 'pending', function ($query) { return $query->where('approved', 0); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy),current($orderBy)); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getListWhereNull(array $orderBy=[], string $searchValue = null, array $filters = [], array $nullFilters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->withdrawRequest->with($relations) ->when($searchValue == 'delivery_withdraw_status_filter' ,function ($query){ $query->whereNotNull('delivery_man_id'); }) ->when(isset($filters) && $filters['approved'] == 'approved', function ($query) { return $query->where('approved', 1); }) ->when(isset($filters) && $filters['approved'] == 'denied', function ($query) { return $query->where('approved', 2); }) ->when(isset($filters) && $filters['approved'] == 'pending', function ($query) { return $query->where('approved', 0); })->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { $this->withdrawRequest->where(['id'=>$id])->update($data); return true; } public function delete(array $params): bool { return $this->withdrawRequest->where($params)->delete(); } } TagRepository.php000064400000003254150072630030010070 0ustar00tag->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { // TODO: Implement getFirstWhere() method. } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { // TODO: Implement delete() method. } public function incrementVisitCount(array $whereIn = []): bool { $this->tag->when(isset($whereIn), function ($query) use ($whereIn) { foreach ($whereIn as $key => $whereInIndex) { return $query->whereIn($key, $whereInIndex); } })->increment('visit_count'); return true; } } DeliveryZipCodeRepository.php000064400000004773150072630030012425 0ustar00deliveryZipCode->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->deliveryZipCode->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->deliveryZipCode->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->deliveryZipCode ->with($relations) ->when($searchValue, function ($query) use ($searchValue) { $query->orWhere('zipcode', 'like', "%$searchValue%"); }) ->when(isset($filters['zipcode']), function ($query) use ($filters) { return $query->where(['zipcode' => $filters['zipcode']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { $this->deliveryZipCode->where('id', $id)->update($data); return true; } public function delete(array $params): bool { return $this->deliveryZipCode->where($params)->delete(); } } ShippingAddressRepository.php000064400000003015150072630030012437 0ustar00shippingAddress->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->shippingAddress->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { // TODO: Implement delete() method. } } FlashDealRepository.php000064400000006003150072630030011173 0ustar00flashDeal->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->flashDeal->where($params)->first(); } public function getFirstWhereWithoutGlobalScope(array $params, array $relations = []): ?Model { return $this->flashDeal->withoutGlobalScopes()->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { } public function getListWhere(array $orderBy=[], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // } public function update(string $id, array $data): bool { return $this->flashDeal->where('id', $id)->update($data); } public function updateWhere(array $params, array $data): bool { $this->flashDeal->where($params)->update($data); return true; } public function delete(array $params): bool { return $this->flashDeal->where($params)->delete(); } public function getListWithRelations(array $orderBy=[], string $searchValue = null, array $filters = [], array $withCount = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->flashDeal ->with($relations) ->when($searchValue, function ($query) use($searchValue){ $query->orWhere('title', 'like', "%$searchValue%"); }) ->when(isset($filters['deal_type']), function ($query) use ($filters) { return $query->where(['deal_type'=>$filters['deal_type']]); }) ->when(isset($withCount['products']), function ($query) use ($withCount) { return $query->withCount([$withCount['products']=> function ($query) { return $query->whereHas('product',function ($query){ return $query->active(); }); }]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } } WalletTransactionRepository.php000064400000017041150072630030013012 0ustar00walletTransaction->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->walletTransaction->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->walletTransaction->with($relations)->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->walletTransaction ->when(!empty($filters['from']) && !empty($filters['to']),function($query)use($filters){ $query->whereBetween('created_at', [$filters['from'].' 00:00:00', $filters['to'].' 23:59:59']); }) ->when(!empty($filters['transaction_type']) && $filters['transaction_type'] != 'all', function($query)use($filters){ $query->where('transaction_type',$filters['transaction_type']); }) ->when(!empty($filters['customer_id']) && $filters['customer_id'] != 'all', function($query)use($filters) { $query->where('user_id', $filters['customer_id']); })->latest(); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends(['searchValue' => $searchValue]); } public function getListWhereSelect(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->walletTransaction->selectRaw('sum(credit) as total_credit, sum(debit) as total_debit') ->when((!empty($filters['from']) && !empty($filters['to'])),function($query)use($filters){ $query->whereBetween('created_at', [$filters['from'].' 00:00:00', $filters['to'].' 23:59:59']); }) ->when(!empty($filters['transaction_type']) && $filters['transaction_type'] != 'all', function($query)use($filters){ $query->where('transaction_type', $filters['transaction_type']); }) ->when(!empty($filters['customer_id']) && $filters['customer_id'] != 'all', function($query)use($filters) { $query->where('user_id', $filters['customer_id']); })->latest(); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends(['searchValue' => $searchValue]); } public function update(string $id, array $data): bool { return $this->walletTransaction->where('id', $id)->update($data); } public function delete(array $params): bool { $this->walletTransaction->where($params)->delete(); return true; } public function addWalletTransaction(string $user_id, float $amount, string $transactionType, string $reference=null, array $payment_data=[]): bool|WalletTransaction { if($this->businessSetting->where('type','wallet_status')->first()->value != 1) return false; $user = $this->user->where('id', $user_id)->first(); $currentBalance = $user->wallet_balance; $wallet_transaction = new WalletTransaction(); $wallet_transaction['user_id'] = $user->id; $wallet_transaction['transaction_id'] = Str::uuid(); $wallet_transaction['reference'] = $reference; $wallet_transaction['transaction_type'] = $transactionType; $wallet_transaction['payment_method'] = $payment_data['payment_method'] ?? null; $debit = 0.0; $credit = 0.0; $addFundToWalletBonus = 0; if(in_array($transactionType, ['add_fund_by_admin','add_fund','order_refund','loyalty_point'])) { $credit = $amount; if($transactionType == 'add_fund') { $wallet_transaction['admin_bonus'] = $this->addFundToWalletBonus(amount: currencyConverter(amount:$amount ?? 0)); $addFundToWalletBonus = $this->addFundToWalletBonus(amount: currencyConverter(amount:$amount ?? 0)); } else if($transactionType == 'loyalty_point') { $credit = (($amount / $this->businessSetting->where('type','loyalty_point_exchange_rate')->first()->value) * currencyConverter(1)); } } else if($transactionType == 'order_place') { $debit = $amount; } $credit_amount = currencyConverter(amount: $credit); $debit_amount = currencyConverter(amount: $debit); $wallet_transaction['credit'] = $credit_amount; $wallet_transaction['debit'] = $debit_amount; $wallet_transaction['balance'] = $currentBalance + $credit_amount - $debit_amount; $wallet_transaction['created_at'] = now(); $wallet_transaction['updated_at'] = now(); try{ DB::beginTransaction(); $this->user->where('id', $user_id)->update([ 'wallet_balance' => $currentBalance + $addFundToWalletBonus + $credit_amount - $debit_amount, ]); $wallet_transaction->save(); DB::commit(); if(in_array($transactionType, ['loyalty_point','order_place','add_fund_by_admin'])) return $wallet_transaction; return true; }catch(\Exception $ex) { DB::rollback(); } return false; } public function addFundToWalletBonus(float $amount): string|float { $bonuses = $this->addFundBonusCategories->where('is_active', 1) ->whereDate('start_date_time', '<=', now()) ->whereDate('end_date_time', '>=', now()) ->where('min_add_money_amount', '<=', $amount) ->get(); $applicableBonuses = $bonuses->where('min_add_money_amount', $bonuses->max('min_add_money_amount')); foreach ($applicableBonuses as $key => $item) { $item->applied_bonus_amount = $item->bonus_type == 'percentage' ? ($amount * $item->bonus_amount) / 100 : $item->bonus_amount; //max bonus check if ($item->bonus_type == 'percentage' && $item->applied_bonus_amount > $item->max_bonus_amount) { $item->applied_bonus_amount = $item->max_bonus_amount; } } return $bonuses->max('applied_bonus_amount') ?? 0; } } AttributeRepository.php000064400000004433150072630030011320 0ustar00attribute->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->attribute->withoutGlobalScope('translate')->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->attribute->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere( array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->attribute->when($searchValue, function ($query) use ($searchValue) { return $query->where('name', 'like', "%$searchValue%"); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->attribute->where('id', $id)->update($data); } public function delete(array $params): bool { $this->attribute->where($params)->delete(); return true; } } OrderExpectedDeliveryHistoryRepository.php000064400000003002150072630030015167 0ustar00orderStatusHistory->where($filters)->latest()->get(); } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { // TODO: Implement delete() method. } } SubscriptionRepository.php000064400000004111150072630030012032 0ustar00subscription->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->subscription->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->subscription->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->subscription->where($filters)->with($relations) ->when($searchValue, function ($query) use($searchValue){ $query->orWhere('email', 'like', "%$searchValue%"); })->latest(); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends(['searchValue' => $searchValue]); } public function update(string $id, array $data): bool { return $this->subscription->where('id', $id)->update($data); } public function delete(array $params): bool { $this->subscription->where($params)->delete(); return true; } } ProductRepository.php000064400000060350150072630030010775 0ustar00tags != null) { $tags = explode(",", $request->tags); } if (isset($tags)) { foreach ($tags as $value) { $tag = $this->tag->firstOrNew( ['tag' => trim($value)] ); $tag->save(); $tagIds[] = $tag->id; } } $product->tags()->sync($tagIds); } public function add(array $data): string|object { return $this->product->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->product->where($params)->with($relations)->first(); } public function getFirstWhereWithCount(array $params, array $withCount = [], array $relations = []): ?Model { return $this->product->with($relations)->where($params)->withCount($withCount)->first(); } public function getFirstWhereWithoutGlobalScope(array $params, array $relations = []): ?Model { return $this->product->withoutGlobalScopes()->where($params)->with($relations)->first(); } public function getFirstWhereActive(array $params, array $relations = []): ?Model { return $this->product->active()->where($params)->with($relations)->first(); } public function getWebFirstWhereActive(array $params, array $relations = [], array $withCount = []): ?Model { return $this->product->active() ->when(isset($relations['reviews']), function ($query) use ($relations) { return $query->with($relations['reviews']); }) ->when(isset($relations['seller.shop']), function ($query) use ($relations) { return $query->with($relations['seller.shop']); }) ->when(isset($relations['wishList']), function ($query) use ($relations, $params) { return $query->with([$relations['wishList'] => function ($query) use ($params) { return $query->when(isset($params['customer_id']), function ($query) use ($params) { return $query->where('customer_id', $params['customer_id']); }); }]); }) ->when(isset($relations['compareList']), function ($query) use ($relations, $params) { return $query->with([$relations['compareList'] => function ($query) use ($params) { return $query->when(isset($params['customer_id']), function ($query) use ($params) { return $query->where('user_id', $params['customer_id']); }); }]); }) ->when(isset($params['slug']), function ($query) use ($params) { return $query->where('slug', $params['slug']); }) ->when(isset($withCount['orderDetails']), function ($query) use ($withCount) { return $query->withCount($withCount['orderDetails']); }) ->when(isset($withCount['wishList']), function ($query) use ($withCount) { return $query->withCount($withCount['wishList']); }) ->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->product->with($relations)->when(isset($filters['added_by']) && $this->isAddedByInHouse(addedBy: $filters['added_by']), function ($query) { return $query->where(['added_by' => 'admin']); })->when(isset($filters['added_by']) && !$this->isAddedByInHouse($filters['added_by']), function ($query) use ($filters) { return $query->where(['added_by' => 'seller']) ->when(isset($filters['request_status']) && $filters['request_status'] != 'all', function ($query) use ($filters) { $query->where(['request_status' => $filters['request_status']]); }) ->when(isset($filters['seller_id'])&& $filters['seller_id']!='all', function ($query) use ($filters) { return $query->where(['user_id' => $filters['seller_id']]); }); })->when($searchValue, function ($query) use ($filters, $searchValue) { $product_ids = $this->translation->where('translationable_type', 'App\Models\Product') ->where('key', 'name') ->where('value', 'like', "%{$searchValue}%") ->pluck('translationable_id'); return $query->where('name', 'like', "%{$searchValue}%") ->orWhere(function ($query) use ($filters) { if (isset($filters['code'])) { $query->where('code', 'like', "%{$filters['code']}%"); } }) ->when(isset($filters['added_by']) && !$this->isAddedByInHouse($filters['added_by']), function($query) use($filters, $product_ids) { $query->orWhereIn('id', $product_ids) ->where(['added_by' => 'seller']) ->when(isset($filters['seller_id']), function ($query) use ($filters) { return $query->where(['user_id' => $filters['seller_id']]); }); }) ->when(isset($filters['added_by']) && $this->isAddedByInHouse($filters['added_by']), function($query) use($filters, $product_ids) { $query->orWhereIn('id', $product_ids)->where(['added_by' => 'admin']); }); })->when(isset($filters['product_search_type']) && $filters['product_search_type'] == 'product_gallery', function ($query) use ($filters) { return $query->when(isset($filters['request_status']) && $filters['request_status'] != 'all', function ($query) use ($filters) { $query->where(['request_status' => $filters['request_status']]); }); })->when(isset($filters['brand_id']) && $filters['brand_id'] != 'all', function ($query) use ($filters) { return $query->where(['brand_id' => $filters['brand_id']]); })->when(isset($filters['category_id']) && $filters['category_id'] != 'all', function ($query) use ($filters) { return $query->where(['category_id' => $filters['category_id']]); })->when(isset($filters['sub_category_id']) && $filters['sub_category_id'] != 'all', function ($query) use ($filters) { return $query->where(['sub_category_id' => $filters['sub_category_id']]); })->when(isset($filters['sub_sub_category_id']) && $filters['sub_sub_category_id'] != 'all', function ($query) use ($filters) { return $query->where(['sub_sub_category_id' => $filters['sub_sub_category_id']]); })->when(isset($filters['is_shipping_cost_updated']), function ($query) use ($filters) { return $query->where(['is_shipping_cost_updated' => $filters['is_shipping_cost_updated']]); })->when(isset($filters['status']), function ($query) use ($filters) { return $query->where(['status' => $filters['status']]); })->when(isset($filters['code']), function ($query) use ($filters) { return $query->where(['code' => $filters['code']]); })->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getListWithScope(array $orderBy = [], string $searchValue = null, string $scope = null, array $filters = [], array $whereIn = [], array $whereNotIn = [], array $relations = [], array $withCount = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->product->with($relations) ->when(isset($withCount['reviews']), function ($query) use ($withCount) { return $query->withCount($withCount['reviews']); }) ->when(isset($scope) && $scope == 'active', function ($query) { return $query->active(); }) ->when($searchValue, function ($query) use ($searchValue) { $product_ids = $this->translation->where('translationable_type', 'App\Models\Product') ->where('key', 'name') ->where('value', 'like', "%{$searchValue}%") ->pluck('translationable_id'); return $query->where('name', 'like', "%{$searchValue}%") ->orWhereIn('id', $product_ids); }) ->when(isset($filters['search_from']) && $filters['search_from'] == 'pos', function ($query) use ($filters) { $searchKeyword = str_ireplace(['\'', '"', ',', ';', '<', '>', '?'], ' ', preg_replace('/\s\s+/', ' ', $filters['keywords'])); return $query->where(function ($query) use ($filters) { return $query->where('code', 'like', "%{$filters['keywords']}%") ->orWhere('name', 'like', "%{$filters['keywords']}%"); }) ->orderByRaw("CASE WHEN name LIKE '%{$searchKeyword}%' THEN 1 ELSE 2 END, LOCATE('{$searchKeyword}', name), name"); }) ->when(isset($filters['added_by']) && $this->isAddedByInHouse(addedBy: $filters['added_by']), function ($query) { return $query->where(['added_by' => 'admin']); })->when(isset($filters['added_by']) && !$this->isAddedByInHouse($filters['added_by']), function ($query) use ($filters) { return $query->where(['added_by' => 'seller']) ->when(isset($filters['request_status']), function ($query) use ($filters) { $query->where(['request_status' => $filters['request_status']]); }) ->when(isset($filters['seller_id']), function ($query) use ($filters) { return $query->where(['user_id' => $filters['seller_id']]); }); }) ->when(isset($filters['brand_id']), function ($query) use ($filters) { return $query->where(['brand_id' => $filters['brand_id']]); })->when(isset($filters['category_id']), function ($query) use ($filters) { return $query->where(['category_id' => $filters['category_id']]); })->when(isset($filters['sub_category_id']), function ($query) use ($filters) { return $query->where(['sub_category_id' => $filters['sub_category_id']]); })->when(isset($filters['status']), function ($query) use ($filters) { return $query->where(['status' => $filters['status']]); })->when(isset($whereIn), function ($query) use ($whereIn) { foreach ($whereIn as $key => $whereInIndex) { return $query->whereIn($key, $whereInIndex); } }) ->when(isset($filters['sub_sub_category_id']), function ($query) use ($filters) { return $query->where(['sub_sub_category_id' => $filters['sub_sub_category_id']]); })->when($whereNotIn, function ($query) use ($whereNotIn) { foreach ($whereNotIn as $key => $whereNotInIndex) { $query->whereNotIn($key, $whereNotInIndex); } })->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getWebListWithScope(array $orderBy = [], string $searchValue = null, string $scope = null, array $filters = [], array $whereHas = [], array $whereIn = [], array $whereNotIn = [], array $relations = [], array $withCount = [], array $withSum = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->product ->when(isset($scope) && $scope == 'active', function ($query) { return $query->active(); }) ->when(isset($filters['added_by']) && $this->isAddedByInHouse(addedBy: $filters['added_by']), function ($query) { return $query->where(['added_by' => 'admin']); })->when(isset($filters['added_by']) && !$this->isAddedByInHouse($filters['added_by']), function ($query) use ($filters) { return $query->where(['added_by' => 'seller']); }) ->when(isset($relations['reviews']), function ($query) use ($relations) { return $query->with($relations['reviews'], function ($query) use($relations) { return $query->active(); }); }) ->when(isset($relations['seller.shop']), function ($query) use ($relations) { return $query->with($relations['seller.shop']); }) ->when(isset($relations['flashDealProducts.flashDeal']), function ($query) use ($relations) { return $query->with($relations['flashDealProducts.flashDeal']); }) ->when(isset($relations['wishList']), function ($query) use ($relations, $filters) { return $query->with([$relations['wishList'] => function ($query) use ($filters) { return $query->when(isset($filters['customer_id']), function ($query) use ($filters) { return $query->where('customer_id', $filters['customer_id']); }); }]); }) ->when(isset($relations['compareList']), function ($query) use ($relations, $filters) { return $query->with([$relations['compareList'] => function ($query) use ($filters) { return $query->when(isset($filters['customer_id']), function ($query) use ($filters) { return $query->where('user_id', $filters['customer_id']); }); }]); }) ->when(isset($whereHas['reviews']), function ($query) use ($whereHas) { return $query; }) ->when(isset($withCount['reviews']), function ($query) use ($withCount) { return $query->withCount([$withCount['reviews'] => function ($query) { return $query->active(); }]); }) ->when($withSum, function ($query) use ($withSum) { foreach ($withSum as $sum) { return $query->withSum($sum['relation'], $sum['column'], function ($query) use ($sum) { $query->where($sum['whereColumn'], $sum['whereValue']); }); } return $query->withSum($withSum['orderDetails']); }) ->when(isset($withSum['qty']), function ($query) use ($withSum) { return $query->withSum($withSum['qty']); }) ->when($searchValue, function ($query) use ($searchValue) { $product_ids = $this->translation->where('translationable_type', 'App\Models\Product') ->where('key', 'name') ->where('value', 'like', "%{$searchValue}%") ->pluck('translationable_id'); return $query->where('name', 'like', "%{$searchValue}%")->orWhereIn('id', $product_ids); })->when(isset($filters['seller_id']), function ($query) use ($filters) { return $query->where('user_id', $filters['seller_id']); })->when(isset($filters['brand_id']), function ($query) use ($filters) { return $query->where(['brand_id' => $filters['brand_id']]); })->when(isset($filters['category_id']), function ($query) use ($filters) { return $query->where(['category_id' => $filters['category_id']]); })->when(isset($filters['sub_category_id']), function ($query) use ($filters) { return $query->where(['sub_category_id' => $filters['sub_category_id']]); })->when(isset($whereIn), function ($query) use ($whereIn) { foreach ($whereIn as $key => $whereInIndex) { return $query->whereIn($key, $whereInIndex); } })->when(isset($filters['sub_sub_category_id']), function ($query) use ($filters) { return $query->where(['sub_sub_category_id' => $filters['sub_sub_category_id']]); })->when($whereNotIn, function ($query) use ($whereNotIn) { foreach ($whereNotIn as $key => $whereNotInIndex) { $query->whereNotIn($key, $whereNotInIndex); } })->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->product->where('id', $id)->update($data); } public function updateByParams(array $params, array $data): bool { return $this->product->where($params)->update($data); } public function getListWhereNotIn(array $filters = [], array $whereNotIn = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->product->when($whereNotIn, function ($query) use ($whereNotIn) { foreach ($whereNotIn as $key => $whereNotInIndex) { $query->whereNotIn($key, $whereNotInIndex); } })->when(isset($filters['user_id']), function ($query) use ($filters) { return $query->where(['user_id' => $filters['user_id']]); })->when(isset($filters['added_by']), function ($query) use ($filters) { return $query->where(['added_by' => $filters['added_by']]); })->get(); } public function getTopRatedList(array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->product->with($relations)->where($filters) ->with('reviews', function ($query) { return $query->whereHas('product', function ($query) { $query->active(); }); }) ->withCount(['reviews' => function ($query){ return $query->whereNull('delivery_man_id'); }]) ->withAvg('rating as ratings_average', 'rating') ->orderByDesc('reviews_count') ->get(); } public function getTopSellList(array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->product->with($relations) ->when(isset($filters['added_by']) && $this->isAddedByInHouse(addedBy: $filters['added_by']), function ($query) { return $query->where(['added_by' => 'admin']); })->when(isset($filters['added_by']) && !$this->isAddedByInHouse($filters['added_by']), function ($query) use ($filters) { return $query->where(['added_by' => 'seller', 'request_status' => $filters['request_status']]); })->when(isset($filters['seller_id']), function ($query) use ($filters) { return $query->where('user_id', $filters['seller_id']); }) ->when(isset($filters['request_status']), function ($query) use ($filters) { return $query->where('request_status', $filters['request_status']); }) ->whereHas('orderDetails', function ($query) { $query->where(['delivery_status' => 'delivered']); }) ->withCount('orderDetails')->get() ->sortByDesc('order_details_count'); } public function delete(array $params): bool { return $this->product->where($params)->delete(); } public function getStockLimitListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $withCount = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $stockLimit = getWebConfig(name: 'stock_limit'); $query = $this->product->with($relations) ->withCount($withCount) ->when($this->isAddedByInHouse(addedBy: $filters['added_by']), function ($query) { return $query->where(['added_by' => 'admin']); }) ->when(!$this->isAddedByInHouse($filters['added_by']), function ($query) use ($filters) { return $query->where(['added_by' => 'seller', 'product_type' => 'physical']) ->when(isset($filters['request_status']), function ($query) use ($filters) { return $query->where(['request_status' => $filters['request_status']]); }) ->when(isset($filters['seller_id']), function ($query) use ($filters) { return $query->where(['user_id' => $filters['seller_id']]); }); }) ->when(isset($filters['product_type']), function ($query) use ($filters) { return $query->where(['product_type' => $filters['product_type']]); }) ->when($searchValue, function ($query) use ($searchValue) { $product_ids = $this->translation->where('translationable_type', 'App\Models\Product') ->where('key', 'name') ->where('value', 'like', "%{$searchValue}%") ->pluck('translationable_id'); return $query->where('name', 'like', "%{$searchValue}%")->orWhereIn('id', $product_ids); }) ->where('current_stock', '<', $stockLimit) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getProductIds(array $filters = []): \Illuminate\Support\Collection|array { return $this->product->when(isset($filters['added_by']), function ($query) use ($filters) { return $query->where('added_by', $filters['added_by']); })->when(isset($filters['user_id']), function ($query) use ($filters) { return $query->where('user_id', $filters['user_id']); })->pluck('id'); } public function addArray(array $data): bool { return DB::table('products')->insert($data); } } VendorWalletRepository.php000064400000004327150072630030011765 0ustar00vendorWallet->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->vendorWallet->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->vendorWallet ->with($relations) ->whereHas('seller', function ($query) { return $query; }) ->when($searchValue, function ($query) use($searchValue){ $query->where('seller_id', 'like', "%$searchValue%"); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->vendorWallet->where(['id'=>$id])->update($data); } public function updateWhere(array $params, array $data): bool { $this->vendorWallet->where($params)->update($data); return true; } public function delete(array $params): bool { // TODO: Implement delete() method. } } HelpTopicRepository.php000064400000005636150072630030011252 0ustar00helpTopic->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->helpTopic->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->helpTopic->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->helpTopic ->with($relations) ->when($searchValue, function ($query) use ($searchValue) { $query->where('question', 'like', "%{$searchValue}%") ->orWhere('answer', 'like', "%{$searchValue}%"); }) ->when(isset($filters['type']), function ($query) use ($filters) { return $query->where(['type' => $filters['type']]); }) ->when(isset($filters['ranking']), function ($query) use ($filters) { return $query->where(['ranking' => $filters['ranking']]); }) ->when(isset($filters['status']), function ($query) use ($filters) { return $query->where(['status' => $filters['status']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy), current($orderBy)); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->helpTopic->where('id', $id)->update($data); } public function updateWhere(array $params, array $data): bool { $this->helpTopic->where($params)->update($data); return true; } public function delete(array $params): bool { $this->helpTopic->where($params)->delete(); return true; } } ContactRepository.php000064400000005243150072630030010750 0ustar00contact->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->contact->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->contact ->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy=[], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->contact->with($relations) ->when($searchValue, function ($query) use($searchValue){ $query->orWhere('name', 'like', "%$searchValue%") ->orWhere('email', 'like', "%$searchValue%") ->orWhere('mobile_number', 'like', "%$searchValue%"); }) ->when(isset($filters['reply']) && $filters['reply'] == 'replied',function ($query){ return $query->whereNotNull('reply'); }) ->when(isset($filters['reply']) && $filters['reply'] == 'not_replied',function ($query){ return $query->whereNull('reply'); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { $this->contact->where('id', $id)->update($data); return true; } public function delete(array $params): bool { return $this->contact->where($params)->delete(); } } FlashDealProductRepository.php000064400000004100150072630030012530 0ustar00flashDealProduct->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->flashDealProduct->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { } public function getListWhere(array $orderBy=[], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->flashDealProduct ->with($relations) ->when($searchValue, function ($query) use($searchValue){ $query->orWhere('title', 'like', "%$searchValue%"); }) ->when(isset($filters['flash_deal_id']), function ($query) use ($filters){ return $query->where(['flash_deal_id'=>$filters['flash_deal_id']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { // } public function delete(array $params): bool { $this->flashDealProduct->where($params)->delete(); return true; } } CategoryShippingCostRepository.php000064400000003361150072630030013464 0ustar00categoryShippingCost->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->categoryShippingCost->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->categoryShippingCost->with($relations)->where($filters)->get(); } public function update(string $id, array $data): bool { return $this->categoryShippingCost->find($id)->update($data); } public function updateOrInsert(array $params, array $data): bool { $this->categoryShippingCost->updateOrInsert($params, $data); return true; } public function delete(array $params): bool { // TODO: Implement delete() method. } } ShippingMethodRepository.php000064400000003467150072630030012305 0ustar00shippingMethod->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->shippingMethod->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->shippingMethod->with($relations)->where($filters) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy),current($orderBy)); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->shippingMethod->find($id)->update($data); } public function delete(array $params): bool { return $this->shippingMethod->where($params)->delete(); } } VendorRepository.php000064400000007571150072630030010620 0ustar00vendor->with($relations)->whereNotIn('status', [$status])->paginate($paginateBy); } public function add(array $data): string|object { return $this->vendor->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->vendor->with($relations) ->when(isset($params['identity']),function ($query) use ($params){ return $query->where(['email' => $params['identity']]) ->orWhere(['phone' => $params['identity']]); }) ->when(isset($params['id']),function ($query) use ($params){ return $query->where(['id' => $params['id']]); }) ->when(isset($params['withCount']),function ($query)use($params){ return $query->withCount($params['withCount']); }) ->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->vendor->with($relations)->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy=[], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->vendor->with($relations)->where($filters) ->when($searchValue, function ($query) use ($searchValue) { $searchTerms = explode(' ', $searchValue); $query->where(function ($query) use ($searchTerms) { foreach ($searchTerms as $term) { $query->orWhere('f_name', 'like', "%$term%") ->orWhere('l_name', 'like', "%$term%") ->orWhere('phone', 'like', "%$term%") ->orWhere('email', 'like', "%$term%") ->orWhereHas('shop', function ($query) use ($term) { $query->where('name', 'like', "%$term%"); }); } }); }) ->when(!empty($relations) && in_array('product', $relations), function ($query) { $query->withCount('product'); }) ->when(!empty($relations) && in_array('orders', $relations), function ($query) { $query->withCount('orders'); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->vendor->where(['id'=>$id])->update($data); } public function delete(array $params): bool { $this->vendor->where($params)->delete(); return true; } } CustomerWalletRepository.php000064400000003012150072630030012317 0ustar00customerWallet->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->customerWallet->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { $this->customerWallet->where($params)->delete(); return true; } } ColorRepository.php000064400000004240150072630030010427 0ustar00color->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->color->when($relations, function ($query) use ($relations) { return $query->with($relations); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere( array $orderBy=[], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null ): Collection|LengthAwarePaginator { return $this->color->when($searchValue, function ($query) use($searchValue) { $query->where(function ($q) use ($searchValue) { $q->Where('name', 'like', "%$searchValue%"); }); }) ->where($filters) ->when($dataLimit == 'all', function($query){ $query->get(); }) ->when($dataLimit != 'all', function($query) use($dataLimit, $filters){ $query->paginate($dataLimit)->appends($filters); }); } public function update(string $id, array $data): bool { return true; } public function delete(array $params): bool { return true; } } DealOfTheDayRepository.php000064400000004677150072630030011620 0ustar00dealOfTheDay->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->dealOfTheDay->where($params)->first(); } public function getFirstWhereWithoutGlobalScope(array $params, array $relations = []): ?Model { return $this->dealOfTheDay->withoutGlobalScopes()->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { } public function getListWhere(array $orderBy=[], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->dealOfTheDay ->with($relations) ->when($searchValue, function ($query) use($searchValue){ $query->orWhere('title', 'like', "%$searchValue%"); }) ->when(isset($filters['product_id']), function ($query) use ($filters){ return $query->where(['product_id'=>$filters['product_id']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { $this->dealOfTheDay->where('id', $id)->update($data); return true; } public function updateWhere(array $params, array $data): bool { $this->dealOfTheDay->where($params)->update($data); return true; } public function delete(array $params): bool { return $this->dealOfTheDay->where($params)->delete(); } } OrderStatusHistoryRepository.php000064400000002721150072630030013214 0ustar00orderStatusHistory->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { // TODO: Implement getFirstWhere() method. } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->orderStatusHistory->where($filters)->latest()->get(); } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { // TODO: Implement delete() method. } } ChattingRepository.php000064400000014561150072630030011121 0ustar00chatting->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->chatting->where($params)->first(); } public function getFirstWhereNotNull(array $params,array $filters = [],array $orderBy = [],array $relations = []): ?Model { return $this->chatting->where($params)->whereNotNull($filters)->orderBy(key($orderBy), current($orderBy))->first(); } public function getListBySelectWhere(array $joinColumn = [], array $select = [],array $filters = [],array $orderBy = []): Collection { list($table, $first, $operator, $second) = $joinColumn; return $this->chatting ->join($table, $first, $operator, $second) ->select($select) ->where($filters) ->orderBy(key($orderBy), current($orderBy)) ->get(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->chatting->with($relations) ->when(isset($filters['user_id']), function ($query) use ($filters) { return $query->where(['user_id'=>$filters['user_id']]); }) ->when(isset($filters['seller_id']), function ($query) use ($filters) { return $query->where(['seller_id'=>$filters['seller_id']]); }) ->when(isset($filters['delivery_man_id']), function ($query) use ($filters) { return $query->where(['delivery_man_id'=>$filters['delivery_man_id']]); }) ->when(isset($filters['admin_id']), function ($query) use ($filters) { return $query->where(['admin_id'=>$filters['admin_id']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getListWhereNotNull(array $orderBy = [], string $searchValue = null, array $filters = [], array $whereNotNull = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->chatting->with($relations) ->when(isset($filters['user_id']), function ($query) use ($filters) { return $query->where(['user_id'=>$filters['user_id']]); }) ->when(isset($filters['seller_id']), function ($query) use ($filters) { return $query->where(['seller_id'=>$filters['seller_id']]); }) ->when(isset($filters['delivery_man_id']), function ($query) use ($filters) { return $query->where(['delivery_man_id'=>$filters['delivery_man_id']]); }) ->when(isset($filters['admin_id']), function ($query) use ($filters) { return $query->where(['admin_id'=>$filters['admin_id']]); }) ->when(isset($filters['notification_receiver']), function ($query) use ($filters) { return $query->where(['notification_receiver'=>$filters['notification_receiver']]); }) ->when(isset($filters['seen_notification']), function ($query) use ($filters) { return $query->where(['seen_notification'=>$filters['seen_notification']]); }) ->whereNotNull($whereNotNull) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function updateAllWhere(array $params, array $data) : bool { return $this->chatting->where($params)->update($data); } public function updateListWhereNotNull(string $searchValue = null, array $filters = [], array $whereNotNull = [], array $data = []): bool { $this->chatting ->when(isset($filters['user_id']), function ($query) use ($filters) { return $query->where(['user_id'=>$filters['user_id']]); }) ->when(isset($filters['seller_id']), function ($query) use ($filters) { return $query->where(['seller_id'=>$filters['seller_id']]); }) ->when(isset($filters['delivery_man_id']), function ($query) use ($filters) { return $query->where(['delivery_man_id'=>$filters['delivery_man_id']]); }) ->when(isset($filters['admin_id']), function ($query) use ($filters) { return $query->where(['admin_id'=>$filters['admin_id']]); }) ->when(isset($filters['notification_receiver']), function ($query) use ($filters) { return $query->where(['notification_receiver'=>$filters['notification_receiver']]); }) ->when(isset($filters['seen_notification']), function ($query) use ($filters) { return $query->where(['seen_notification'=>$filters['seen_notification']]); }) ->whereNotNull($whereNotNull)->update($data); return true; } public function update(string $id, array $data): bool { // TODO: Implement update() method. } public function delete(array $params): bool { // TODO: Implement delete() method. } } DeliveryManRepository.php000064400000013176150072630030011600 0ustar00deliveryMan->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->deliveryMan->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->deliveryMan->with($relations) ->withCount('orders') ->when($searchValue, function ($query) use ($searchValue) { $searchTerms = explode(' ', $searchValue); $query->where(function ($query) use ($searchTerms) { foreach ($searchTerms as $term) { $query->orWhere('f_name', 'like', "%$term%") ->orWhere('l_name', 'like', "%$term%") ->orWhere('phone', 'like', "%$term%") ->orWhere('email', 'like', "%$term%"); } }); }) ->when(isset($filters['seller_id']), function ($query) use ($filters) { $query->where('seller_id', $filters['seller_id']); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy), current($orderBy)); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getTopRatedList(array $orderBy = [],array $filters = [], array $whereHasFilters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->deliveryMan->with($relations) ->when(isset($filters['seller_id']), function ($query) use ($filters) { $query->where('seller_id', $filters['seller_id']); }) ->when(current($relations)=='deliveredOrders', function ($query) use ($whereHasFilters) { $query->whereHas('deliveredOrders', function ($query) use ($whereHasFilters) { $query->when($whereHasFilters,function ($query)use($whereHasFilters){ return $query->where($whereHasFilters)->whereNotNull('delivery_man_id'); }); }); }) ->withCount(current($relations)) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy), current($orderBy)); }) ->get(); } public function update(string $id, array $data): bool { return $this->deliveryMan->where('id', $id)->update($data); } public function delete(array $params): bool { $this->deliveryMan->where($params)->delete(); return true; } public function getListWhereIn(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], array $nullFields = [], array $withCounts = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->deliveryMan ->when(!empty($searchValue), function ($query) use ($searchValue) { $query->where('f_name', 'like', "%$searchValue%") ->orWhere('l_name', 'like', "%$searchValue%") ->orWhere('phone', 'like', "%$searchValue%"); }) ->when(!empty($filters) && isset($filters['order_seller']) && isset($filters['shipping_method']), function ($query) use ($filters) { $query->when($filters['order_seller'] == 'seller' && $filters['shipping_method'] == 'sellerwise_shipping', function ($query) use ($filters) { $query->where(['seller_id' => $filters['seller_id']]); })->when($filters['order_seller'] == 'seller' && $filters['shipping_method'] == 'inhouse_shipping', function ($query) use ($filters) { $query->where(['seller_id' => 0]); }); }) ->when(isset($filters['is_active']), function ($query) use ($filters) { $query->where(['is_active' => $filters['is_active']]); }) ->when(isset($withCounts), function ($query) use ($withCounts) { $query->withCount($withCounts); }) ->when(!empty($nullFields), function ($query) use ($nullFields) { $query->whereNull($nullFields); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } } EmailTemplatesRepository.php000064400000003264150072630030012264 0ustar00emailTemplate->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->emailTemplate->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { return $this->emailTemplate->with($relations)->where($filters) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); })->get(); } public function update(string $id, array $data): bool { return $this->emailTemplate->find($id)->update($data); } public function delete(array $params): bool { return $this->emailTemplate->where($params)->delete(); } } AdminRepository.php000064400000007022150072630030010402 0ustar00admin->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->admin->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->admin->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->admin ->when($searchValue, function ($query) use($searchValue){ $query->where('name', 'like', "%$searchValue%") ->orWhere('phone', 'like', "%$searchValue%") ->orWhere('email', 'like', "%$searchValue%"); }) ->when($filters['admin_role_id'] && $filters['admin_role_id'] !='all', function($query)use($filters){ $query->where('admin_role_id', $filters['admin_role_id']); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->admin->where('id', $id)->update($data); } public function delete(array $params): bool { $this->admin->where($params)->delete(); return true; } public function getEmployeeListWhere( array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null ): Collection|LengthAwarePaginator { $query = $this->admin ->with($relations) ->whereNotIn('id', [1]) ->when($searchValue, function ($query) use($searchValue){ $query->where('name', 'like', "%$searchValue%") ->orWhere('phone', 'like', "%$searchValue%") ->orWhere('email', 'like', "%$searchValue%"); }) ->when($filters['admin_role_id'] && $filters['admin_role_id'] != 'all', function($query)use ($filters){ $query->where('admin_role_id', $filters['admin_role_id']); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } } BannerRepository.php000064400000007720150072630030010564 0ustar00banner->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->banner->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->banner->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy), array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->banner->with($relations) ->when($searchValue, function ($query) use($searchValue){ return $query->orWhere('banner_type', 'like', "%$searchValue%"); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }) ->when(isset($filters['resource_type']) && isset($filters['resource_id']), function ($query) use($filters){ return $query->where(['resource_type'=>$filters['resource_type'],'resource_id'=>$filters['resource_id']]); }) ->when(isset($filters['theme']), function ($query) use($filters){ return $query->where('theme', $filters['theme']); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getListWhereIn(array $orderBy = [], string $searchValue = null, array $filters = [], array $whereInFilters = [], array $relations = [], array $nullFields = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->banner ->with($relations) ->when($searchValue, function ($query) use($searchValue){ return $query->orWhere('banner_type', 'like', "%$searchValue%"); }) ->when(!empty($whereInFilters), function ($query) use ($whereInFilters) { foreach ($whereInFilters as $key => $filterIndex){ $query->whereIn($key , $filterIndex); } }) ->when(!empty($nullFields), function ($query) use ($nullFields) { return $query->whereNull($nullFields); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); })->when($filters['theme'], function ($query) use($filters){ return $query->where('theme', $filters['theme']); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { $this->banner->where('id', $id)->update($data); return true; } public function delete(array $params): bool { $this->banner->where($params)->delete(); return true; } } CouponRepository.php000064400000007541150072630030010623 0ustar00coupon->newInstance()->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->coupon->with($relations)->where($params)->first(); } public function getFirstWhereFilters(array $filters = [], array $relations = []): ?Model { return $this->coupon->with($relations) ->when(isset($filters['added_by']), function ($query) use ($filters) { $query->where('added_by', $filters['added_by']); }) ->when(isset($filters['code']), function ($query) use ($filters) { $query->where('code', $filters['code']); }) ->when(isset($filters['coupon_bearer']), function ($query) use ($filters) { $query->where('coupon_bearer', $filters['coupon_bearer']); }) ->when(isset($filters['limit']), function ($query) use ($filters) { $query->where('limit', '>', $filters['limit']); }) ->when(isset($filters['status']), function ($query) use ($filters) { $query->where('status', $filters['status']); }) ->when(isset($filters['start_date']), function ($query) use ($filters) { $query->whereDate('start_date', '<=', $filters['start_date']); }) ->when(isset($filters['expire_date']), function ($query) use ($filters) { $query->whereDate('expire_date', '>=', $filters['expire_date']); }) ->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->coupon->with($relations) ->when(!empty($searchValue), function ($query) use ($searchValue) { return $query->where(function ($query) use ($searchValue) { return $query->orWhere('title', 'like', "%{$searchValue}%") ->orWhere('code', 'like', "%{$searchValue}%") ->orWhere('discount_type', 'like', "%{$searchValue}%"); }); }) ->when(isset($filters['added_by']) && $filters['added_by'] == 'seller', function ($query) use ($filters) { return $query->whereIn('seller_id', ['0', $filters['vendorId']]); }) ->when(isset($filters['added_by']) && $filters['added_by'] == 'admin', function ($query) use ($filters) { return $query->where(['added_by' => $filters['added_by']]); }) ->withCount('order') ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy), current($orderBy)); }); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->coupon->where('id', $id)->update($data); } public function delete(array $params): bool { return $this->coupon->where($params)->delete(); } } SocialMediaRepository.php000064400000005053150072630030011526 0ustar00socialMedia->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->socialMedia->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->socialMedia->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->socialMedia ->with($relations) ->when($searchValue, function ($query) use($searchValue){ $query->where('name', 'like', "%{$searchValue}%"); }) ->when(isset($filters['status']) , function ($query) use ($filters){ return $query->where(['status' => $filters['status']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy),current($orderBy)); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->socialMedia->where('id', $id)->update($data); } public function updateWhere(array $params, array $data): bool { $this->socialMedia->where($params)->update($data); return true; } public function delete(array $params): bool { $this->socialMedia->where($params)->delete(); return true; } } RefundRequestRepository.php000064400000007332150072630030012152 0ustar00refundRequest->where($params)->with($relations)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getList() method. } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { // TODO: Implement getListWhere() method. } public function getListWhereHas(array $orderBy = [], string $searchValue = null, array $filters = [], string $whereHas = null, array $whereHasFilters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->refundRequest->whereHas($whereHas, function ($query) use ($whereHasFilters) { return $query->when(isset($whereHasFilters['seller_is']) && $whereHasFilters['seller_is'] == 'admin', function ($query) use ($whereHasFilters) { return $query->where(['seller_is' => $whereHasFilters['seller_is']]); })->when(isset($whereHasFilters['seller_is']) && $whereHasFilters['seller_is'] == 'seller', function ($query) use ($whereHasFilters) { return $query->where(['seller_is' => $whereHasFilters['seller_is']]) ->when(isset($whereHasFilters['seller_id']), function($query) use($whereHasFilters){ return $query->where(['seller_id' => $whereHasFilters['seller_id']]); }); }); }) ->when(isset($searchValue), function ($query) use ($searchValue) { $key = explode(' ', $searchValue); $query->where(function ($subQuery) use ($key) { foreach ($key as $value) { $subQuery->orWhere('order_id', 'like', "%{$value}%") ->orWhere('id', 'like', "%{$value}%"); } }); }) ->when(isset($filters['status']), function ($query) use ($filters) { $query->where(['status' => $filters['status']]); }) ->orderBy(key($orderBy), current($orderBy)); $filters += ['searchValue' => $searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getFirstWhereHas(array $params, string $whereHas = null, array $whereHasFilters = [], array $relations = []): ?Model { return $this->refundRequest->with($relations)->whereHas($whereHas, function ($query) use ($whereHasFilters) { $query->where($whereHasFilters); })->where($params)->first(); } public function update(string $id, array $data): bool { return $this->refundRequest->find($id)->update($data); } public function delete(array $params): bool { // TODO: Implement delete() method. } } BusinessSettingRepository.php000064400000011333150072630030012503 0ustar00businessSetting->create($data); } public function getFirstWhere(array $params, array $relations = []): ?Model { return $this->businessSetting->with($relations)->where($params)->first(); } public function getList(array $orderBy = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->businessSetting->with($relations) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit); } public function getListWhere(array $orderBy = [], string $searchValue = null, array $filters = [], array $relations = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->businessSetting ->with($relations) ->when($searchValue, function ($query) use($searchValue){ $query->where('value', 'like', "%{$searchValue}%"); }) ->when(isset($filters['id']) , function ($query) use ($filters){ return $query->where(['id' => $filters['id']]); }) ->when(isset($filters['type']) , function ($query) use ($filters){ return $query->where(['type' => $filters['type']]); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { $query->orderBy(key($orderBy),current($orderBy)); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function getListWhereIn(array $orderBy = [], string $searchValue = null, array $filters = [], array $whereInFilters = [], array $relations = [], array $nullFields = [], int|string $dataLimit = DEFAULT_DATA_LIMIT, int $offset = null): Collection|LengthAwarePaginator { $query = $this->businessSetting ->with($relations)->where($filters) ->when($searchValue, function ($query) use($searchValue){ return $query->where('value', 'like', "%$searchValue%"); }) ->when(isset($filters['id']) , function ($query) use ($filters){ return $query->where(['id' => $filters['id']]); }) ->when(isset($filters['type']) , function ($query) use ($filters){ return $query->where(['type' => $filters['type']]); }) ->when(!empty($whereInFilters), function ($query) use ($whereInFilters) { foreach ($whereInFilters as $key => $filterIndex){ $query->whereIn($key , $filterIndex); } }) ->when(!empty($nullFields), function ($query) use ($nullFields) { return $query->whereNull($nullFields); }) ->when(!empty($orderBy), function ($query) use ($orderBy) { return $query->orderBy(array_key_first($orderBy),array_values($orderBy)[0]); }); $filters += ['searchValue' =>$searchValue]; return $dataLimit == 'all' ? $query->get() : $query->paginate($dataLimit)->appends($filters); } public function update(string $id, array $data): bool { return $this->businessSetting->where('id', $id)->update($data); } public function updateWhere(array $params, array $data): bool { $this->businessSetting->where($params)->update($data); return true; } public function updateOrInsert(string $type, mixed $value): bool { $this->businessSetting->updateOrInsert(['type' => $type], [ 'value' => $value, 'updated_at' => now() ]); return true; } public function whereJsonContains(array $params, array $value): ?Model { return $this->businessSetting->where($params)->whereJsonContains('value', $value)->first(); } public function delete(array $params): bool { $this->businessSetting->where($params)->delete(); return true; } }