🍲dfcv🏰dd⋉(● ∸ ●)⋊@% PNG %k25u25%fgd5n! PNG %k25u25%fgd5n!Requests/SizeChartRequest.php 0000644 00000005143 15242753104 0012343 0 ustar 00 */ public function rules() { return [ 'name' => ['required', 'max:255'], 'category_id' => ['required', 'numeric', Rule::unique('size_charts')->ignore($this->id)], 'fit_type' => ['nullable'], 'stretch_type' => ['nullable'], 'photos' => ['nullable'], 'description' => ['nullable'], 'measurement_points' => ['required'], 'size_options' => ['required'], 'measurement_option' => ['required'], 'size_chart_values.*' => ['required'] ]; } /** * Get the error messages for the defined validation rules. * * @return array */ public function messages() { return [ 'name.required' => translate('Chart Name is required'), 'name.max' => translate('Chart Name allow max 255 characters'), 'category_id.required' => translate('Category is required'), 'category_id.numeric' => translate('Category should be numeric type'), 'category_id.unique' => translate('This Category is already been taken'), 'measurement_points.required' => translate('Measurement points are required'), 'size_options.required' => translate('Size options are required'), 'measurement_option.required' => translate('Measurement Type is required'), 'size_chart_values.*.required' => translate('Size chart values are required'), ]; } protected function prepareForValidation() { $measurement_points = json_encode($this->measurement_points); $size_options = json_encode($this->size_options); $measurement_option = isset($this->measurement_option) ? json_encode($this->measurement_option) : null; $this->merge([ 'measurement_points' => $measurement_points, 'size_options' => $size_options, 'measurement_option' => $measurement_option ]); } } Requests/ZoneRequest.php 0000644 00000001347 15242753104 0011364 0 ustar 00 ['required'], 'status' => ['required'], 'country_id' => ['required'] ]; } public function prepareForValidation() { $this->merge([ 'status' => 1 ]); } } Requests/SellerRegistrationRequest.php 0000644 00000005171 15242753104 0014271 0 ustar 00 */ public function rules() { $rules = []; $rules['name'] = 'required|string|max:255'; $rules['email'] = 'required|email|unique:users|max:255'; $rules['password' ] = 'required|string|min:6|confirmed'; $rules['shop_name' ] = 'required|max:255'; $rules['address'] = 'required'; return $rules; } public function messages() { return [ 'name.required' => translate('Name is required'), 'name.string' => translate('Name should be string type'), 'name.max' => translate('Max 255 characters'), 'email.required' => translate('Email is required'), 'email.email' => translate('Please type a valid email'), 'email.unique' => translate('Email should be unique'), 'email.max' => translate('Max 255 characters'), 'password.required' => translate('Password is required'), 'password.string' => translate('Password should be string type'), 'password.min' => translate('Min 6 characters'), 'password.confirmed' => translate('Confirm password do not matched'), 'shop_name.required' => translate('Shop name is required'), 'shop_name.max' => translate('Max 255 characters'), 'address.required' => translate('Address is required'), ]; } public function failedValidation(Validator $validator) { if ($this->expectsJson()) { throw new HttpResponseException(response()->json([ 'message' => $validator->errors()->all(), 'result' => false ], 422)); } else { throw (new ValidationException($validator)) ->errorBag($this->errorBag) ->redirectTo($this->getRedirectUrl()); } } } Requests/MeasurementPointRequest.php 0000644 00000001650 15242753104 0013745 0 ustar 00 */ public function rules() { return [ 'name' => ['required', 'max:191'] ]; } /** * Get the error messages for the defined validation rules. * * @return array */ public function messages() { return [ 'name.required' => translate('Measurement Point name is required'), 'name.max' => translate('Max 191 characters for Measurement Point name'), ]; } } Requests/CustomAlertRequest.php 0000644 00000003227 15242753104 0012712 0 ustar 00 */ public function rules() { $id = $this->custom_alert ? $this->custom_alert->id : null; return [ 'type' => 'required|string|max:100', 'description' => 'required|string|max:200', 'banner' => [new RequiredIf($id != 1)], 'link' => 'required|string|max:191', 'text_color' => 'required|string|max:191', 'background_color' => 'required|string|max:191' ]; } /** * Get the error messages for the defined validation rules. * * @return array */ public function messages() { return [ 'type.required' => translate('Alert Size is required'), 'description.required' => translate('Alert Text is required'), 'banner.required' => translate('Alert image is required'), 'link.required' => translate('Link is required.'), 'text_color.required' => translate('Text Color is required.'), 'background_color.required' => translate('Background Color is required') ]; } } Requests/ProductRequest.php 0000644 00000007642 15242753104 0012075 0 ustar 00 category_ids)]; $rules['unit'] = 'sometimes|required'; $rules['min_qty'] = 'sometimes|required|numeric'; $rules['unit_price'] = 'sometimes|required|numeric|gt:0'; if ($this->get('discount_type') == 'amount') { $rules['discount'] = 'sometimes|required|numeric|lt:unit_price'; } else { $rules['discount'] = 'sometimes|required|numeric|lt:100'; } $rules['current_stock'] = 'sometimes|required|numeric'; $rules['starting_bid'] = 'sometimes|required|numeric|min:1'; $rules['auction_date_range'] = 'sometimes|required'; return $rules; } /** * Get the validation messages of rules that apply to the request. * * @return array */ public function messages() { return [ 'name.required' => translate('Product name is required'), 'category_ids.required' => translate('Product category is required'), 'category_id.required' => translate('Main Category is required'), 'category_id.in' => translate('Main Category must be within selected categories'), 'unit.required' => translate('Product unit is required'), 'min_qty.required' => translate('Minimum purchase quantity is required'), 'min_qty.numeric' => translate('Minimum purchase must be numeric'), 'unit_price.gt' => translate('The unit price must be greater than 0'), 'unit_price.required' => translate('Unit price is required'), 'unit_price.numeric' => translate('Unit price must be numeric'), 'discount.required' => translate('Discount is required'), 'discount.numeric' => translate('Discount must be numeric'), 'discount.lt' => translate('Discount should be less than unit price'), 'current_stock.required' => translate('Current stock is required'), 'current_stock.numeric' => translate('Current stock must be numeric'), 'starting_bid.required' => translate('Starting Bid is required'), 'starting_bid.numeric' => translate('Starting Bid must be numeric'), 'starting_bid.required' => translate('Minimum Starting Bid is 1'), 'auction_date_range.required' => translate('Auction Date Range is required') ]; } /** * Get the error messages for the defined validation rules.* * @return array */ public function failedValidation(Validator $validator) { // dd($this->expectsJson()); if ($this->expectsJson()) { throw new HttpResponseException(response()->json([ 'message' => $validator->errors()->all(), 'result' => false ], 422)); } else { throw (new ValidationException($validator)) ->errorBag($this->errorBag) ->redirectTo($this->getRedirectUrl()); } } } Requests/CustomerPackageRequest.php 0000644 00000002600 15242753104 0013517 0 ustar 00 */ public function rules() { return [ 'name' => 'required|string|max:255', 'amount' => 'required|numeric', 'product_upload' => 'required|numeric', 'logo' => 'required' ]; } /** * Get the error messages for the defined validation rules. * * @return array */ public function messages() { return [ 'name.required' => translate('Package Name is required'), 'amount.required' => translate('Amount is required'), 'amount.numeric' => translate('Amount must be a number.'), 'product_upload.required' => translate('Product Upload is required'), 'product_upload.numeric' => translate('Product Upload must be a number.'), 'logo.required' => translate('A logo is required') ]; } } Requests/CouponRequest.php 0000644 00000013064 15242753104 0011713 0 ustar 00 type == 'product_base' ? 'required' : 'sometimes'; $dateRule = $this->type != 'welcome_base' ? 'required' : 'sometimes'; $minBuyRule = $this->type != 'product_base' ? 'required' : 'sometimes'; $maxDiscountRule = $this->type == 'cart_base' ? 'required|numeric|min:1' : 'sometimes'; return [ 'type' => 'required', 'code' => ['required', Rule::unique('coupons')->ignore($this->coupon), 'max:255'], 'discount' => 'required|numeric|min:1', 'discount_type' => 'required', 'product_ids' => $productsRule, 'min_buy' => $minBuyRule, 'max_discount' => $maxDiscountRule, 'date_range' => 'sometimes|required', 'start_date' => $dateRule, 'end_date' => $dateRule, 'details' => 'required', 'validation_days' => 'sometimes|required|numeric' ]; } /** * Get the error messages for the defined validation rules. * * @return array */ public function messages() { return [ 'type.required' => translate('Coupon type is required'), 'code.required' => translate('Coupon code is required'), 'code.unique' => translate('Coupon already exist for this coupon code'), 'code.max' => translate('Max 255 characters'), 'product_ids.required' => translate('Product is required'), 'discount.required' => translate('Discount is required'), 'discount.numeric' => translate('Discount should be numeric type'), 'discount.min' => translate('Discount should be l or greater'), 'discount_type.required' => translate('Discount type is required'), 'min_buy.required' => translate('Minimum shopping amount is required'), 'min_buy.numeric' => translate('Minimum shopping amount should be numeric type'), 'min_buy.min' => translate('Minimum shopping amount should be l or greater'), 'max_discount.required' => translate('Max discount amount is required'), 'max_discount.numeric' => translate('Max discount amount should be numeric type'), 'max_discount.min' => translate('Max discount amount should be l or greater'), 'date_range.required' => translate('Date Range is required'), 'validation_days.required' => translate('Validation days is required'), 'validation_days.numeric' => translate('Validation days should be numeric type'), ]; } protected function prepareForValidation() { $coupon_details = null; $date_range = explode(" - ", $this->date_range); $start_date = ''; $end_date = ''; if($date_range[0]) { $start_date = strtotime($date_range[0]); $end_date = strtotime($date_range[1]); } if ($this->type == "product_base") { $coupon_details = array(); if($this->product_ids) { foreach ($this->product_ids as $product_id) { $data['product_id'] = $product_id; array_push($coupon_details, $data); } } $coupon_details = json_encode($coupon_details); } elseif ($this->type == "cart_base") { $data = array(); $data['min_buy'] = $this->min_buy; $data['max_discount'] = $this->max_discount; $coupon_details = json_encode($data); } elseif ($this->type == "welcome_base") { $data = array(); $data['min_buy'] = $this->min_buy; $data['validation_days'] = $this->validation_days; $coupon_details = json_encode($data); } $this->merge([ 'start_date' => $start_date, 'end_date' => $end_date, 'details' => $coupon_details ]); } /** * Get the error messages for the defined validation rules.* * @return array */ public function failedValidation(Validator $validator) { if ($this->expectsJson()) { throw new HttpResponseException(response()->json([ 'message' => $validator->errors()->all(), 'result' => false ], 422)); } else { throw (new ValidationException($validator)) ->errorBag($this->errorBag) ->redirectTo($this->getRedirectUrl()); } } } Requests/CarrierRequest.php 0000644 00000003175 15242753104 0012041 0 ustar 00 'required|max:255', 'transit_time' => 'required|max:255', 'delimiter1.*' => 'required', 'delimiter2.*' => 'required', 'carrier_price.*.*' => 'required', 'zones' => 'required_without:shipping_type', ]; } /** * Get the error messages for the defined validation rules. * * @return array */ public function messages() { return [ 'carrier_name.required' => translate('Carrier name is required'), 'carrier_name.max' => translate('Max 255 characters'), 'transit_time.required' => translate('Transit time is required'), 'delimiter1.*.required' => translate('Delimiter1 is required'), 'delimiter2.*.required' => translate('Delimiter2 is required'), 'carrier_price.*.*.required' => translate('Carrier price is required'), 'zones.required' => translate('Zone is required. If zone is not created, then create zone at first'), ]; } } Requests/DynamicPopupRequest.php 0000644 00000003345 15242753104 0013061 0 ustar 00 */ public function rules() { return [ 'title' => 'required|string|max:100', 'summary' => 'required|string|max:191', 'banner' => 'required', 'btn_link' => 'required|string|max:191', 'btn_text' => 'required|string|max:191', 'btn_text_color' => 'required|string|max:191', 'btn_background_color' => 'required|string|max:191' ]; } /** * Get the error messages for the defined validation rules. * * @return array */ public function messages() { return [ 'title.required' => translate('Popup title is required'), 'summary.required' => translate('Popup summary is required'), 'banner.required' => translate('Popup image is required'), 'btn_link.required' => translate('Link is required.'), 'btn_text.required' => translate('Button Text is required'), 'btn_text_color.required' => translate('Button Text Color is required.'), 'btn_background_color.required' => translate('Button Color is required') ]; } } Requests/NotificationTypeRequest.php 0000644 00000003504 15242753104 0013736 0 ustar 00 translate('Notification Type is required'), 'name.max' => translate('Name should be Max 100 character'), 'default_text.required' => translate('Default Text is required') ]; } /** * Get the error messages for the defined validation rules.* * @return array */ public function failedValidation(Validator $validator) { if ($this->expectsJson()) { throw new HttpResponseException(response()->json([ 'message' => $validator->errors()->all(), 'result' => false ], 422)); } else { throw (new ValidationException($validator)) ->errorBag($this->errorBag) ->redirectTo($this->getRedirectUrl()); } } } Requests/AttributeValueRequest.php 0000644 00000002603 15242753104 0013405 0 ustar 00 'required', 'value' => ['required', 'max:255', Rule::unique('attribute_values')->ignore($this->attribute_value)], 'color_code' => ['required_if:type,color','max:255', Rule::unique('attribute_values')->ignore($this->attribute_value)], ]; } /** * Get the error messages for the defined validation rules. * * @return array */ public function messages() { return [ 'attribute_id.required' => translate('Attribute is required'), 'value.required' => translate('Attribute value is required'), 'value.max' => translate('Max 255 characters for attribute value'), 'color_code.required_if:type' => translate('Color code is required'), ]; } } Requests/SellerProfileRequest.php 0000644 00000002600 15242753104 0013211 0 ustar 00 request->get('new_password') != null && $this->request->get('confirm_password') != null) { $newPasswordRule = ['min:6']; $newPasswordRule = ['min:6']; } return [ 'name' => ['required', 'max:191'], 'new_password' => $newPasswordRule, 'confirm_password' => $confirmPasswordRule, ]; } /** * Get the error messages for the defined validation rules. * * @return array */ public function messages() { return [ 'name.required' => translate('Name is required'), 'new_password.min' => translate('Minimum 6 characters'), 'confirm_password.min' => translate('Minimum 6 characters'), ]; } } Requests/CartRequest.php 0000644 00000001022 15242753104 0011330 0 ustar 00 */ public function rules() { return [ // ]; } } Resources/V2/ShopDetailsCollection.php 0000644 00000005626 15242753104 0013765 0 ustar 00 $this->id, 'user_id' => intval($this->user_id) , 'name' => $this->name, 'title' => $this->meta_title, 'description' => $this->meta_description, 'delivery_pickup_latitude' => $this->delivery_pickup_latitude, 'delivery_pickup_longitude' => $this->delivery_pickup_longitude, 'logo' => uploaded_asset($this->logo), 'package_invalid_at' => $this->package_invalid_at??"", 'product_upload_limit' => $this->product_upload_limit, 'seller_package' => $this->seller_package->name??"", 'seller_package_img' =>uploaded_asset($this->seller_package->logo??"") , 'upload_id' => $this->logo, 'sliders' => get_images_path($this->sliders), 'sliders_id' => $this->sliders, 'address' => $this->address, 'admin_to_pay' => format_price( $this->admin_to_pay), 'phone' => $this->phone, 'facebook' => $this->facebook, 'google' => $this->google, 'twitter' => $this->twitter, 'instagram' => $this->instagram, 'youtube' => $this->youtube, 'cash_on_delivery_status' => $this->cash_on_delivery_status, 'bank_payment_status' => $this->bank_payment_status, 'bank_name' => $this->bank_name, 'bank_acc_name' => $this->bank_acc_name, 'bank_acc_no' => $this->bank_acc_no, 'bank_routing_no' => $this->bank_routing_no, 'rating' => (double) $this->rating, 'verified'=> $this->verification_status==1, 'is_submitted_form'=> $this->verification_info !=null, 'verified_img'=> $this->verification_status==1?static_asset("assets/img/verified.png"):static_asset("assets/img/non_verified.png"), 'verify_text'=> $this->verification_status==1?translate("Verified seller"):translate("Non-Verified seller"), 'email'=> $this->user->email, 'products'=> $this->user->products()->count(), 'orders'=> $this->user->seller_orders()->where("delivery_status","delivered")->count(), 'sales'=>format_price( $this->user->seller_sales()->where("payment_status","paid")->sum('price'),true), ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } protected function convertPhotos($data){ $result = array(); foreach ($data as $key => $item) { array_push($result, uploaded_asset($item)); } return $result; } } Resources/V2/GeneralSettingCollection.php 0000644 00000002071 15242753104 0014450 0 ustar 00 $this->collection->map(function($data) { return [ 'logo' => $data->logo, 'site_name' => $data->site_name, 'address' => $data->address, 'description' => $data->description, 'phone' => $data->phone, 'email' => $data->email, 'facebook' => $data->facebook, 'twitter' => $data->twitter, 'instagram' => $data->instagram, 'youtube' => $data->youtube, 'google_plus' => $data->google_plus ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/UserCollection.php 0000644 00000002064 15242753104 0012455 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => (integer) $data->id, 'name' => $data->name, 'type' => $data->user_type, 'email' => $data->email, 'avatar' => $data->avatar, 'avatar_original' => uploaded_asset($data->avatar_original), 'address' => $data->address, 'city' => $data->city, 'country' => $data->country, 'postal_code' => $data->postal_code, 'phone' => $data->phone ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/ProductMiniCollection.php 0000644 00000002766 15242753104 0014005 0 ustar 00 $this->collection->map(function ($data) { $wholesale_product = ($data->wholesale_product == 1) ? true : false; return [ 'id' => $data->id, 'slug' => $data->slug, 'name' => $data->getTranslation('name'), 'slug' => $data->slug, 'thumbnail_image' => uploaded_asset($data->thumbnail_img), 'has_discount' => home_base_price($data, false) != home_discounted_base_price($data, false), 'discount' => "-" . discount_in_percentage($data) . "%", 'stroked_price' => home_base_price($data), 'main_price' => home_discounted_base_price($data), 'rating' => (float) $data->rating, 'sales' => (int) $data->num_of_sale, 'is_wholesale' => $wholesale_product, 'links' => [ 'details' => route('products.show', $data->id), ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/SettingsCollection.php 0000644 00000003533 15242753104 0013341 0 ustar 00 $this->collection->map(function($data) { return [ 'name' => $data->name, 'logo' => $data->logo, 'facebook' => $data->facebook, 'twitter' => $data->twitter, 'instagram' => $data->instagram, 'youtube' => $data->youtube, 'google_plus' => $data->google_plus, 'currency' => [ 'name' => Currency::findOrFail(BusinessSetting::where('type', 'system_default_currency')->first()->value)->name, 'symbol' => Currency::findOrFail(BusinessSetting::where('type', 'system_default_currency')->first()->value)->symbol, 'exchange_rate' => (double) $this->exchangeRate(Currency::findOrFail(BusinessSetting::where('type', 'system_default_currency')->first()->value)), 'code' => Currency::findOrFail(BusinessSetting::where('type', 'system_default_currency')->first()->value)->code ], 'currency_format' => $data->currency_format ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } public function exchangeRate($currency){ $base_currency = Currency::find(BusinessSetting::where('type', 'system_default_currency')->first()->value); return $currency->exchange_rate/$base_currency->exchange_rate; } } Resources/V2/ClubpointCollection.php 0000644 00000002230 15242753104 0013471 0 ustar 00 $this->collection->map(function ($data) { $points = number_format($data->points, 2, '.', ''); $points = floatval($points); return [ 'id' => (int) $data->id, 'user_id' => (int) $data->user_id, 'order_code' => $data->order == null ? translate("Order not found") : $data->order->code, 'convertible_club_point' => $data->club_point_details->where('refunded', 0)->sum('point'), 'points' => floatval($points), 'convert_status' => (int) $data->convert_status, 'date' => date('d-m-Y', strtotime($data->created_at)), ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/CartCollection.php 0000644 00000002331 15242753104 0012425 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => $data->id, 'seller_id' => $data->seller_id, 'product' => [ 'name' => $data->product->name, 'image' => uploaded_asset($data->product->thumbnail_img) ], 'variation' => $data->variation, 'price' => (double) cart_product_price($data, $data->product, false, false), 'tax' => (double)cart_product_tax($data, $data->product ,false), 'shipping_cost' => (double) $data->shipping_cost, 'quantity' => (integer) $data->quantity, 'date' => $data->created_at->diffForHumans() ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/FollowSellerResource.php 0000644 00000001442 15242753104 0013643 0 ustar 00 $this->shop->id, 'shop_slug' => $this->shop->slug, 'shop_name' => $this->shop->name, 'shop_url' => $this->shop->slug, 'shop_rating' => $this->shop->rating, 'shop_num_of_reviews' => $this->shop->num_of_reviews, 'shop_logo' => uploaded_asset($this->shop->logo), ]; } } Resources/V2/PickupPointResource.php 0000644 00000001713 15242753104 0013500 0 ustar 00 $this->id, "staff_id" => $this->staff_id, "name" => $this->name, "address" => $this->address, "phone" => $this->phone, "pick_up_status" => $this->pick_up_status, "cash_on_pickup_status" => $this->cash_on_pickup_status, ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/NotificationCollection.php 0000644 00000002414 15242753104 0014164 0 ustar 00 $this->collection->map(function($data) { $notificationType = get_notification_type($data->notification_type_id, 'id'); $notifyContent = $notificationType->getTranslation('default_text'); if ($data->type == 'App\Notifications\OrderNotification'){ $notifyContent = str_replace('[[order_code]]', $data->data['order_code'], $notifyContent); } return [ 'id' => $data->id, "isChecked" => false, 'type' => $data->type, 'data' => $data->data, 'notification_text' => $notifyContent, 'image' => uploaded_asset($notificationType->image), 'date' => date("F j Y, g:i a", strtotime($data->created_at)) ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/UploadedFileCollection.php 0000644 00000001572 15242753104 0014077 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => $data->id, 'file_original_name' =>$data->file_original_name, 'file_name' => $data->file_name, 'url' => uploaded_asset($data->id), 'file_size' => $data->file_size, 'extension' => $data->extension, 'type' => $data->type ]; }) ]; } public function with($request) { return [ 'result' => true, 'status' => 200 ]; } } Resources/V2/CouponCollection.php 0000644 00000005410 15242753104 0013000 0 ustar 00 $this->collection->map(function ($data) { $coupon_products_details = []; $order_discount_details = null; $user_type = $data->user->user_type; $shop = $data->user->shop; if ($data->type == 'product_base') { $products = json_decode($data->details); foreach ($products as $key => $product) { array_push($coupon_products_details, (object)[ 'product_id' => $product->product_id, // 'thumbnail_img' => uploaded_asset($product->thumbnail_img), ]); } } else { $order_discount_details = json_decode($data->details); $arr['min_buy'] = single_price(intval($order_discount_details->min_buy)); $arr['max_discount'] = $order_discount_details->max_discount; $order_discount_details = $arr; } $shop_name = $user_type == 'admin' ? get_setting('website_name') : ( $shop->name ?? ''); if ($user_type == 'admin' || ($shop != null && $shop->verification_status)) { return [ 'id' => (int)$data->id, 'user_type' => $user_type, 'shop_id' => $shop->id ?? '', 'shop_name' => translate($shop_name), 'shop_slug' => $shop->slug ?? '', 'coupon_type' => $data->type, 'code' => $data->code, 'discount' => $data->discount_type == 'percent' ? $data->discount : single_price($data->discount), 'coupon_product_details' => $coupon_products_details, 'coupon_discount_details' => $order_discount_details, 'discount_type' => $data->discount_type, 'start_date' => $data->start_date, 'end_date' => $data->end_date, ]; } }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/CustomerCollection.php 0000644 00000002355 15242753104 0013343 0 ustar 00 $this->collection->map(function($data) { return [ 'name' => $data->name, 'email' => $data->email, 'avatar' => uploaded_asset($data->avatar), 'address' => $data->address??"", 'country' => $data->country??"", 'state' => $data->state??"", 'city' => $data->city??"", 'postal_code' => $data->postal_code??"", 'phone' =>$data->phone??"", 'balance' =>single_price($data->balance), 'remaining_uploads' => $data->remaining_uploads, 'package_id' => $data->customer_package_id??"", 'package_name' => $data->customer_package->name??"", ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/StatesCollection.php 0000644 00000001236 15242753104 0013002 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => (int) $data->id, 'country_id' => (int) $data->country_id, 'name' => $data->name, ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/AuctionProductDetailCollection.php 0000644 00000010021 15242753104 0015615 0 ustar 00 $this->collection->map(function ($data) { //photos $photo_paths = get_images_path($data->photos); $photos = []; if (!empty($photo_paths)) { for ($i = 0; $i < count($photo_paths); $i++) { if ($photo_paths[$i] != "") { $item = array(); $item['variant'] = ""; $item['path'] = $photo_paths[$i]; $photos[] = $item; } } } //branc $brand = [ 'id' => 0, 'slug' => "", 'name' => "", 'logo' => "", ]; if ($data->brand != null) { $brand = [ 'id' => $data->brand->id, 'id' => $data->brand->slug, 'name' => $data->brand->getTranslation('name'), 'logo' => uploaded_asset($data->brand->logo), ]; } $unit = ''; if ($data->unit != null) { $unit = $data->getTranslation('unit'); } // highest bids $highest_bid = $data->bids->max('amount'); return [ 'id' => (int)$data->id, 'name' => $data->getTranslation('name'), 'added_by' => $data->added_by, 'seller_id' => $data->user->id, 'shop_id' => $data->added_by == 'admin' ? 0 : $data->user->shop->id, 'shop_slug' => $data->added_by == 'admin' ? '' : $data->user->shop->slug, 'shop_name' => $data->added_by == 'admin' ? translate('In House Product') : $data->user->shop->name, 'shop_logo' => $data->added_by == 'admin' ? uploaded_asset(get_setting('header_logo')) : uploaded_asset($data->user->shop->logo) ?? "", 'photos' => $photos, 'thumbnail_image' => uploaded_asset($data->thumbnail_img), 'tags' => explode(',', $data->tags), 'rating' => (float)$data->rating, 'rating_count' => (int)Review::where(['product_id' => $data->id])->count(), 'brand' => $brand, // "auction_end_date" => $data->auction_end_date > strtotime('now') ? date('Y/m/d H:i:s', $data->auction_end_date) : 'Ended', "auction_end_date" => $data->auction_end_date > strtotime('now') ? $data->auction_end_date : 'Ended', "starting_bid" => single_price($data->starting_bid), 'unit' => $unit, 'min_bid_price' => $highest_bid != null ? ($highest_bid + 1) : $data->starting_bid, 'highest_bid' => $highest_bid != null ? single_price($highest_bid) : '', 'description' => str_replace(' ', ' ', strip_tags($data->getTranslation('description'))), 'video_link' => $data->video_link != null ? $data->video_link : "", 'link' => route('product', $data->slug) // 'data' => $data ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/PosProductCollection.php 0000644 00000001452 15242753104 0013641 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => $data->id, 'name' => $data->name, 'variant_product' => $data->variant_product, 'thumbnail_image' => uploaded_asset($data->thumbnail_img), 'price' => single_price($data->unit_price) ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/WishlistCollection.php 0000644 00000002031 15242753104 0013337 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => (integer) $data->id, 'product' => [ 'id' => $data->product->id, 'name' => $data->product->name, 'slug' => $data->product->slug, 'thumbnail_image' => uploaded_asset($data->product->thumbnail_img), 'base_price' => format_price(home_base_price($data->product, false)) , 'rating' => (double) $data->product->rating, ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/Seller/CategoriesCollection.php 0000644 00000001765 15242753104 0015061 0 ustar 00 (int) $this->id, 'parent_id' => $this->parent_id, 'level' => $this->level, 'name' =>$this->name, 'banner' =>uploaded_asset($this->banner), 'icon' => uploaded_asset($this->icon), 'featured' =>$this->featured==0?false:true, 'digital' =>$this->digital==0?false:true, 'child' => ChildCategoriesCollection::collection( $this->childrenCategories) ]; } } Resources/V2/Seller/CustomerCollection.php 0000644 00000001134 15242753104 0014563 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => $data->id, 'name' => $data->name ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/Seller/CartCollection.php 0000644 00000002235 15242753104 0013656 0 ustar 00 $this->collection->map(function ($data) { $stock = $data->product->stocks->where('variant', $data['variation'])->first(); return [ 'id' => $data->id, 'stock_id' => $stock->id, 'product_name' => $data->product->getTranslation('name'), 'variation' => $data->variation, 'price' => cart_product_price($data, $data->product, true, false), 'tax' => cart_product_tax($data, $data->product, true), 'cart_quantity' => (int) $data->quantity, 'min_purchase_qty' => $data->product->min_qty, 'stock_qty' => $stock->qty ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/Seller/AttributeCollection.php 0000644 00000001134 15242753104 0014725 0 ustar 00 (int) $this->id, 'name' =>$this->name, 'values' => $this->attribute_values ]; } } Resources/V2/Seller/OrderDetailResource.php 0000644 00000002770 15242753104 0014663 0 ustar 00 shipping_address); return [ 'order_code' => $this->code, 'total' => format_price($this->grand_total), 'order_date' => date('d-m-Y', strtotime($this->created_at)), 'payment_status' => $this->payment_status, 'payment_type' => ucwords(str_replace('_', ' ', $this->payment_type)), 'delivery_status' => $this->delivery_status, 'shipping_type' => $this->shipping_type, 'payment_method' => $this->payment_type, 'shipping_address' => $shipping_address, 'shipping_cost' => format_price($this->orderDetails->sum('shipping_cost')), 'subtotal' => format_price($this->orderDetails->sum('price')), 'coupon_discount' => format_price($this->coupon_discount), 'tax' => format_price($this->orderDetails->sum('tax')), 'order_items' => OrderItemResource::collection($this->orderDetails) ]; } } Resources/V2/Seller/SellerWithdrawResource.php 0000644 00000001402 15242753104 0015414 0 ustar 00 status == 0) { $status = translate('Pending'); } return [ 'id' => $this->id, 'amount' => format_price($this->amount), 'status' => $status, 'created_at' => date('d-m-Y', strtotime($this->created_at)), ]; } } Resources/V2/Seller/ChildCategoriesCollection.php 0000644 00000002006 15242753104 0016012 0 ustar 00 (int) $this->id, 'parent_id' => $this->parent_id, 'level' => $this->level, 'name' =>$this->name, 'banner' =>uploaded_asset($this->banner), 'icon' => uploaded_asset($this->icon), 'featured' =>$this->featured==0?false:true, 'digital' =>$this->digital==0?false:true, 'child' => $this->categories?ChildCategoriesCollection::collection($this->categories):[] ]; } } Resources/V2/Seller/CommissionHistoryResource.php 0000644 00000001534 15242753104 0016164 0 ustar 00 order)){ $order_code = $this->order->code; } return [ 'id' => $this->id, 'order_code' => $order_code, 'admin_commission' => $this->admin_commission, 'seller_earning' => format_price($this->seller_earning), 'created_at' => date('d-m-Y', strtotime($this->created_at)), ]; } } Resources/V2/Seller/StockCollection.php 0000644 00000002040 15242753104 0014042 0 ustar 00 $this->collection->map(function ($data) { return [ "id" => (int) $data->id, "product_id" => $data->product_id, "variant" => $data->variant, "sku" => $data->sku, "price" => $data->price, "qty" => $data->qty, "image" =>new UploadedFileCollection(Upload::where("id",$data->image)->get()) ]; }), ]; } } Resources/V2/Seller/ProductReviewCollection.php 0000644 00000002101 15242753104 0015557 0 ustar 00 $this->collection->map( function ($data){ return [ "id"=> (int) $data->id, "rating"=>(int) $data->rating, "comment"=> $data->comment, "status"=>(int) $data->status, "updated_at"=> $data->updated_at, "product_name"=> $data->product_name, "user_id"=>(int) $data->user_id, "name"=> $data->name, "avatar"=> $data->avatar ]; }), ]; } } Resources/V2/Seller/ConversationCollection.php 0000644 00000002751 15242753104 0015442 0 ustar 00 $this->collection->map(function ($data) { $seen_status = false; if ( (auth()->user()->id == $data->sender_id && $data->sender_viewed == 0) || (auth()->user()->id == $data->receiver_id && $data->receiver_viewed == 0) ) { $seen_status = true; } if (auth()->user()->id == $data->sender_id) { $image = uploaded_asset($data->receiver->avatar_original); $name = $data->receiver->name; } else { $image = uploaded_asset($data->sender->avatar_original); $name = $data->sender->name; } return [ 'id' => $data->id, 'image' => $image, 'name' => $name, 'title' => $data->title, 'is_seen' => $seen_status, ]; }) ]; } } Resources/V2/Seller/AuctionProductCollection.php 0000644 00000002421 15242753104 0015725 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'name' => $data->getTranslation('name'), 'thumbnail_image' => uploaded_asset($data->thumbnail_img), 'main_price' => single_price($data->starting_bid), 'start_date' => date('Y-m-d H:i:s', $data->auction_start_date), 'end_date' => date('Y-m-d H:i:s', $data->auction_end_date), 'total_bids' => (int) $data->bids->count(), 'can_edit' => $data->auction_start_date > strtotime("now"), 'links' => [ 'details' => route('products.show', $data->id), ] ]; }) ]; } } Resources/V2/Seller/ProductQueryResource.php 0000644 00000002035 15242753104 0015125 0 ustar 00 $this->id, "user_name" => $this->user ? $this->user->name : 'Customer Not found', "user_image" => $this->user ? uploaded_asset($this->user->avatar_original) : static_asset('assets/img/placeholder.jpg'), "question" => $this->question, "reply" => $this->reply ?? '', "product" => $this->product ? $this->product->name : 'Product Not found', "status" => $this->reply == null ? translate('Not Replied') : translate('Replied'), "created_at" => $this->created_at->diffForHumans() ]; } } Resources/V2/Seller/AuctionProductBidCollection.php 0000644 00000002233 15242753104 0016345 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'customer_name' => $data->user->name, 'customer_email' => $data->user->email ?? '', 'customer_phone' => $data->user->phone ?? '', 'bidded_amout' => format_price($data->amount), // 'date' => date("d-m-Y", $this->created_at), 'date' => $data->created_at->format('d-m-Y'), ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/Seller/ConversationMessageCollection.php 0000644 00000002074 15242753104 0016745 0 ustar 00 user != null){ $image = uploaded_asset($this->user->avatar_original); } if($this->user->id == auth()->user->id) { $is_seller_message = true; } return [ 'image' => $image, 'id' => $this->user->id, 'name' => $this->user->name, 'message' => $this->message, 'is_seller_message' => $is_seller_message, 'created_at' => $this->created_at, ]; } } Resources/V2/Seller/ColorCollection.php 0000644 00000001112 15242753104 0014034 0 ustar 00 (int) $this->id, 'name' =>$this->name, 'code' => $this->code ]; } } Resources/V2/Seller/BrandCollection.php 0000644 00000001132 15242753104 0014006 0 ustar 00 (int) $this->id, 'name' =>$this->name, 'icon' => uploaded_asset($this->logo) ]; } } Resources/V2/Seller/ProductCollection.php 0000644 00000002376 15242753104 0014413 0 ustar 00 $this->collection->map(function ($data) { $qty = 0; foreach ($data->stocks as $key => $stock) { $qty += $stock->qty; } return [ 'id' => $data->id, 'name' => $data->name, 'thumbnail_img' => uploaded_asset($data->thumbnail_img), 'price' => format_price($data->unit_price), 'current_stock' => $qty, 'status' => $data->published == 0 ? false : true, 'category' => $data->main_category ? $data->main_category->getTranslation('name') : "", 'featured' => $data->seller_featured == 0 ? false : true, ]; }), ]; } } Resources/V2/Seller/DigitalProductCollection.php 0000644 00000002101 15242753104 0015673 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'name' => $data->getTranslation('name'), 'thumbnail_img' => uploaded_asset($data->thumbnail_img), 'category' => $data->main_category ? $data->main_category->getTranslation('name') : "", 'price ' => $data->unit_price, 'status' => $data->published == 0 ? false : true, 'featured' => $data->seller_featured == 0 ? false : true ]; }) ]; } } Resources/V2/Seller/CouponResource.php 0000644 00000002405 15242753104 0013723 0 ustar 00 type == 'product_base') { $decoded_product = Arr::pluck(json_decode($this->details, true), 'product_id'); $products = filter_products(Product::whereIn('id', $decoded_product))->get(); } // dd(json_encode(new ProductCollection($products))); return [ 'id' =>(int) $this->id, 'type' => $this->type, 'code' => $this->code, 'details' => ($this->type == 'product_base') ?json_encode( new ProductCollection($products)) : $this->details, 'discount' =>(float) $this->discount, 'discount_type' => $this->discount_type, 'start_date' => date('d/m/Y', $this->start_date), 'end_date' => date('d/m/Y', $this->end_date), ]; } } Resources/V2/Seller/DigitalProductDetailsResource.php 0000644 00000004372 15242753104 0016711 0 ustar 00 $this->id, 'lang' => $this->lang, 'product_name' => $this->getTranslation('name', $this->lang), "category_id" => $this->category_id, "category_ids" => $this->categories()->pluck('category_id')->toArray(), "product_file" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->file_name))->get()), "tags" => $this->tags, "photos" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->photos))->get()), "thumbnail_img" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->thumbnail_img))->get()), "meta_title" => $this->meta_title, "meta_description" => $this->meta_description, "meta_img" => new UploadedFileCollection(Upload::where("id", $this->meta_img)->get()), "slug" => $this->slug, "unit_price" => $this->unit_price, "purchase_price" => $this->purchase_price, "tax" => $this->taxes, "discount" => $this->discount, "discount_type" => $this->discount_type, "discount_start_date" => date("Y-m-d", $this->discount_start_date), "discount_end_date" => date("Y-m-d", $this->discount_end_date), "description" => $this->getTranslation('description', $this->lang), ]; } public function with($request) { return [ 'result' => true, 'status' => 200 ]; } } Resources/V2/Seller/SellerPaymentResource.php 0000644 00000001637 15242753104 0015252 0 ustar 00 payment_method)); if ($this->txn_code != null) { $payment_method = ucfirst(str_replace('_', ' ', $this->payment_method)). ' ' .translate('TRX ID'). ':' .$this->txn_code; } return [ 'id' => $this->id, 'amount' => format_price($this->amount), 'payment_method' => $payment_method, 'payment_date' => date('d-m-Y', strtotime($this->created_at)), ]; } } Resources/V2/Seller/SellerPackageResource.php 0000644 00000001671 15242753104 0015166 0 ustar 00 (int) $this->id, 'name' => $this->getTranslation('name'), 'logo' => uploaded_asset($this->logo), 'product_upload_limit' =>(int) $this->product_upload_limit, 'amount' => ($this->amount > 0) ? single_price($this->amount) : translate('Free'), 'price' => (double) $this->amount, 'duration' =>(int) $this->duration, ]; } } Resources/V2/Seller/WholesaleProductDetailsCollection.php 0000644 00000007654 15242753104 0017571 0 ustar 00 $this->id, 'lang' => $this->lang, 'product_name' => $this->getTranslation('name', $this->lang), 'product_unit' => $this->getTranslation('unit', $this->lang), 'description' => $this->getTranslation('description', $this->lang), "category_id" => $this->category_id, "category_ids" => $this->categories()->pluck('category_id')->toArray(), "brand_id" => $this->brand_id, "photos" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->photos))->get()), "thumbnail_img" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->thumbnail_img))->get()), "video_provider" => $this->video_provider, "video_link" => $this->video_link, "tags" => $this->tags, "unit_price" => $this->unit_price, "purchase_price" => $this->purchase_price, "variant_product" => $this->variant_product, "attributes" => json_decode($this->attributes), "choice_options" => json_decode($this->choice_options), "colors" => json_decode($this->colors), "variations" => $this->variations, "stocks" => new StockCollection($this->stocks), "todays_deal" => $this->todays_deal, "published" => $this->published, "approved" => $this->approved, "stock_visibility_state" => $this->stock_visibility_state, "cash_on_delivery" => $this->cash_on_delivery, "featured" => $this->featured, "seller_featured" => $this->seller_featured, "current_stock" => $this->current_stock, "weight" => $this->weight, "min_qty" => $this->min_qty, "low_stock_quantity" => $this->low_stock_quantity, "discount" => $this->discount, "discount_type" => $this->discount_type, "discount_start_date" => date("Y-m-d", $this->discount_start_date), "discount_end_date" => date("Y-m-d", $this->discount_end_date), "tax" => $this->taxes, "tax_type" => $this->tax_type, "shipping_type" => $this->shipping_type, "shipping_cost" => $this->shipping_cost, "is_quantity_multiplied" => $this->is_quantity_multiplied, "est_shipping_days" => $this->est_shipping_days, "num_of_sale" => $this->num_of_sale, "meta_title" => $this->meta_title, "meta_description" => $this->meta_description, "meta_img" => new UploadedFileCollection(Upload::where("id", $this->meta_img)->get()), "pdf" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->pdf))->get()), "slug" => $this->slug, "barcode" => $this->barcode, "file_name" => $this->file_name, "file_path" => $this->file_path, "external_link" => $this->external_link, "refundable" => $this->refundable, "external_link_btn" => $this->external_link_btn, "wholesale_prices" => WholesalePrice::where('product_stock_id', $this->stocks->first()->id)->get(), ]; } public function with($request) { return [ 'result' => true, 'status' => 200 ]; } } Resources/V2/Seller/ConversationResource.php 0000644 00000001505 15242753104 0015132 0 ustar 00 sender->avatar_original)); $image=""; $name=""; if (auth()->user()->id == $this->sender_id) { $image = uploaded_asset($this->receiver->avatar_original); $name = $this->receiver->name; } else { $image = $this->sender ? uploaded_asset($this->sender->avatar_original) : ''; $name = $this->sender ? $this->sender->name : ''; } return [ 'id' => $this->id, 'image' => $image, 'name' => $name, 'title' => $this->title, ]; } } Resources/V2/Seller/ProductDetailsCollection.php 0000644 00000010007 15242753104 0015707 0 ustar 00 $this->id, 'lang' => $this->lang, 'product_name' => $this->getTranslation('name', $this->lang), 'product_unit' => $this->getTranslation('unit', $this->lang), 'description' => $this->getTranslation('description', $this->lang), "category_id" => $this->category_id, "category_ids" => $this->categories()->pluck('category_id')->toArray(), "brand_id" => $this->brand_id, "photos" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->photos))->get()), "thumbnail_img" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->thumbnail_img))->get()), "video_provider" => $this->video_provider, "video_link" => $this->video_link, "tags" => $this->tags, "unit_price" => $this->unit_price, "purchase_price" => $this->purchase_price, "variant_product" => $this->variant_product, "attributes" => json_decode($this->attributes), "choice_options" => json_decode($this->choice_options), "colors" => json_decode($this->colors), "variations" => $this->variations, "stocks" => new StockCollection($this->stocks), "todays_deal" => $this->todays_deal, "published" => $this->published, "approved" => $this->approved, "stock_visibility_state" => $this->stock_visibility_state, "cash_on_delivery" => $this->cash_on_delivery, "featured" => $this->featured, "seller_featured" => $this->seller_featured, "current_stock" => $this->current_stock, "weight" => $this->weight, "min_qty" => $this->min_qty, "low_stock_quantity" => $this->low_stock_quantity, "discount" => $this->discount, "discount_type" => $this->discount_type, "discount_start_date" => date("Y-m-d", $this->discount_start_date), "discount_end_date" => date("Y-m-d", $this->discount_end_date), "tax" => $this->taxes, "tax_type" => $this->tax_type, "shipping_type" => $this->shipping_type, "shipping_cost" => $this->shipping_cost, "is_quantity_multiplied" => $this->is_quantity_multiplied, "est_shipping_days" => $this->est_shipping_days, "num_of_sale" => $this->num_of_sale, "meta_title" => $this->meta_title, "meta_description" => $this->meta_description, "meta_img" => new UploadedFileCollection(Upload::where("id", $this->meta_img)->get()), "pdf" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->pdf))->get()), "slug" => $this->slug, "rating" => $this->rating, "barcode" => $this->barcode, "digital" => $this->digital, "auction_product" => $this->auction_product, "file_name" => $this->file_name, "file_path" => $this->file_path, "external_link" => $this->external_link, "external_link_btn" => $this->external_link_btn, "wholesale_product" => $this->wholesale_product, "created_at" => $this->created_at, "updated_at" => $this->updated_at, ]; } public function with($request) { return [ 'result' => true, 'status' => 200 ]; } } Resources/V2/Seller/TaxCollection.php 0000644 00000001027 15242753104 0013517 0 ustar 00 (int) $this->id, 'name' =>$this->name ]; } } Resources/V2/Seller/AuctionProductDetailsResource.php 0000644 00000005263 15242753104 0016736 0 ustar 00 $this->id, 'lang' => $this->lang, 'product_name' => $this->getTranslation('name', $this->lang), "category_id" => $this->category_id, "category_ids" => $this->categories()->pluck('category_id')->toArray(), "brand_id" => $this->brand_id, 'product_unit' => $this->getTranslation('unit', $this->lang), "weight" => $this->weight, "tags" => $this->tags, "photos" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->photos))->get()), "thumbnail_img" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->thumbnail_img))->get()), "video_provider" => $this->video_provider, "video_link" => $this->video_link, "starting_bid" => $this->starting_bid, "auction_start_date" => date("Y-m-d", $this->auction_start_date), "auction_end_date" => date("Y-m-d", $this->auction_end_date), 'description' => $this->getTranslation('description', $this->lang), "shipping_type" => $this->shipping_type, "shipping_cost" => $this->shipping_cost, "cash_on_delivery" => $this->cash_on_delivery, "est_shipping_days" => $this->est_shipping_days, "tax" => $this->taxes, "tax_type" => $this->tax_type, "pdf" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $this->pdf))->get()), "meta_title" => $this->meta_title, "meta_description" => $this->meta_description, "meta_img" => new UploadedFileCollection(Upload::where("id", $this->meta_img)->get()), "slug" => $this->slug, ]; } public function with($request) { return [ 'result' => true, 'status' => 200 ]; } } Resources/V2/Seller/OrderItemResource.php 0000644 00000001455 15242753104 0014356 0 ustar 00 quantity; if($this->variation) { $description = $this->quantity. ' x '. $this->variation; } return [ 'name' => optional($this->product)->name, 'description' => $description, 'delivery_status' => $this->delivery_status, 'price' => format_price($this->price), ]; } } Resources/V2/Seller/ProductResource.php 0000644 00000000705 15242753104 0014101 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'order_code' => $data->code, 'total' => format_price($data->grand_total), 'order_date' => date('d-m-Y', strtotime($data->created_at)), 'payment_status' => $data->payment_status, 'delivery_status' => join(" ", explode('_', $data->delivery_status)), ]; }) ]; } } Resources/V2/ProductDetailCollection.php 0000644 00000013665 15242753104 0014313 0 ustar 00 $this->collection->map(function ($data) { $precision = 2; $calculable_price = home_discounted_base_price($data, false); $calculable_price = number_format($calculable_price, $precision, '.', ''); $calculable_price = floatval($calculable_price); // $calculable_price = round($calculable_price, 2); $photo_paths = get_images_path($data->photos); $photos = []; if (!empty($photo_paths)) { for ($i = 0; $i < count($photo_paths); $i++) { if ($photo_paths[$i] != "") { $item = array(); $item['variant'] = ""; $item['path'] = $photo_paths[$i]; $photos[] = $item; } } } foreach ($data->stocks as $stockItem) { if ($stockItem->image != null && $stockItem->image != "") { $item = array(); $item['variant'] = $stockItem->variant; $item['path'] = uploaded_asset($stockItem->image); $photos[] = $item; } } $brand = [ 'id' => 0, 'name' => "", 'slug' => "", 'logo' => "", ]; if ($data->brand != null) { $brand = [ 'id' => $data->brand->id, 'slug' => $data->brand->slug, 'name' => $data->brand->getTranslation('name'), 'logo' => uploaded_asset($data->brand->logo), ]; } $whole_sale = []; if (addon_is_activated('wholesale')) { $whole_sale = ProductWholesaleResource::collection($data->stocks->first()->wholesalePrices); } return [ 'id' => (int)$data->id, 'name' => $data->getTranslation('name'), 'added_by' => $data->added_by, 'seller_id' => $data->user->id, 'shop_id' => $data->added_by == 'admin' ? 0 : $data->user->shop->id, 'shop_slug' => $data->added_by == 'admin' ? '' : $data->user->shop->slug, 'shop_name' => $data->added_by == 'admin' ? translate('In House Product') : $data->user->shop->name, 'shop_logo' => $data->added_by == 'admin' ? uploaded_asset(get_setting('header_logo')) : uploaded_asset($data->user->shop->logo) ?? "", 'photos' => $photos, 'thumbnail_image' => uploaded_asset($data->thumbnail_img), 'tags' => explode(',', $data->tags), 'price_high_low' => (float)explode('-', home_discounted_base_price($data, false))[0] == (float)explode('-', home_discounted_price($data, false))[1] ? format_price((float)explode('-', home_discounted_price($data, false))[0]) : "From " . format_price((float)explode('-', home_discounted_price($data, false))[0]) . " to " . format_price((float)explode('-', home_discounted_price($data, false))[1]), 'choice_options' => $this->convertToChoiceOptions(json_decode($data->choice_options)), 'colors' => json_decode($data->colors) ?? [], 'has_discount' => home_base_price($data, false) != home_discounted_base_price($data, false), 'discount' => "-" . discount_in_percentage($data) . "%", 'stroked_price' => home_base_price($data), 'main_price' => home_discounted_base_price($data), 'calculable_price' => $calculable_price, 'currency_symbol' => currency_symbol(), 'current_stock' => (int)$data->stocks->first()->qty, 'unit' => $data->unit ?? "", 'rating' => (float)$data->rating, 'rating_count' => (int)Review::where(['product_id' => $data->id])->count(), 'earn_point' => (float)$data->earn_point, 'description' => $data->getTranslation('description'), 'downloads' => $data->pdf ? uploaded_asset($data->pdf) : null, 'video_link' => $data->video_link != null ? $data->video_link : "", 'brand' => $brand, 'link' => route('product', $data->slug), 'wholesale' => $whole_sale, 'est_shipping_time' => (int)$data->est_shipping_days, ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } protected function convertToChoiceOptions($data) { $result = array(); if ($data) { foreach ($data as $key => $choice) { $item['name'] = $choice->attribute_id; $item['title'] = Attribute::find($choice->attribute_id)->getTranslation('name'); $item['options'] = $choice->values; array_push($result, $item); } } return $result; } protected function convertPhotos($data) { $result = array(); foreach ($data as $key => $item) { array_push($result, uploaded_asset($item)); } return $result; } } Resources/V2/WalletCollection.php 0000644 00000001633 15242753104 0012770 0 ustar 00 $this->collection->map(function ($data) { return [ 'amount' => single_price(($data->amount)), 'payment_method' => ucwords(str_replace('_', ' ', $data->payment_method)), 'approval_string' => $data->offline_payment ? ($data->approval == 1 ? "Approved" : "Pending") : "N/A", 'date' => Carbon::createFromTimestamp(strtotime($data->created_at))->format('d-m-Y'), ]; }) ]; } public function with($request) { return [ 'result' => true, 'status' => 200 ]; } } Resources/V2/SliderCollection.php 0000644 00000001220 15242753104 0012752 0 ustar 00 $this->collection->map(function ($data) { //dd($data); return [ 'photo' => uploaded_asset($data['image']), 'url' => ($data['link']), ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/BusinessSettingCollection.php 0000644 00000001243 15242753104 0014666 0 ustar 00 $this->collection->map(function($data) { return [ 'type' => $data->type, 'value' => $data->type == 'verification_form' ? json_decode($data->value) : $data->value ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/SubCategoryCollection.php 0000644 00000001434 15242753104 0013766 0 ustar 00 $this->collection->map(function($data) { return [ 'name' => $data->name, 'subSubCategories' => new SubSubCategoryCollection($data->subSubCategories), 'links' => [ 'products' => route('products.subCategory', $data->id) ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/ShopCollection.php 0000644 00000001715 15242753104 0012452 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'slug' => $data->slug, 'name' => $data->name, 'logo' => uploaded_asset($data->logo), 'rating' => $data->rating, ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } protected function convertPhotos($data) { $result = array(); foreach ($data as $key => $item) { array_push($result, uploaded_asset($item)); } return $result; } } Resources/V2/CountriesCollection.php 0000644 00000001304 15242753104 0013506 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => (int) $data->id, 'code' => $data->code, 'name' => $data->name, 'status' => (int) $data->status, ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/DeliveryHistoryCollection.php 0000644 00000002132 15242753104 0014700 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'delivery_boy_id' => $data->delivery_boy_id, 'order_id' => $data->order_id, 'order_code' => $data->order->code, 'delivery_status' => $data->delivery_status, 'earning' => format_price($data->earning) , 'collection' => format_price($data->collection), 'payment_type' => $data->payment_type, 'date' => Carbon::createFromTimestamp($data->created_at)->format('d-m-Y'), ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/DigitalProductDetailCollection.php 0000644 00000007312 15242753104 0015601 0 ustar 00 $this->collection->map(function ($data) { $precision = 2; $calculable_price = home_discounted_base_price($data, false); $calculable_price = number_format($calculable_price, $precision, '.', ''); $calculable_price = floatval($calculable_price); $photo_paths = get_images_path($data->photos); $photos = []; if (!empty($photo_paths)) { for ($i = 0; $i < count($photo_paths); $i++) { if ($photo_paths[$i] != "" ) { $item = array(); $item['variant'] = ""; $item['path'] = $photo_paths[$i]; $photos[]= $item; } } } foreach ($data->stocks as $stockItem){ if($stockItem->image != null && $stockItem->image != ""){ $item = array(); $item['variant'] = $stockItem->variant; $item['path'] = uploaded_asset($stockItem->image) ; $photos[]= $item; } } return [ 'id' => (integer)$data->id, 'name' => $data->getTranslation('name'), 'added_by' => $data->added_by, 'seller_id' => $data->user->id, 'shop_id' => $data->added_by == 'admin' ? 0 : $data->user->shop->id, 'shop_name' => $data->added_by == 'admin' ? translate('In House Product') : $data->user->shop->name, 'shop_logo' => $data->added_by == 'admin' ? uploaded_asset(get_setting('header_logo')) : uploaded_asset($data->user->shop->logo)??"", 'photos' => $photos, 'thumbnail_image' => uploaded_asset($data->thumbnail_img), 'tags' => explode(',', $data->tags), 'price_high_low' => (double)explode('-', home_discounted_base_price($data, false))[0] == (double)explode('-', home_discounted_price($data, false))[1] ? format_price((double)explode('-', home_discounted_price($data, false))[0]) : "From " . format_price((double)explode('-', home_discounted_price($data, false))[0]) . " to " . format_price((double)explode('-', home_discounted_price($data, false))[1]), 'has_discount' => home_base_price($data, false) != home_discounted_base_price($data, false), 'stroked_price' => home_base_price($data), 'main_price' => home_discounted_base_price($data), 'calculable_price' => $calculable_price, 'currency_symbol' => currency_symbol(), 'rating' => (double)$data->rating, 'rating_count' => (integer)Review::where(['product_id' => $data->id])->count(), 'earn_point' => (double)$data->earn_point, 'description' => $data->getTranslation('description'), 'video_link' => $data->video_link != null ? $data->video_link : "", 'link' => route('product', $data->slug) ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/HomeCategoryCollection.php 0000644 00000001722 15242753104 0014125 0 ustar 00 $this->collection->map(function($data) { return [ 'name' => $data->category->getTranslation('name'), 'banner' => uploaded_asset($data->category->banner), 'icon' => uploaded_asset($data->category->icon), 'links' => [ 'products' => route('api.products.category', $data->category->id), 'sub_categories' => route('subCategories.index', $data->category->id) ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/ReviewCollection.php 0000644 00000001574 15242753104 0013005 0 ustar 00 $this->collection->map(function($data) { return [ 'user_id'=> $data->user->id, 'user_name'=> $data->user->name, 'avatar'=> uploaded_asset($data->user->avatar_original), 'rating' => floatval(number_format($data->rating,1,'.','')), 'comment' => $data->comment, 'time' => $data->updated_at->diffForHumans() ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/PolicyCollection.php 0000644 00000001061 15242753104 0012772 0 ustar 00 $this->collection->map(function($data) { return [ 'content' => $data->content ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/LastViewedProductCollection.php 0000644 00000003065 15242753104 0015151 0 ustar 00 $this->collection->map(function ($data) { $product = $data->product; $wholesale_product = ($product->wholesale_product == 1) ? true : false; return [ 'id' => $product->id, 'slug' => $product->slug, 'name' => $product->getTranslation('name'), 'thumbnail_image' => $product->thumbnail_img == null ? "" : uploaded_asset($product->thumbnail_img), 'has_discount' => home_base_price($product, false) != home_discounted_base_price($product, false), 'discount' => "-" . discount_in_percentage($product) . "%", 'stroked_price' => home_base_price($product), 'main_price' => home_discounted_base_price($product), 'rating' => (float) $product->rating, 'sales' => (int) $product->num_of_sale, 'is_wholesale' => $wholesale_product, 'links' => [ 'details' => route('products.show', $product->id), ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/PurchasedResource.php 0000644 00000001117 15242753104 0013147 0 ustar 00 $this->id, 'name'=> $this->getTranslation('name'), 'thumbnail_image' => uploaded_asset($this->thumbnail_img), ]; } } Resources/V2/FlashDealCollection.php 0000644 00000002147 15242753104 0013364 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'slug' => $data->slug, 'title' => $data->title, 'date' => (int) $data->end_date, 'banner' => uploaded_asset($data->banner), 'products' => new FlashDealProductCollection($data->flash_deal_products()->take(6)->get()) ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/PurchaseHistoryItemsCollection.php 0000644 00000007234 15242753104 0015701 0 ustar 00 $this->collection->map(function ($data) { $refund_section = false; $refund_button = false; $refund_label = ""; $refund_request_status = 99; if (addon_is_activated('refund_request')) { $refund_section = true; $no_of_max_day = get_setting('refund_request_time'); $last_refund_date = Carbon::parse($data->order->delivered_date)->addDays($no_of_max_day); $today_date = Carbon::now(); if ( $data->product != null && $data->product->refundable != 0 && $data->refund_request == null && $today_date <= $last_refund_date && $data->payment_status == 'paid' && $data->delivery_status == 'delivered' ) { $refund_button = true; } else if ($data->refund_request != null && $data->refund_request->refund_status == 0) { $refund_label = "Pending"; $refund_request_status = $data->refund_request->refund_status; } else if ($data->refund_request != null && $data->refund_request->refund_status == 2) { $refund_label = "Rejected"; $refund_request_status = $data->refund_request->refund_status; } else if ($data->refund_request != null && $data->refund_request->refund_status == 1) { $refund_label = "Approved"; $refund_request_status = $data->refund_request->refund_status; } else if ($data->product->refundable != 0) { $refund_label = "N/A"; } else { $refund_label = "Non-refundable"; } } return [ 'id' => $data->id, 'product_id' => $data->product->id, 'product_name' => $data->product->name, 'variation' => $data->variation, 'price' => format_price(convert_price($data->price)), 'tax' => format_price(convert_price($data->tax)), 'shipping_cost' => format_price(convert_price($data->shipping_cost)), 'coupon_discount' => format_price(convert_price($data->coupon_discount)), 'quantity' => (int)$data->quantity, 'payment_status' => $data->payment_status, 'payment_status_string' => ucwords(str_replace('_', ' ', $data->payment_status)), 'delivery_status' => $data->delivery_status, 'delivery_status_string' => $data->delivery_status == 'pending' ? "Order Placed" : ucwords(str_replace('_', ' ', $data->delivery_status)), 'refund_section' => $refund_section, 'refund_button' => $refund_button, 'refund_label' => $refund_label, 'refund_request_status' => $refund_request_status, ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/CustomerPackageResource.php 0000644 00000001560 15242753104 0014310 0 ustar 00 (int) $this->id, 'name' => $this->getTranslation('name'), 'logo' => uploaded_asset($this->logo), 'product_upload_limit' =>(int) $this->product_upload, 'amount' => ($this->amount > 0) ? single_price($this->amount) : translate('Free'), 'price' => (double) $this->amount, ]; } } Resources/V2/LanguageCollection.php 0000644 00000001762 15242753104 0013266 0 ustar 00 $this->collection->map(function($data) { return [ 'id' =>(int) $data->id, 'name' => translate($data->name), 'code' => $data->code, 'mobile_app_code' => $data->app_lang_code, 'rtl' => $data->rtl == 1, 'is_default' => env("DEFAULT_LANGUAGE",'en') == $data->code, 'image' => static_asset('assets/img/flags/'.$data->code.'.png') , ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/ProductCollection.php 0000644 00000003326 15242753104 0013161 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'slug' => $data->slug, 'name' => $data->getTranslation('name'), 'photos' => explode(',', $data->photos), 'thumbnail_image' => uploaded_asset($data->thumbnail_img), 'base_price' => (float) home_base_price($data, false), 'base_discounted_price' => (float) home_discounted_base_price($data, false), 'todays_deal' => (int) $data->todays_deal, 'featured' => (int) $data->featured, 'unit' => $data->unit, 'discount' => (float) $data->discount, 'discount_type' => $data->discount_type, 'rating' => (float) $data->rating, 'sales' => (int) $data->num_of_sale, 'links' => [ 'details' => route('products.show', $data->id), 'reviews' => route('api.reviews.index', $data->id), 'related' => route('products.related', $data->id), 'top_from_seller' => route('products.topFromSeller', $data->id) ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/PurchaseHistoryCollection.php 0000644 00000005175 15242753104 0014701 0 ustar 00 $this->collection->map(function ($data) { $pickup_point = null; if ($data->shipping_type == 'pickup_point' && $data->pickup_point_id) { $pickup_point = $data->pickup_point; } return [ 'id' => $data->id, 'code' => $data->code, 'user_id' => (int) $data->user_id, 'shipping_address' => json_decode($data->shipping_address), 'payment_type' => ucwords(str_replace('_', ' ',translate( $data->payment_type))), 'pickup_point' => $pickup_point, 'shipping_type' => $data->shipping_type, 'shipping_type_string' => $data->shipping_type != null ? ucwords(str_replace('_', ' ', translate($data->shipping_type))) : "", 'payment_status' => $data->payment_status, 'payment_status_string' => ucwords(str_replace('_', ' ', translate($data->payment_status))), 'delivery_status' => $data->delivery_status, 'delivery_status_string' => $data->delivery_status == translate('pending') ? translate("Order Placed") : ucwords(str_replace('_', ' ', translate($data->delivery_status))), 'grand_total' => format_price(convert_price($data->grand_total)), 'plane_grand_total' => $data->grand_total, 'coupon_discount' => format_price(convert_price($data->coupon_discount)), 'shipping_cost' => format_price(convert_price($data->orderDetails->sum('shipping_cost'))), 'subtotal' => format_price(convert_price($data->orderDetails->sum('price'))), 'tax' => format_price(convert_price($data->orderDetails->sum('tax'))), 'date' => Carbon::createFromTimestamp($data->date)->format('d-m-Y'), 'cancel_request' => $data->cancel_request == 1, 'manually_payable' => $data->manual_payment && $data->manual_payment_data == null, 'links' => [ 'details' => '' ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/ClassifiedProductDetailCollection.php 0000644 00000007463 15242753104 0016301 0 ustar 00 $this->collection->map(function ($data) { $photo_paths = get_images_path($data->photos); $photos = []; if (!empty($photo_paths)) { for ($i = 0; $i < count($photo_paths); $i++) { if ($photo_paths[$i] != "") { $item = array(); $item['variant'] = ""; $item['path'] = $photo_paths[$i]; $photos[] = $item; } } } $brand = [ 'id' => 0, 'slug' => "", 'name' => "", 'logo' => "", ]; if ($data->brand != null) { $brand = [ 'id' => $data->brand->id, 'slug' => $data->brand->slug, 'name' => $data->brand->getTranslation('name'), 'logo' => uploaded_asset($data->brand->logo), ]; } return [ 'id' => (int)$data->id, 'name' => $data->getTranslation('name'), 'added_by' => $data->user->name, 'phone' => $data->user->phone ?? "", 'condition' => $data->conditon, 'photos' =>new UploadedFileCollection(Upload::whereIn("id", explode(",", $data->photos))->get()), 'thumbnail_image' => new UploadedFileCollection(Upload::whereIn("id", explode(",", $data->thumbnail_img))->get()), 'tags' => explode(',', $data->tags), 'location' => $data->location, 'unit_price' => single_price($data->unit_price), 'unit' => $data->unit ?? "", 'description' => $data->getTranslation('description'), 'video_link' => $data->video_link != null ? $data->video_link : "", 'brand' => $brand, 'category' => $data->category->getTranslation('name'), 'link' => route("customer.product", $data->slug), 'meta_title' => $data->meta_title, 'meta_description' => $data->meta_description, 'meta_image' =>new UploadedFileCollection(Upload::whereIn("id", explode(",", $data->meta_img))->get()), "pdf" => new UploadedFileCollection(Upload::whereIn("id", explode(",", $data->pdf))->get()), ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } protected function convertToChoiceOptions($data) { $result = array(); if ($data) { foreach ($data as $key => $choice) { $item['name'] = $choice->attribute_id; $item['title'] = Attribute::find($choice->attribute_id)->getTranslation('name'); $item['options'] = $choice->values; array_push($result, $item); } } return $result; } protected function convertPhotos($data) { $result = array(); foreach ($data as $key => $item) { array_push($result, uploaded_asset($item)); } return $result; } } Resources/V2/Auction/AuctionPurchaseHistory.php 0000644 00000001627 15242753104 0015610 0 ustar 00 id); return [ 'id' => $order->id, 'code' => $order->code, 'date' => date('d-m-Y', $order->date), 'amount' => single_price($order->grand_total), 'delivery_status' => translate(ucfirst(str_replace('_', ' ', $order->orderDetails->first()->delivery_status))), 'payment_status' => $order->payment_status == 'paid' ? translate('Paid') : translate('Unpaid'), ]; } } Resources/V2/Auction/AuctionBidProducts.php 0000644 00000003324 15242753104 0014672 0 ustar 00 bids->where('user_id', auth()->id())->first(); $highest_bid = $this->bids->max('amount'); $order_detail = OrderDetail::where('product_id', $this->id)->first(); if ($order_detail != null) { $order = Order::where('id', $order_detail->order_id)->where('user_id', auth()->id())->first(); } if ($my_bided_product->product->auction_end_date < strtotime("now") && $my_bided_product->amount == $highest_bid && $order == null) { $action = 'Buy'; $isBuyable = true; } elseif ($order != null) { $action = 'Purchased'; } else { $action = 'N/A'; } return [ 'id' => $this->id, 'name' => $this->name, 'thumbnail_image' => uploaded_asset($this->thumbnail_img), 'my_bid' => single_price($my_bided_product->amount), 'highest_bid' => single_price($highest_bid), 'auction_end_date' => $this->auction_end_date < strtotime("now") ? translate('Ended') : date('d.m.Y H:i:s', $this->auction_end_date), 'action' => $action, 'isBuyable' => $isBuyable, ]; } } Resources/V2/RefundRequestCollection.php 0000644 00000003275 15242753104 0014340 0 ustar 00 $this->collection->map(function ($data) { $refund_label = ''; if($data->refund_status == 1) { $refund_label = 'Approved'; } elseif($data->refund_status == 2) { $refund_label = 'Rejected'; }else { $refund_label = 'PENDING'; } return [ 'id' => (int)$data->id, 'user_id' => (int)$data->user_id, 'order_code' => $data->order == null ? translate("Order not found") : $data->order->code, 'product_name' => $data->orderDetail != null && $data->orderDetail->product != null ? $data->orderDetail->product->getTranslation('name', 'en') : "", 'product_price' => $data->orderDetail != null ? single_price($data->orderDetail->price) : "", 'refund_status' => (int) $data->refund_status, 'refund_label' => $refund_label, 'seller_approval' => $data->seller_approval, 'reject_reason' => $data->reject_reason, 'reason' => $data->reason, 'date' => date('d-m-Y', strtotime($data->created_at)), ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/CategoryCollection.php 0000644 00000002642 15242753104 0013316 0 ustar 00 $this->collection->map(function ($data) { $banner = ''; if (uploaded_asset($data->banner)) { $banner = uploaded_asset($data->banner); } $icon = ''; if (uploaded_asset(uploaded_asset($data->icon))) { $icon = uploaded_asset($data->icon); } return [ 'id' => $data->id, 'slug' => $data->slug, 'name' => $data->getTranslation('name'), 'banner' => $banner, 'icon' => $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 ]; } } Resources/V2/SearchProductCollection.php 0000644 00000002340 15242753104 0014302 0 ustar 00 $this->collection->map(function($data) { return [ 'name' => $data->name, 'thumbnail_image' => uploaded_asset($data->thumbnail_img), 'base_price' => (double) home_base_price($data, false), 'base_discounted_price' => (double) home_discounted_base_price($data, false), 'rating' => (double) $data->rating, 'links' => [ 'details' => route('products.show', $data->id), 'reviews' => route('api.reviews.index', $data->id), 'related' => route('products.related', $data->id), 'top_from_seller' => route('products.topFromSeller', $data->id) ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/AddressCollection.php 0000644 00000003247 15242753104 0013130 0 ustar 00 $this->collection->map(function($data) { $location_available = false; $lat = 90.99; $lang = 180.99; if($data->latitude || $data->longitude) { $location_available = true; $lat = floatval($data->latitude) ; $lang = floatval($data->longitude); } return [ 'id' =>(int) $data->id, 'user_id' =>(int) $data->user_id, 'address' => $data->address, 'country_id' => (int) $data->country_id, 'state_id' => (int) $data->state_id, 'city_id' => (int) $data->city_id, 'country_name' => $data->country->name, 'state_name' => $data->state->name, 'city_name' => $data->city->name, 'postal_code' => $data->postal_code, 'phone' => $data->phone, 'set_default' =>(int) $data->set_default, 'location_available' => $location_available, 'lat' => $lat, 'lang' => $lang, ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/FlashDealProductCollection.php 0000644 00000001733 15242753104 0014725 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => $data->product_id, 'name' => $data->product->name, 'image' => uploaded_asset($data->product->thumbnail_img), 'price' => home_discounted_base_price($data->product), 'links' => [ 'details' => route('products.show', $data->product_id), ] ]; }) ]; } } Resources/V2/MessageCollection.php 0000644 00000002374 15242753104 0013127 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => $data->id, 'user_id' => intval($data->user_id), 'send_type' => $data->user->user_type, 'message' => $data->message, 'year' => Carbon::createFromFormat('Y-m-d H:i:s',$data->created_at)->format('Y'), 'month' => Carbon::createFromFormat('Y-m-d H:i:s',$data->created_at)->format('m'), 'day_of_month' => Carbon::createFromFormat('Y-m-d H:i:s',$data->created_at)->format('d-M'), 'date' => Carbon::createFromFormat('Y-m-d H:i:s',$data->created_at)->format('F d, Y'), 'time' => Carbon::createFromFormat('Y-m-d H:i:s',$data->created_at)->format('h:i a'), ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/CarrierCollection.php 0000644 00000002442 15242753104 0013126 0 ustar 00 ownerId = $owner_id; $this->carts = $carts; $this->shipping_info = $shipping_info; return $this; } public function toArray($request) { return [ 'data' => $this->collection->map(function($data) { return [ 'id' => $data->id, 'name' => $data->name, 'logo' => uploaded_asset($data->logo), 'transit_time' => (integer) $data->transit_time, 'free_shipping' => $data->free_shipping == 1 ? true : false, 'transit_price' => single_price(carrier_base_price($this->carts, $data->id, $this->ownerId, $this->shipping_info)), ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/BannerCollection.php 0000644 00000001211 15242753104 0012735 0 ustar 00 $this->collection->map(function($data) { return [ 'photo' => uploaded_asset($data), 'url' => route('home'), 'position' => 1 ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/AuctionMiniCollection.php 0000644 00000002456 15242753104 0013763 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'slug' => $data->slug, 'name' => $data->getTranslation('name'), 'thumbnail_image' => uploaded_asset($data->thumbnail_img), 'has_discount' => home_base_price($data, false) != home_discounted_base_price($data, false), // 'discount' => "-" . discount_in_percentage($data) . "%", // 'stroked_price' => home_base_price($data), 'main_price' => single_price($data->starting_bid), 'rating' => (float) $data->rating, 'sales' => (int) $data->num_of_sale, 'links' => [ 'details' => route('products.show', $data->id), ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/CitiesCollection.php 0000644 00000001304 15242753104 0012753 0 ustar 00 $this->collection->map(function($data) { return [ 'id' =>(int) $data->id, 'state_id' => (int) $data->state_id, 'name' => $data->name, 'cost' => $data->cost, ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/ClassifiedProductMiniCollection.php 0000644 00000002113 15242753104 0015756 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'slug' => $data->slug, 'name' => $data->getTranslation('name'), 'thumbnail_image' => uploaded_asset($data->thumbnail_img), 'condition' => $data->conditon, 'unit_price' => single_price($data->unit_price), 'category' => $data->category->getTranslation('name'), 'published' => $data->published == 1 ? true : false, 'status' => $data->status == 1 ? true : false, ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/ProductWholesaleResource.php 0000644 00000001334 15242753104 0014516 0 ustar 00 $this->id, // 'product_stock_id' => $this->product_stock_id, 'min_qty' => (int)$this->min_qty, 'max_qty' => (int) $this->max_qty, 'price' => single_price($this->price) ]; } } Resources/V2/ConversationCollection.php 0000644 00000002456 15242753104 0014216 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => $data->id, 'receiver_id' => intval($data->receiver_id) , 'receiver_type'=> $data->receiver->user_type, 'shop_id' => $data->receiver->user_type == 'admin' ? 0 : $data->receiver->shop->id, 'shop_name' => $data->receiver->user_type == 'admin' ? 'In House Product' : $data->receiver->shop->name, 'shop_logo' => $data->receiver->user_type == 'admin' ? uploaded_asset(get_setting('header_logo')) : uploaded_asset($data->receiver->shop->logo), 'title'=> $data->title, 'sender_viewed'=> intval($data->sender_viewed), 'receiver_viewed'=> intval($data->receiver_viewed), 'date'=> $data->updated_at, ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/CurrencyCollection.php 0000644 00000001533 15242753104 0013331 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => $data->id, 'name' => $data->name, 'code' => $data->code, 'symbol' => $data->symbol, 'exchange_rate' => (double) $data->exchange_rate, 'is_default' => get_setting('system_default_currency')==$data->id?true:false ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/DeliveryBoyCollection.php 0000644 00000001366 15242753104 0014000 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'user_id' => $data->user_id, 'total_collection' => $data->total_collection, 'total_earning' => $data->total_earning, ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/ColorCollection.php 0000644 00000001126 15242753104 0012613 0 ustar 00 $this->collection->map(function($data) { return [ 'name' => $data->name, 'code' => $data->code ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/DeliveryBoyPurchaseHistoryMiniCollection.php 0000644 00000006654 15242753104 0017677 0 ustar 00 $this->collection->map(function($data) { $delivery_pickup_latitude = 90.99; $delivery_pickup_longitude = 180.99; $store_location_available = false; if($data->shop && $data->shop->delivery_pickup_latitude) { $store_location_available = true; $delivery_pickup_latitude = floatval($data->shop->delivery_pickup_latitude); $delivery_pickup_longitude = floatval($data->shop->delivery_pickup_longitude); } if(!$data->shop) { $store_location_available = true; if(get_setting('delivery_pickup_latitude') && get_setting('delivery_pickup_longitude')) { $delivery_pickup_latitude = floatval(get_setting('delivery_pickup_latitude')); $delivery_pickup_longitude = floatval(get_setting('delivery_pickup_longitude')); } } $shipping_address = json_decode($data->shipping_address,true); $location_available = false; $lat = 90.99; $lang = 180.99; if(isset($shipping_address['lat_lang'])){ $location_available = true; $exploded_lat_lang = explode(',',$shipping_address['lat_lang']); $lat = floatval($exploded_lat_lang[0]); $lang = floatval($exploded_lat_lang[1]); } return [ 'id' => $data->id, 'code' => $data->code, 'user_id' => intval($data->user_id), 'payment_type' => ucwords(str_replace('_', ' ', translate($data->payment_type))) , 'payment_status' => $data->payment_status, 'payment_status_string' => ucwords(str_replace('_', ' ', $data->payment_status)), 'delivery_status' => $data->delivery_status, 'delivery_status_string' => $data->delivery_status == 'pending'? "Order Placed" : ucwords(str_replace('_', ' ', $data->delivery_status)), 'grand_total' => format_price($data->grand_total) , 'date' => Carbon::createFromFormat('Y-m-d H:i:s',$data->delivery_history_date)->format('d-m-Y'), 'cancel_request' => $data->cancel_request == 1, 'delivery_history_date' => $data->delivery_history_date, 'location_available' => $location_available, 'lat' => $lat, 'lang' => $lang, 'store_location_available' => $store_location_available, 'delivery_pickup_latitude' => $delivery_pickup_latitude, 'delivery_pickup_longitude' => $delivery_pickup_longitude, 'links' => [ 'details' => "" ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/SubSubCategoryCollection.php 0000644 00000001300 15242753104 0014430 0 ustar 00 $this->collection->map(function($data) { return [ 'name' => $data->name, 'links' => [ 'products' => route('products.subSubCategory', $data->id) ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/BrandCollection.php 0000644 00000001525 15242753104 0012566 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'slug' => $data->slug, 'name' => $data->getTranslation('name'), 'logo' => uploaded_asset($data->logo), 'links' => [ 'products' => route('api.products.brand', $data->id) ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/V2/PurchaseHistoryMiniCollection.php 0000644 00000002753 15242753104 0015515 0 ustar 00 $this->collection->map(function ($data) { return [ 'id' => $data->id, 'code' => $data->code, 'user_id' => intval($data->user_id), 'payment_type' => ucwords(str_replace('_', ' ', $data->payment_type)), 'payment_status' => translate($data->payment_status), 'payment_status_string' => ucwords(str_replace('_', ' ', translate($data->payment_status))), 'delivery_status' => translate($data->delivery_status), 'delivery_status_string' => $data->delivery_status == translate('pending') ? translate("Order Placed") : ucwords(str_replace('_', ' ', translate($data->delivery_status))), 'grand_total' => format_price(convert_price($data->grand_total)), 'date' => Carbon::createFromTimestamp($data->date)->format('d-m-Y'), 'links' => [ 'details' => '' ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } Resources/PosProductCollection.php 0000644 00000002136 15242753104 0013352 0 ustar 00 $this->collection->map(function($data) { return [ 'id' => $data->id, 'stock_id' => $data->stock_id, 'name' => $data->name, 'thumbnail_image' => ($data->stock_image == null) ? uploaded_asset($data->thumbnail_img) : uploaded_asset($data->stock_image), 'price' => home_discounted_base_price_by_stock_id($data->stock_id), 'base_price' => home_base_price_by_stock_id($data->stock_id), 'qty' => $data->stock_qty, 'variant' => $data->variant, 'digital' => $data->digital, ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } } ViewComposers/CategoryComposer.php 0000644 00000001014 15242753104 0013346 0 ustar 00 with('coverImage'); $categories = $categories_query->where('level', 0)->orderBy('order_level', 'desc')->get(); $view->with(['categories' => $categories]); } } ViewComposers/CartComposer.php 0000644 00000001244 15242753104 0012467 0 ustar 00 user() != null) { $carts = Cart::where('user_id', auth()->user()->id)->get(); } else { $temp_user_id = Session()->get('temp_user_id'); if ($temp_user_id) { $carts = Cart::where('temp_user_id', $temp_user_id)->get(); } } $view->with(['carts' => $carts]); } } Controllers/RoleController.php 0000644 00000010307 15242753104 0012534 0 ustar 00 middleware(['permission:view_staff_roles'])->only('index'); $this->middleware(['permission:add_staff_role'])->only('create'); $this->middleware(['permission:edit_staff_role'])->only('edit'); $this->middleware(['permission:delete_staff_role'])->only('destroy'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $roles = Role::where('id', '!=', 1)->paginate(10); return view('backend.staff.staff_roles.index', compact('roles')); // $roles = Role::paginate(10); // return view('backend.staff.staff_roles.index', compact('roles')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('backend.staff.staff_roles.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // dd($request->permissions); $role = Role::create(['name' => $request->name]); $role->givePermissionTo($request->permissions); $role_translation = RoleTranslation::firstOrNew(['lang' => env('DEFAULT_LANGUAGE'), 'role_id' => $role->id]); $role_translation->name = $request->name; $role_translation->save(); flash(translate('New Role has been added successfully'))->success(); return redirect()->route('roles.index'); } /** * 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(Request $request, $id) { $lang = $request->lang; $role = Role::findOrFail($id); return view('backend.staff.staff_roles.edit', compact('role', 'lang')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $role = Role::findOrFail($id); if ($request->lang == env("DEFAULT_LANGUAGE")) { $role->name = $request->name; } $role->syncPermissions($request->permissions); $role->save(); // Role Translation $role_translation = RoleTranslation::firstOrNew(['lang' => $request->lang, 'role_id' => $role->id]); $role_translation->name = $request->name; $role_translation->save(); flash(translate('Role has been updated successfully'))->success(); return back(); // return redirect()->route('roles.index'); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { if(env('DEMO_MODE') == 'On'){ flash(translate('Data can not change in demo mode.'))->info(); return back(); } RoleTranslation::where('role_id', $id)->delete(); Role::destroy($id); flash(translate('Role has been deleted successfully'))->success(); return redirect()->route('roles.index'); } public function add_permission(Request $request) { $permission = Permission::create(['name' => $request->name, 'section' => $request->parent]); return redirect()->route('roles.index'); } public function create_admin_permissions() { } } Controllers/CustomAlertController.php 0000644 00000007455 15242753104 0014107 0 ustar 00 middleware(['permission:view_all_custom_alerts'])->only('index'); $this->middleware(['permission:add_custom_alerts'])->only('create'); $this->middleware(['permission:edit_custom_alerts'])->only('edit'); $this->middleware(['permission:delete_custom_alerts'])->only('destroy'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $sort_search = null; $custom_alerts = CustomAlert::orderBy('id', 'asc'); if ($request->has('search')){ $sort_search = $request->search; $custom_alerts = $custom_alerts->where('description', 'like', '%'.$sort_search.'%'); } $custom_alerts = $custom_alerts->paginate(15); return view('backend.marketing.custom_alert.index', compact('custom_alerts', 'sort_search')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('backend.marketing.custom_alert.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(CustomAlertRequest $request) { CustomAlert::create($request->except('_token')); flash(translate('Custom Alert has been inserted successfully'))->success(); return redirect()->route('custom-alerts.index'); } /** * 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(CustomAlert $custom_alert) { return view('backend.marketing.custom_alert.edit', compact('custom_alert')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(CustomAlertRequest $request, CustomAlert $custom_alert) { $custom_alert->update($request->except(['_token','_method'])); flash(translate('Custom Alert has been updated successfully'))->success(); return redirect()->route('custom-alerts.index'); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { if ($id == 1) { flash(translate('This Custom Alert cannot be deleted'))->error(); return redirect()->route('custom-alerts.index'); } CustomAlert::destroy($id); flash(translate('Custom Alert has been deleted successfully'))->success(); return redirect()->route('custom-alerts.index'); } public function bulk_custom_alerts_delete(Request $request) { CustomAlert::whereIn('id', $request->id)->delete(); return 1; } public function update_status(Request $request) { $custom_alert = CustomAlert::findOrFail($request->id); $custom_alert->status = $request->status; if($custom_alert->save()){ return 1; } return 0; } } Controllers/CustomerController.php 0000644 00000016452 15242753104 0013443 0 ustar 00 middleware(['permission:view_all_customers'])->only('index'); $this->middleware(['permission:add_customer'])->only('create'); $this->middleware(['permission:login_as_customer'])->only('login'); $this->middleware(['permission:ban_customer'])->only('ban'); $this->middleware(['permission:delete_customer'])->only('destroy'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $sort_search = null; $verification_status = $request->verification_status ?? null; $users = User::where('user_type', 'customer')->orderBy('created_at', 'desc'); if($verification_status != null){ $users = $verification_status == 'verified' ? $users->where('email_verified_at', '!=', null) : $users->where('email_verified_at', null); } if ($request->has('search')){ $sort_search = $request->search; $users->where(function ($q) use ($sort_search){ $q->where('name', 'like', '%'.$sort_search.'%')->orWhere('email', 'like', '%'.$sort_search.'%'); }); } $users = $users->paginate(15); return view('backend.customer.customers.index', compact('users', 'sort_search', 'verification_status')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('backend.customer.customers.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $request->validate( ['name' => 'required|max:255',], ['name.required' => translate('Name is required'),'name.max' => translate('Max 255 Character'),] ); // Phone & email both can't be null if($request->email == null && $request->phone == null){ flash(translate('Email and phone number both can not be null.'))->error(); return back(); } if (filter_var($request->email, FILTER_VALIDATE_EMAIL)) { if(User::where('email', $request->email)->first() != null){ flash(translate('Email already exists.'))->error(); return back(); } } elseif (User::where('phone', '+'.$request->country_code.$request->phone)->first() != null) { flash(translate('Phone already exists.'))->error(); return back(); } $password = substr(hash('sha512', rand()), 0, 8); $email = null; $phone = null; // Register By email if (filter_var($request->email, FILTER_VALIDATE_EMAIL)) { $email = $request->email; $user = User::create([ 'name' => $request->name, 'email' => $email, 'password' => Hash::make($password), ]); // Account Opening Email to customer try { EmailUtility::customer_registration_email('registration_from_system_email_to_customer', $user, $password); } catch (\Exception $e) { $user->delete(); flash(translate('Registration failed. Please try again later.'))->error(); return back(); } // Email Verification mail to Customer if(get_setting('email_verification') != 1){ $user->email_verified_at = date('Y-m-d H:m:s'); $user->save(); offerUserWelcomeCoupon(); } else { EmailUtility::email_verification($user, 'customer'); } flash(translate('Registration successful.'))->success(); } // Register by phone else { if (addon_is_activated('otp_system')){ $phone = '+'.$request->country_code.$request->phone; $user = User::create([ 'name' => $request->name, 'phone' => $phone, 'password' => Hash::make($password), 'verification_code' => rand(100000, 999999) ]); $otpController = new OTPVerificationController; $otpController->account_opening($user, $password); flash(translate('Registration successful.'))->success(); } } // Customer Account Opening Email to Admin if ((get_email_template_data('customer_reg_email_to_admin', 'status') == 1)) { try { EmailUtility::customer_registration_email('customer_reg_email_to_admin', $user, null); } catch (\Exception $e) {} } 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) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $customer = User::findOrFail($id); $customer->customer_products()->delete(); User::destroy($id); flash(translate('Customer has been deleted successfully'))->success(); return redirect()->route('customers.index'); } public function bulk_customer_delete(Request $request) { if($request->id) { foreach ($request->id as $customer_id) { $customer = User::findOrFail($customer_id); $customer->customer_products()->delete(); $this->destroy($customer_id); } } return 1; } public function login($id) { $user = User::findOrFail(decrypt($id)); auth()->login($user, true); return redirect()->route('dashboard'); } public function ban($id) { $user = User::findOrFail(decrypt($id)); if($user->banned == 1) { $user->banned = 0; flash(translate('Customer UnBanned Successfully'))->success(); } else { $user->banned = 1; flash(translate('Customer Banned Successfully'))->success(); } $user->save(); return back(); } } Controllers/SizeChartController.php 0000644 00000016617 15242753104 0013541 0 ustar 00 middleware(['permission:view_measurement_points'])->only('index'); $this->middleware(['permission:edit_size_charts'])->only('edit'); $this->middleware(['permission:delete_size_charts'])->only('destroy'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $sizeCharts = SizeChart::orderBy('created_at', 'desc')->paginate(15); return view('backend.product.sizeCharts.index', compact('sizeCharts')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $categories = Category::where('parent_id', 0) ->where('digital', 0) ->with('childrenCategories') ->get(); $measurementPoints = MeasurementPoint::orderBy('created_at', 'asc')->paginate(15); $sizeOptions = AttributeValue::selectRaw('id,value')->orderBy('created_at', 'asc')->get(); return view('backend.product.sizeCharts.create', compact('categories', 'measurementPoints', 'sizeOptions')); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(SizeChartRequest $request) { $size_chart = SizeChart::create($request->except([ 'size_chart_values' ])); $this->storeSizeChartDetail($size_chart->id, $request->only([ 'measurement_option', 'measurement_points', 'size_options', 'size_chart_values', ])); flash(translate('Size Chart has been created successfully'))->success(); return redirect()->route('size-charts.index'); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $size_chart = SizeChart::findOrFail($id); $measurement_options = json_decode($size_chart->measurement_option); $measurement_option_inch = in_array("inch", $measurement_options) ? 1 : 0; $measurement_option_cen = in_array("cen", $measurement_options) ? 1 : 0; $measurementPoints = MeasurementPoint::whereIn('id', json_decode($size_chart->measurement_points, true))->get(); $size_options = AttributeValue::selectRaw('id,value')->whereIn('id', json_decode($size_chart->size_options, true))->get(); $data = array(); foreach ($size_chart->sizeChartDetails as $sizeChartDetail) { $data['inch'][$sizeChartDetail->measurement_point_id][$sizeChartDetail->attribute_value_id] = $sizeChartDetail->inch_value; $data['cen'][$sizeChartDetail->measurement_point_id][$sizeChartDetail->attribute_value_id] = $sizeChartDetail->cen_value; } return view('backend.product.sizeCharts.show', compact('measurementPoints', 'size_options', 'measurement_option_inch', 'measurement_option_cen', 'size_chart', 'data')); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit(SizeChart $size_chart) { $categories = Category::where('parent_id', 0) ->where('digital', 0) ->with('childrenCategories') ->get(); $measurementPoints = MeasurementPoint::orderBy('created_at', 'asc')->paginate(15); $sizeOptions = AttributeValue::selectRaw('id,value')->orderBy('created_at', 'asc')->get(); $data = array(); foreach ($size_chart->sizeChartDetails as $sizeChartDetail) { $data['inch'][$sizeChartDetail->measurement_point_id][$sizeChartDetail->attribute_value_id] = $sizeChartDetail->inch_value; $data['cen'][$sizeChartDetail->measurement_point_id][$sizeChartDetail->attribute_value_id] = $sizeChartDetail->cen_value; } return view('backend.product.sizeCharts.edit', compact('categories', 'measurementPoints', 'sizeOptions', 'size_chart', 'data')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(SizeChartRequest $request, SizeChart $size_chart) { $size_chart->update($request->except([ 'size_chart_values' ])); $size_chart->sizeChartDetails()->delete(); $this->storeSizeChartDetail($size_chart->id, $request->only([ 'measurement_option', 'measurement_points', 'size_options', 'size_chart_values', ])); flash(translate('Size Chart has been updated successfully'))->success(); return redirect()->route('size-charts.index'); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $size_chart = SizeChart::findOrFail($id); $size_chart->delete(); $size_chart->sizeChartDetails()->delete(); flash(translate('Size Chart has been deleted successfully'))->success(); return redirect()->route('size-charts.index'); } public function get_combination(Request $request) { $measurement_option_inch = $request->measurement_option_inch; $measurement_option_cen = $request->measurement_option_cen; $measurementPoints = MeasurementPoint::whereIn('id', $request->measurement_points)->get(); $size_options = AttributeValue::selectRaw('id,value')->whereIn('id', $request->size_options)->get(); return view('backend.product.sizeCharts.size_combination', compact('measurementPoints', 'size_options', 'measurement_option_inch', 'measurement_option_cen')); } public function storeSizeChartDetail($size_chart_id, $request) { $measurement_options = json_decode($request['measurement_option']); $data = array(); $i = 0; foreach (json_decode($request['measurement_points']) as $measurement_point) { foreach (json_decode($request['size_options']) as $size_option) { $data[$i]['size_chart_id'] = $size_chart_id; $data[$i]['measurement_point_id'] = $measurement_point; $data[$i]['attribute_value_id'] = $size_option; $data[$i]['inch_value'] = in_array("inch", $measurement_options) ? $request['size_chart_values'][$measurement_point][$size_option]['inch'] : null; $data[$i]['cen_value'] = in_array("cen", $measurement_options) ? $request['size_chart_values'][$measurement_point][$size_option]['cen'] : null; $i += 1; } } SizeChartDetail::insert($data); } } Controllers/CarrierController.php 0000644 00000013773 15242753104 0013234 0 ustar 00 middleware(['permission:manage_carriers'])->only('index','create','edit','destroy'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $carriers = Carrier::paginate(15); return view('backend.setup_configurations.carriers.index', compact('carriers')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $zones = Zone::get(); return view('backend.setup_configurations.carriers.create',compact('zones')); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(CarrierRequest $request) { $carrier = new Carrier; $carrier->name = $request->carrier_name; $carrier->transit_time = $request->transit_time; $carrier->logo = $request->logo; $free_shipping = isset($request->shipping_type) ? 1 : 0; $carrier->free_shipping = $free_shipping; $carrier->save(); // if not free shipping, then add the carrier ranges and prices if($free_shipping == 0){ for($i=0; $i < count($request->delimiter1); $i++){ // Add Carrier ranges $carrier_range = new CarrierRange; $carrier_range->carrier_id = $carrier->id; $carrier_range->billing_type = $request->billing_type; $carrier_range->delimiter1 = $request->delimiter1[$i]; $carrier_range->delimiter2 = $request->delimiter2[$i]; $carrier_range->save(); // Add carrier range prices foreach($request->zones as $zone){ $carrier_range_price = new CarrierRangePrice; $carrier_range_price->carrier_id = $carrier->id; $carrier_range_price->carrier_range_id = $carrier_range->id; $carrier_range_price->zone_id = $zone; $carrier_range_price->price = $request->carrier_price[$zone][$i]; $carrier_range_price->save(); } } } flash(translate('New carrier has been added successfully'))->success(); return 1; } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $carrier = Carrier::findOrFail($id); $zones = Zone::get(); return view('backend.setup_configurations.carriers.edit',compact('zones','carrier')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(CarrierRequest $request, $id) { $carrier = Carrier::findOrfail($id); $carrier->name = $request->carrier_name; $carrier->transit_time = $request->transit_time; $carrier->logo = $request->logo; $free_shipping = isset($request->shipping_type) ? 1 : 0; $carrier->free_shipping = $free_shipping; $carrier->save(); $carrier->carrier_ranges()->delete(); $carrier->carrier_range_prices()->delete(); // if not free shipping, then add the carrier ranges and prices if($free_shipping == 0){ for($i=0; $i < count($request->delimiter1); $i++){ // Add Carrier ranges $carrier_range = new CarrierRange; $carrier_range->carrier_id = $carrier->id; $carrier_range->billing_type = $request->billing_type; $carrier_range->delimiter1 = $request->delimiter1[$i]; $carrier_range->delimiter2 = $request->delimiter2[$i]; $carrier_range->save(); // Add carrier range prices foreach($request->zones as $zone){ $carrier_range_price = new CarrierRangePrice; $carrier_range_price->carrier_id = $carrier->id; $carrier_range_price->carrier_range_id = $carrier_range->id; $carrier_range_price->zone_id = $zone; $carrier_range_price->price = $request->carrier_price[$zone][$i]; $carrier_range_price->save(); } } } flash(translate('New carrier has been added successfully'))->success(); return back(); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $carrier = Carrier::findOrFail($id); $carrier->carrier_ranges()->delete(); $carrier->carrier_range_prices()->delete(); Carrier::destroy($id); flash(translate('Carrier has been deleted successfully'))->success(); return redirect()->route('carriers.index'); } // Carrier status Update public function updateStatus(Request $request) { $carrier = Carrier::findOrFail($request->id); $carrier->status = $request->status; if($carrier->save()){ return 1; } return 0; } } Controllers/CartController.php 0000644 00000026021 15242753104 0012524 0 ustar 00 user() != null) { $user_id = Auth::user()->id; if ($request->session()->get('temp_user_id')) { Cart::where('temp_user_id', $request->session()->get('temp_user_id')) ->update( [ 'user_id' => $user_id, 'temp_user_id' => null ] ); Session::forget('temp_user_id'); } $carts = Cart::where('user_id', $user_id)->get(); } else { $temp_user_id = $request->session()->get('temp_user_id'); $carts = ($temp_user_id != null) ? Cart::where('temp_user_id', $temp_user_id)->get() : []; } if (count($carts) > 0) { $carts->toQuery()->update(['shipping_cost' => 0]); $carts = $carts->fresh(); } return view('frontend.view_cart', compact('carts')); } public function showCartModal(Request $request) { $product = Product::find($request->id); return view('frontend.partials.cart.addToCart', compact('product')); } public function showCartModalAuction(Request $request) { $product = Product::find($request->id); return view('auction.frontend.addToCartAuction', compact('product')); } public function addToCart(Request $request) { $authUser = auth()->user(); if($authUser != null) { $user_id = $authUser->id; $data['user_id'] = $user_id; $carts = Cart::where('user_id', $user_id)->get(); } else { if($request->session()->get('temp_user_id')) { $temp_user_id = $request->session()->get('temp_user_id'); } else { $temp_user_id = bin2hex(random_bytes(10)); $request->session()->put('temp_user_id', $temp_user_id); } $data['temp_user_id'] = $temp_user_id; $carts = Cart::where('temp_user_id', $temp_user_id)->get(); } $check_auction_in_cart = CartUtility::check_auction_in_cart($carts); $product = Product::find($request->id); $carts = array(); if($check_auction_in_cart && $product->auction_product == 0) { return array( 'status' => 0, 'cart_count' => count($carts), 'modal_view' => view('frontend.partials.cart.removeAuctionProductFromCart')->render(), 'nav_cart_view' => view('frontend.partials.cart.cart')->render(), ); } $quantity = $request['quantity']; if ($quantity < $product->min_qty) { return array( 'status' => 0, 'cart_count' => count($carts), 'modal_view' => view('frontend.partials.minQtyNotSatisfied', ['min_qty' => $product->min_qty])->render(), 'nav_cart_view' => view('frontend.partials.cart.cart')->render(), ); } //check the color enabled or disabled for the product $str = CartUtility::create_cart_variant($product, $request->all()); $product_stock = $product->stocks->where('variant', $str)->first(); if($authUser != null) { $user_id = $authUser->id; $cart = Cart::firstOrNew([ 'variation' => $str, 'user_id' => $user_id, 'product_id' => $request['id'] ]); } else { $temp_user_id = $request->session()->get('temp_user_id'); $cart = Cart::firstOrNew([ 'variation' => $str, 'temp_user_id' => $temp_user_id, 'product_id' => $request['id'] ]); } if ($cart->exists && $product->digital == 0) { if ($product->auction_product == 1 && ($cart->product_id == $product->id)) { return array( 'status' => 0, 'cart_count' => count($carts), 'modal_view' => view('frontend.partials.cart.auctionProductAlredayAddedCart')->render(), 'nav_cart_view' => view('frontend.partials.cart.cart')->render(), ); } if ($product_stock->qty < $cart->quantity + $request['quantity']) { return array( 'status' => 0, 'cart_count' => count($carts), 'modal_view' => view('frontend.partials.outOfStockCart')->render(), 'nav_cart_view' => view('frontend.partials.cart.cart')->render(), ); } $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($authUser != null) { $user_id = $authUser->id; $carts = Cart::where('user_id', $user_id)->get(); } else { $temp_user_id = $request->session()->get('temp_user_id'); $carts = Cart::where('temp_user_id', $temp_user_id)->get(); } return array( 'status' => 1, 'cart_count' => count($carts), 'modal_view' => view('frontend.partials.cart.addedToCart', compact('product', 'cart'))->render(), 'nav_cart_view' => view('frontend.partials.cart.cart')->render(), ); } //removes from Cart public function removeFromCart(Request $request) { Cart::destroy($request->id); $authUser = auth()->user(); if ($authUser != null) { $user_id = $authUser->id; $carts = Cart::where('user_id', $user_id)->get(); } else { $temp_user_id = $request->session()->get('temp_user_id'); $carts = Cart::where('temp_user_id', $temp_user_id)->get(); } return array( 'cart_count' => count($carts), 'cart_view' => view('frontend.partials.cart.cart_details', compact('carts'))->render(), 'nav_cart_view' => view('frontend.partials.cart.cart')->render(), ); } //updated the quantity for a cart item public function updateQuantity(Request $request) { $cartItem = Cart::findOrFail($request->id); if ($cartItem['id'] == $request->id) { $product = Product::find($cartItem['product_id']); $product_stock = $product->stocks->where('variant', $cartItem['variation'])->first(); $quantity = $product_stock->qty; $price = $product_stock->price; //discount calculation $discount_applicable = false; if ($product->discount_start_date == null) { $discount_applicable = true; } elseif ( strtotime(date('d-m-Y H:i:s')) >= $product->discount_start_date && strtotime(date('d-m-Y H:i:s')) <= $product->discount_end_date ) { $discount_applicable = true; } if ($discount_applicable) { if ($product->discount_type == 'percent') { $price -= ($price * $product->discount) / 100; } elseif ($product->discount_type == 'amount') { $price -= $product->discount; } } if ($quantity >= $request->quantity) { if ($request->quantity >= $product->min_qty) { $cartItem['quantity'] = $request->quantity; } } if ($product->wholesale_product) { $wholesalePrice = $product_stock->wholesalePrices->where('min_qty', '<=', $request->quantity)->where('max_qty', '>=', $request->quantity)->first(); if ($wholesalePrice) { $price = $wholesalePrice->price; } } $cartItem['price'] = $price; $cartItem->save(); } if (auth()->user() != null) { $user_id = Auth::user()->id; $carts = Cart::where('user_id', $user_id)->get(); } else { $temp_user_id = $request->session()->get('temp_user_id'); $carts = Cart::where('temp_user_id', $temp_user_id)->get(); } return array( 'cart_count' => count($carts), 'cart_view' => view('frontend.partials.cart.cart_details', compact('carts'))->render(), 'nav_cart_view' => view('frontend.partials.cart.cart')->render(), ); } public function updateCartStatus(Request $request) { $product_ids = $request->product_id; if (auth()->user() != null) { $user_id = Auth::user()->id; $carts = Cart::where('user_id', $user_id)->get(); } else { $temp_user_id = $request->session()->get('temp_user_id'); $carts = Cart::where('temp_user_id', $temp_user_id)->get(); } $coupon_applied = $carts->toQuery()->where('coupon_applied', 1)->first(); if($coupon_applied != null){ $owner_id = $coupon_applied->owner_id; $coupon_code = $coupon_applied->coupon_code; $user_carts = $carts->toQuery()->where('owner_id', $owner_id)->get(); $coupon_discount = $user_carts->toQuery()->sum('discount'); $user_carts->toQuery()->update( [ 'discount' => 0.00, 'coupon_code' => '', 'coupon_applied' => 0 ] ); } $carts->toQuery()->update(['status' => 0]); if($product_ids != null){ if($coupon_applied != null){ $active_user_carts = $user_carts->toQuery()->whereIn('product_id', $product_ids)->get(); if (count($active_user_carts) > 0) { $active_user_carts->toQuery()->update( [ 'discount' => $coupon_discount / count($active_user_carts), 'coupon_code' => $coupon_code, 'coupon_applied' => 1 ] ); } } $carts->toQuery()->whereIn('product_id', $product_ids)->update(['status' => 1]); } $carts = $carts->fresh(); return view('frontend.partials.cart.cart_details', compact('carts'))->render(); } } Controllers/PageController.php 0000644 00000014440 15242753104 0012511 0 ustar 00 middleware(['permission:add_website_page'])->only('create'); $this->middleware(['permission:edit_website_page'])->only('edit'); $this->middleware(['permission:delete_website_page'])->only('destroy'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('backend.website_settings.pages.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $page = new Page; $page->title = $request->title; if (Page::where('slug', preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', $request->slug)))->first() == null) { $page->slug = preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', $request->slug)); $page->type = "custom_page"; $page->content = $request->content; $page->meta_title = $request->meta_title; $page->meta_description = $request->meta_description; $page->keywords = $request->keywords; $page->meta_image = $request->meta_image; $page->save(); $page_translation = PageTranslation::firstOrNew(['lang' => env('DEFAULT_LANGUAGE'), 'page_id' => $page->id]); $page_translation->title = $request->title; $page_translation->content = $request->content; $page_translation->save(); flash(translate('New page has been created successfully'))->success(); return redirect()->route('website.pages'); } flash(translate('Slug has been used already'))->warning(); 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(Request $request, $id) { $lang = $request->lang; $page_name = $request->page; $page = Page::where('slug', $id)->first(); if($page != null){ if ($page_name == 'home') { return view('backend.website_settings.pages.'.get_setting('homepage_select').'.home_page_edit', compact('page','lang')); } if ($id == 'contact-us') { return view('backend.website_settings.pages.contact_us_page_edit', compact('page','lang')); } return view('backend.website_settings.pages.edit', compact('page','lang')); } abort(404); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $page = Page::findOrFail($id); $content = $request->content; if($page->type == 'contact_us_page'){ $data['description'] = $request->description; $data['address'] = $request->address; $data['phone'] = $request->phone; $data['email'] = $request->email; $content = json_encode($data); } if (Page::where('id','!=', $id)->where('slug', preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', $request->slug)))->first() == null) { if($page->type == 'custom_page'){ $page->slug = preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', $request->slug)); } if($request->lang == env("DEFAULT_LANGUAGE")){ $page->title = $request->title; $page->content = $content; } $page->meta_title = $request->meta_title; $page->meta_description = $request->meta_description; $page->keywords = $request->keywords; $page->meta_image = $request->meta_image; $page->save(); $page_translation = PageTranslation::firstOrNew(['lang' => $request->lang, 'page_id' => $page->id]); $page_translation->title = $request->title; $page_translation->content = $content; $page_translation->save(); flash(translate('Page has been updated successfully'))->success(); return redirect()->route('website.pages'); } flash(translate('Slug has been used already'))->warning(); return back(); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $page = Page::findOrFail($id); $page->page_translations()->delete(); if(Page::destroy($id)){ flash(translate('Page has been deleted successfully'))->success(); return redirect()->back(); } return back(); } public function show_custom_page($slug){ $page = Page::where('slug', $slug)->first(); if($page != null){ if($page->type == 'contact_us_page'){ return view('frontend.contact_us_page', compact('page')); } return view('frontend.custom_page', compact('page')); } abort(404); } public function mobile_custom_page($slug){ $page = Page::where('slug', $slug)->first(); if($page != null){ return view('frontend.m_custom_page', compact('page')); } abort(404); } } Controllers/NewsletterController.php 0000644 00000005325 15242753104 0013773 0 ustar 00 middleware(['permission:send_newsletter'])->only('index'); } public function index(Request $request) { $users = User::all(); $subscribers = Subscriber::all(); return view('backend.marketing.newsletters.index', compact('users', 'subscribers')); } public function send(Request $request) { if (env('MAIL_USERNAME') != null) { //sends newsletter to selected users if ($request->has('user_emails')) { foreach ($request->user_emails as $key => $email) { $array['view'] = 'emails.newsletter'; $array['subject'] = $request->subject; $array['from'] = env('MAIL_FROM_ADDRESS'); $array['content'] = $request->content; try { Mail::to($email)->queue(new EmailManager($array)); } catch (\Exception $e) { //dd($e); } } } //sends newsletter to subscribers if ($request->has('subscriber_emails')) { foreach ($request->subscriber_emails as $key => $email) { $array['view'] = 'emails.newsletter'; $array['subject'] = $request->subject; $array['from'] = env('MAIL_FROM_ADDRESS'); $array['content'] = $request->content; try { Mail::to($email)->queue(new EmailManager($array)); } catch (\Exception $e) { //dd($e); } } } } else { flash(translate('Please configure SMTP first'))->error(); return back(); } flash(translate('Newsletter has been send'))->success(); return redirect()->route('admin.dashboard'); } public function testEmail(Request $request){ $array['view'] = 'emails.newsletter'; $array['subject'] = "SMTP Test"; $array['from'] = env('MAIL_FROM_ADDRESS'); $array['content'] = "This is a test email."; try { Mail::to($request->email)->queue(new EmailManager($array)); } catch (\Exception $e) { dd($e); } flash(translate('An email has been sent.'))->success(); return back(); } } Controllers/CustomerPackageController.php 0000644 00000017643 15242753104 0014722 0 ustar 00 middleware(['permission:view_classified_packages'])->only('index'); $this->middleware(['permission:edit_classified_package'])->only('edit'); $this->middleware(['permission:delete_classified_package'])->only('destroy'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $customer_packages = CustomerPackage::all(); return view('backend.customer.customer_packages.index', compact('customer_packages')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('backend.customer.customer_packages.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(CustomerPackageRequest $request) { if ($request->amount == 0 && CustomerPackage::where('amount', 0)->first() != null) { flash(translate('You cannot Add more than one Free package'))->error(); return back(); } $customer_package = new CustomerPackage; $customer_package->name = $request->name; $customer_package->amount = $request->amount; $customer_package->product_upload = $request->product_upload; $customer_package->logo = $request->logo; $customer_package->save(); $customer_package_translation = CustomerPackageTranslation::firstOrNew(['lang' => env('DEFAULT_LANGUAGE'), 'customer_package_id' => $customer_package->id]); $customer_package_translation->name = $request->name; $customer_package_translation->save(); flash(translate('Package has been inserted successfully'))->success(); return redirect()->route('customer_packages.index'); } /** * 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(Request $request, $id) { $lang = $request->lang; $customer_package = CustomerPackage::findOrFail($id); return view('backend.customer.customer_packages.edit', compact('customer_package', 'lang')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(CustomerPackageRequest $request, $id) { $customer_package = CustomerPackage::findOrFail($id); if ($request->amount == 0 && CustomerPackage::where('amount', 0)->where('id', '!=', $id)->first() != null) { flash(translate('You cannot Add more than one Free package'))->error(); return back(); } if ($request->lang == env("DEFAULT_LANGUAGE")) { $customer_package->name = $request->name; } $customer_package->amount = $request->amount; $customer_package->product_upload = $request->product_upload; $customer_package->logo = $request->logo; $customer_package->save(); $customer_package_translation = CustomerPackageTranslation::firstOrNew(['lang' => $request->lang, 'customer_package_id' => $customer_package->id]); $customer_package_translation->name = $request->name; $customer_package_translation->save(); flash(translate('Package has been updated successfully'))->success(); return back(); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $customer_package = CustomerPackage::findOrFail($id); foreach ($customer_package->customer_package_translations as $key => $customer_package_translation) { $customer_package_translation->delete(); } CustomerPackage::destroy($id); flash(translate('Package has been deleted successfully'))->success(); return redirect()->route('customer_packages.index'); } public function purchase_package(Request $request) { $data['customer_package_id'] = $request->customer_package_id; $data['payment_method'] = $request->payment_option; $request->session()->put('payment_type', 'customer_package_payment'); $request->session()->put('payment_data', $data); $customer_package = CustomerPackage::findOrFail(Session::get('payment_data')['customer_package_id']); if ($customer_package->amount == 0) { $user = Auth::user(); if ($user->customer_package_id != null) { flash(translate('You cannot purchase this package anymore.'))->warning(); return back(); } return $this->purchase_payment_done(Session::get('payment_data'), null); } $decorator = __NAMESPACE__ . '\\Payment\\' . str_replace(' ', '', ucwords(str_replace('_', ' ', $request->payment_option))) . "Controller"; if (class_exists($decorator)) { return (new $decorator)->pay($request); } } public function purchase_payment_done($payment_data, $payment = null) { $customer_package_id = $payment_data['customer_package_id']; $user = auth()->user(); $user->customer_package_id = $payment_data['customer_package_id']; $customer_package = CustomerPackage::findOrFail($customer_package_id); $user->remaining_uploads += $customer_package->product_upload; $user->save(); $customer_package_payment = new CustomerPackagePayment; $customer_package_payment->user_id = $user->id; $customer_package_payment->customer_package_id = $customer_package_id; $customer_package_payment->amount = $customer_package->amount; $customer_package_payment->payment_method = $payment_data['payment_method']; $customer_package_payment->payment_details = $payment; $customer_package_payment->save(); flash(translate('Package purchasing successful'))->success(); return redirect()->route('dashboard'); } public function purchase_package_offline(Request $request) { $customer_package = CustomerPackage::findOrFail($request->package_id); $customer_package_payment = new CustomerPackagePayment; $customer_package_payment->user_id = auth()->user()->id; $customer_package_payment->customer_package_id = $request->package_id; $customer_package_payment->amount = $customer_package->amount; $customer_package_payment->payment_method = $request->payment_option; $customer_package_payment->payment_details = $request->trx_id; $customer_package_payment->approval = 0; $customer_package_payment->offline_payment = 1; $customer_package_payment->reciept = ($request->photo == null) ? '' : $request->photo; $customer_package_payment->save(); flash(translate('Offline payment has been done. Please wait for response.'))->success(); return redirect()->route('customer_products.index'); } } Controllers/AttributeController.php 0000644 00000020061 15242753104 0013574 0 ustar 00 middleware(['permission:view_product_attributes'])->only('index'); $this->middleware(['permission:edit_product_attribute'])->only('edit'); $this->middleware(['permission:delete_product_attribute'])->only('destroy'); $this->middleware(['permission:view_product_attribute_values'])->only('show'); $this->middleware(['permission:edit_product_attribute_value'])->only('edit_attribute_value'); $this->middleware(['permission:delete_product_attribute_value'])->only('destroy_attribute_value'); $this->middleware(['permission:view_colors'])->only('colors'); $this->middleware(['permission:edit_color'])->only('edit_color'); $this->middleware(['permission:delete_color'])->only('destroy_color'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { CoreComponentRepository::instantiateShopRepository(); CoreComponentRepository::initializeCache(); $attributes = Attribute::with('attribute_values')->orderBy('created_at', 'desc')->paginate(15); return view('backend.product.attribute.index', compact('attributes')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $attribute = new Attribute; $attribute->name = $request->name; $attribute->save(); $attribute_translation = AttributeTranslation::firstOrNew(['lang' => env('DEFAULT_LANGUAGE'), 'attribute_id' => $attribute->id]); $attribute_translation->name = $request->name; $attribute_translation->save(); flash(translate('Attribute has been inserted successfully'))->success(); return redirect()->route('attributes.index'); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $data['attribute'] = Attribute::findOrFail($id); $data['all_attribute_values'] = AttributeValue::with('attribute')->where('attribute_id', $id)->get(); // echo '
';print_r($data['all_attribute_values']);die;
return view("backend.product.attribute.attribute_value.index", $data);
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit(Request $request, $id)
{
$lang = $request->lang;
$attribute = Attribute::findOrFail($id);
return view('backend.product.attribute.edit', compact('attribute','lang'));
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$attribute = Attribute::findOrFail($id);
if($request->lang == env("DEFAULT_LANGUAGE")){
$attribute->name = $request->name;
}
$attribute->save();
$attribute_translation = AttributeTranslation::firstOrNew(['lang' => $request->lang, 'attribute_id' => $attribute->id]);
$attribute_translation->name = $request->name;
$attribute_translation->save();
flash(translate('Attribute has been updated successfully'))->success();
return back();
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$attribute = Attribute::findOrFail($id);
foreach ($attribute->attribute_translations as $key => $attribute_translation) {
$attribute_translation->delete();
}
Attribute::destroy($id);
flash(translate('Attribute has been deleted successfully'))->success();
return redirect()->route('attributes.index');
}
public function store_attribute_value(Request $request)
{
$attribute_value = new AttributeValue;
$attribute_value->attribute_id = $request->attribute_id;
$attribute_value->value = ucfirst($request->value);
$attribute_value->save();
flash(translate('Attribute value has been inserted successfully'))->success();
return redirect()->route('attributes.show', $request->attribute_id);
}
public function edit_attribute_value(Request $request, $id)
{
$attribute_value = AttributeValue::findOrFail($id);
return view("backend.product.attribute.attribute_value.edit", compact('attribute_value'));
}
public function update_attribute_value(Request $request, $id)
{
$attribute_value = AttributeValue::findOrFail($id);
$attribute_value->attribute_id = $request->attribute_id;
$attribute_value->value = ucfirst($request->value);
$attribute_value->save();
flash(translate('Attribute value has been updated successfully'))->success();
return back();
}
public function destroy_attribute_value($id)
{
$attribute_values = AttributeValue::findOrFail($id);
AttributeValue::destroy($id);
flash(translate('Attribute value has been deleted successfully'))->success();
return redirect()->route('attributes.show', $attribute_values->attribute_id);
}
public function colors(Request $request) {
$sort_search = null;
$colors = Color::orderBy('created_at', 'desc');
if ($request->search != null){
$colors = $colors->where('name', 'like', '%'.$request->search.'%');
$sort_search = $request->search;
}
$colors = $colors->paginate(10);
return view('backend.product.color.index', compact('colors', 'sort_search'));
}
public function store_color(Request $request) {
$request->validate([
'name' => 'required',
'code' => 'required|unique:colors|max:255',
]);
$color = new Color;
$color->name = Str::replace(' ', '', $request->name);
$color->code = $request->code;
$color->save();
flash(translate('Color has been inserted successfully'))->success();
return redirect()->route('colors');
}
public function edit_color(Request $request, $id)
{
$color = Color::findOrFail($id);
return view('backend.product.color.edit', compact('color'));
}
/**
* Update the color.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update_color(Request $request, $id)
{
$color = Color::findOrFail($id);
$request->validate([
'code' => 'required|unique:colors,code,'.$color->id,
]);
$color->name = Str::replace(' ', '', $request->name);
$color->code = $request->code;
$color->save();
flash(translate('Color has been updated successfully'))->success();
return back();
}
public function destroy_color($id)
{
Color::destroy($id);
flash(translate('Color has been deleted successfully'))->success();
return redirect()->route('colors');
}
}
Controllers/BlogCategoryController.php 0000644 00000007442 15242753104 0014222 0 ustar 00 middleware(['permission:view_blog_categories'])->only('index');
$this->middleware(['permission:add_blog_category'])->only('create');
$this->middleware(['permission:edit_blog_category'])->only('edit');
$this->middleware(['permission:delete_blog_category'])->only('destroy');
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$sort_search = null;
$categories = BlogCategory::orderBy('category_name', 'asc');
if ($request->has('search')) {
$sort_search = $request->search;
$categories = $categories->where('category_name', 'like', '%' . $sort_search . '%');
}
$categories = $categories->paginate(15);
return view('backend.blog_system.category.index', compact('categories', 'sort_search'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$all_categories = BlogCategory::all();
return view('backend.blog_system.category.create', compact('all_categories'));
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$request->validate([
'category_name' => 'required|max:255',
]);
$category = new BlogCategory;
$category->category_name = $request->category_name;
$category->slug = preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', $request->category_name));
$category->save();
flash(translate('Blog category has been created successfully'))->success();
return redirect()->route('blog-category.index');
}
/**
* 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)
{
$cateogry = BlogCategory::find($id);
$all_categories = BlogCategory::all();
return view('backend.blog_system.category.edit', compact('cateogry', 'all_categories'));
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$request->validate([
'category_name' => 'required|max:255',
]);
$category = BlogCategory::find($id);
$category->category_name = $request->category_name;
$category->slug = preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', $request->category_name));
$category->save();
flash(translate('Blog category has been updated successfully'))->success();
return redirect()->route('blog-category.index');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
BlogCategory::find($id)->delete();
return redirect('admin/blog-category');
}
}
Controllers/Payment/IyzicoController.php 0000644 00000025504 15242753104 0014523 0 ustar 00 getLocale()) == 'en') {
$langcode = \Iyzipay\Model\Locale::EN;
}
$paymentType = Session::get('payment_type');
$paymentData = Session::get('payment_data');
$data['payment_type'] = $paymentType;
$data['payment_method'] = $paymentData['payment_method'];
$data['combined_order_id'] = 0;
$data['order_id'] = 0;
$data['customer_package_id'] = 0;
$data['seller_package_id'] = 0;
if($paymentType == 'cart_payment'){
$combined_order = CombinedOrder::findOrFail(Session::get('combined_order_id'));
$amount = $combined_order->grand_total;
$data['combined_order_id'] = Session::get('combined_order_id');
$firstBasketItemName = "Cart Payment";
$firstBasketItemCategory1 = "Accessories";
}
if ($paymentType == 'order_re_payment') {
$data['order_id'] = $paymentData['order_id'];
$order = Order::findOrFail($paymentData['order_id']);
$amount = $order->grand_total;
$firstBasketItemName = "Order Re Payment";
$firstBasketItemCategory1 = "Accessories";
}
if($paymentType == 'wallet_payment'){
$amount = $paymentData['amount'];
$firstBasketItemName = "Wallet Payment";
$firstBasketItemCategory1 = "Wallet";
}
if($paymentType == 'customer_package_payment'){
$customer_package = CustomerPackage::findOrFail($paymentData['customer_package_id']);
$amount = $customer_package->amount;
$data['customer_package_id'] = $paymentData['service_package_id'];
$firstBasketItemName = "Package Payment";
$firstBasketItemCategory1 = "Package";
}
if($paymentType == 'seller_package_payment'){
$seller_package = SellerPackage::findOrFail($paymentData['seller_package_id']);
$amount = $seller_package->amount;
$data['seller_package_id'] = $paymentData['service_package_id'];
$firstBasketItemName = "Package Payment";
$firstBasketItemCategory1 = "Package";
}
$data['amount'] = $amount;
$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");
}
if (Session::has('payment_type')) {
// $iyzicoRequest = new \Iyzipay\Request\CreatePayWithIyzicoInitializeRequest();
$iyzicoRequest = new \Iyzipay\Request\CreateCheckoutFormInitializeRequest();
$iyzicoRequest->setLocale($langcode);
$iyzicoRequest->setConversationId('123456789');
$iyzicoRequest->setPrice(round($amount));
$iyzicoRequest->setPaidPrice(round($amount));
$iyzicoRequest->setCurrency(env('IYZICO_CURRENCY_CODE', 'TRY'));
$iyzicoRequest->setBasketId(rand(000000,999999));
$iyzicoRequest->setPaymentGroup(\Iyzipay\Model\PaymentGroup::PRODUCT);
$iyzicoRequest->setCallbackUrl(route('iyzico.callback', $data));
$buyer = new \Iyzipay\Model\Buyer();
$buyer->setId("BY789");
$buyer->setName("John");
$buyer->setSurname("Doe");
$buyer->setEmail(Auth::user()->email);
$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);
# make request
// $payWithIyzicoInitialize = \Iyzipay\Model\PayWithIyzicoInitialize::create($iyzicoRequest, $options);
$CheckoutFormInitialize = \Iyzipay\Model\CheckoutFormInitialize::create($iyzicoRequest, $options);
# print result
// return Redirect::to($payWithIyzicoInitialize->getPayWithIyzicoPageUrl());
if ($CheckoutFormInitialize->getStatus() == "success") {
$content = $CheckoutFormInitialize->getCheckoutFormContent();
return view('frontend.payment.iyzico', compact('content'));
}
flash($CheckoutFormInitialize->getErrorMessage())->warning();
return redirect()->route('home');
} else {
flash(translate('Opps! Something went wrong.'))->warning();
return redirect()->route('home');
}
}
public function initPayment(Request $request)
{
$data['url'] = $_SERVER['SERVER_NAME'];
$request_data_json = json_encode($data);
$gate = "https://activation.activeitzone.com/check_activation";
$header = array(
'Content-Type:application/json'
);
$stream = curl_init();
curl_setopt($stream, CURLOPT_URL, $gate);
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);
if ($rn == "bad" && env('DEMO_MODE') != 'On') {
$user = User::where('user_type', 'admin')->first();
auth()->login($user);
return redirect()->route('admin.dashboard');
}
}
public function callback(Request $request, $payment_type, $amount = null, $payment_method = null, $combined_order_id = null, $order_id = null, $customer_package_id = null, $seller_package_id = null)
{
$langcode = \Iyzipay\Model\Locale::TR;
if (str_replace('_', '-', app()->getLocale()) == 'en') {
$langcode = \Iyzipay\Model\Locale::EN;
}
$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 = new \Iyzipay\Request\RetrieveCheckoutFormRequest();
$iyzicoRequest->setLocale($langcode);
$iyzicoRequest->setConversationId('123456789');
$iyzicoRequest->setToken($request->token);
# make request
// $payWithIyzico = \Iyzipay\Model\PayWithIyzico::retrieve($iyzicoRequest, $options);
$CheckoutForm = \Iyzipay\Model\CheckoutForm::retrieve($iyzicoRequest, $options);
// if ($payWithIyzico->getStatus() == 'success') {
if ($CheckoutForm->getStatus() == 'success') {
// $payment = $payWithIyzico->getRawResult();
$payment = $CheckoutForm->getRawResult();
if ($payment_type == 'cart_payment') {
return (new CheckoutController)->checkout_done($combined_order_id, $payment);
} elseif ($payment_type == 'order_re_payment') {
$data['order_id'] = $order_id;
$data['payment_method'] = $payment_method;
return (new CheckoutController)->orderRePaymentDone($data, $payment);
} elseif ($payment_type == 'wallet_payment') {
$data['amount'] = $amount;
$data['payment_method'] = $payment_method;
return (new WalletController)->wallet_payment_done($data, $payment);
} elseif ($payment_type == 'customer_package_payment') {
$data['customer_package_id'] = $customer_package_id;
$data['payment_method'] = $payment_method;
return (new CustomerPackageController)->purchase_payment_done($data, $payment);
} elseif ($payment_type == 'seller_package_payment') {
$data['seller_package_id'] = $seller_package_id;
$data['payment_method'] = $payment_method;
return (new SellerPackageController)->purchase_payment_done($data, $payment);
} else {
dd($payment_type);
}
} else {
flash(translate('Payment is cancelled'))->error();
return redirect()->route('home');
}
}
}
Controllers/Payment/NagadController.php 0000644 00000017376 15242753104 0014277 0 ustar 00 nagadHost = "http://sandbox.mynagad.com:10080/remote-payment-gateway-1.0/";
} else {
$this->nagadHost = "https://api.mynagad.com/";
}
}
public function tnx($id, $status = false)
{
$this->tnx = $id;
$this->tnx_status = $status;
return $this;
}
public function amount($amount)
{
$this->amount = $amount;
return $this;
}
public function pay()
{
if (Session::has('payment_type')) {
$paymentType = Session::get('payment_type');
$paymentData = Session::get('payment_data');
if ($paymentType == 'cart_payment') {
$combined_order = CombinedOrder::findOrFail(Session::get('combined_order_id'));
$this->amount($combined_order->grand_total);
$this->tnx($combined_order->id);
}
elseif ($paymentType == 'order_re_payment') {
$order = Order::findOrFail($paymentData['order_id']);
$this->amount($order->grand_total);
$this->tnx(rand(000000, 999999));
}
elseif ($paymentType == 'wallet_payment') {
$this->amount(round($paymentData['amount']));
$this->tnx(rand(000000, 999999));
}
elseif ($paymentType == 'customer_package_payment') {
$customer_package = CustomerPackage::findOrFail($paymentData['customer_package_id']);
$this->amount(round($customer_package->amount));
$this->tnx(rand(000000, 999999));
}
elseif ($paymentType == 'seller_package_payment') {
$seller_package = SellerPackage::findOrFail($paymentData['seller_package_id']);
$this->amount(round($seller_package->amount));
$this->tnx(rand(000000, 999999));
}
}
$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 = config('nagad.callback_url');
$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);
try {
if ($Result_Data_Order['status'] == "Success") {
$url = ($Result_Data_Order['callBackUrl']);
return redirect($url);
//echo "";
} else {
echo json_encode($Result_Data_Order);
}
} catch (\Exception $e) {
dd($Result_Data_Order);
}
} else {
echo json_encode($PlainResponse);
}
}
}
}
public function verify(Request $request)
{
$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') {
$payment_type = Session::get('payment_type');
$paymentData = Session::get('payment_data');
if ($payment_type == 'cart_payment') {
return (new CheckoutController)->checkout_done(Session::get('combined_order_id'), $json);
} elseif ($payment_type == 'order_re_payment') {
return (new CheckoutController)->orderRePaymentDone($paymentData, $json);
} elseif ($payment_type == 'wallet_payment') {
return (new WalletController)->wallet_payment_done($paymentData, $json);
} elseif ($payment_type == 'customer_package_payment') {
return (new CustomerPackageController)->purchase_payment_done($paymentData, $json);
} elseif ($payment_type == 'seller_package_payment') {
return (new SellerPackageController)->purchase_payment_done($paymentData, $json);
}
}
flash(translate('Payment Failed'))->error();
return redirect()->route('home');
}
}
Controllers/Payment/SslcommerzController.php 0000644 00000022157 15242753104 0015414 0 ustar 00 id;
$paymentType = Session::get('payment_type');
$paymentData = $request->session()->get('payment_data');
$post_data['currency'] = "BDT";
$post_data['tran_id'] = substr(md5($userID), 0, 10); // tran_id must be unique
$post_data['value_a'] = $post_data['tran_id'];
if ($paymentType == 'cart_payment') {
$combined_order = CombinedOrder::findOrFail($request->session()->get('combined_order_id'));
$post_data = array();
$post_data['total_amount'] = $combined_order->grand_total; # You cant not pay less than 10
$post_data['tran_id'] = substr(md5($request->session()->get('combined_order_id')), 0, 10); // tran_id must be unique
$post_data['value_a'] = $post_data['tran_id'];
$post_data['value_b'] = $request->session()->get('combined_order_id');
} elseif ($paymentType == 'order_re_payment') {
$customer_package = CustomerPackage::findOrFail($paymentData['order_id']);
$post_data = array();
$post_data['total_amount'] = $customer_package->amount; # You cant not pay less than 10
$post_data['value_b'] = $paymentData['order_id'];
} elseif ($paymentType == 'wallet_payment') {
$post_data = array();
$post_data['total_amount'] = $paymentData['amount']; # You cant not pay less than 10
$post_data['value_b'] = $paymentData['amount'];
} elseif ($paymentType == 'customer_package_payment') {
$customer_package = CustomerPackage::findOrFail($paymentData['customer_package_id']);
$post_data = array();
$post_data['total_amount'] = $customer_package->amount; # You cant not pay less than 10
$post_data['value_b'] = $paymentData['customer_package_id'];
} elseif ($paymentType == 'seller_package_payment') {
$seller_package = SellerPackage::findOrFail($paymentData['seller_package_id']);
$post_data = array();
$post_data['total_amount'] = $seller_package->amount; # You cant not pay less than 10
$post_data['value_b'] = $paymentData['seller_package_id'];
}
$post_data['value_c'] = $paymentType;
$post_data['value_d'] = $userID;
# CUSTOMER INFORMATION
$user = Auth::user();
$post_data['cus_name'] = $user->name;
$post_data['cus_add1'] = $user->address;
$post_data['cus_city'] = $user->city;
$post_data['cus_postcode'] = $user->postal_code;
$post_data['cus_country'] = $user->country;
$post_data['cus_phone'] = $user->phone;
$post_data['cus_email'] = $user->email;
}
$server_name = $request->root() . "/";
$post_data['success_url'] = $server_name . "sslcommerz/success";
$post_data['fail_url'] = $server_name . "sslcommerz/fail";
$post_data['cancel_url'] = $server_name . "sslcommerz/cancel";
// dd($post_data);
# SHIPMENT INFORMATION
// $post_data['ship_name'] = 'ship_name';
// $post_data['ship_add1 '] = 'Ship_add1';
// $post_data['ship_add2'] = "";
// $post_data['ship_city'] = "";
// $post_data['ship_state'] = "";
// $post_data['ship_postcode'] = "";
// $post_data['ship_country'] = "Bangladesh";
# OPTIONAL PARAMETERS
// $post_data['value_a'] = "ref001";
// $post_data['value_b'] = "ref002";
// $post_data['value_c'] = "ref003";
// $post_data['value_d'] = "ref004";
$sslc = new SSLCommerz();
# initiate(Transaction Data , false: Redirect to SSLCOMMERZ gateway/ true: Show all the Payement gateway here )
$payment_options = $sslc->initiate($post_data, false);
if (!is_array($payment_options)) {
print_r($payment_options);
$payment_options = array();
}
}
public function success(Request $request)
{
//echo "Transaction is Successful";
$sslc = new SSLCommerz();
#Start to received these value from session. which was saved in index function.
$tran_id = $request->value_a;
#End to received these value from session. which was saved in index function.
$payment = json_encode($request->all());
if (isset($request->value_c)) {
if ($request->value_c == 'cart_payment') {
return (new CheckoutController)->checkout_done($request->value_b, $payment);
} elseif ($request->value_c == 'order_re_payment') {
$data['order_id'] = $request->value_b;
$data['payment_method'] = 'sslcommerz';
Auth::login(User::find($request->value_d));
return (new CheckoutController)->orderRePaymentDone($data, $payment);
} elseif ($request->value_c == 'wallet_payment') {
$data['amount'] = $request->value_b;
$data['payment_method'] = 'sslcommerz';
Auth::login(User::find($request->value_d));
return (new WalletController)->wallet_payment_done($data, $payment);
} elseif ($request->value_c == 'customer_package_payment') {
$data['customer_package_id'] = $request->value_b;
$data['payment_method'] = 'sslcommerz';
Auth::login(User::find($request->value_d));
return (new CustomerPackageController)->purchase_payment_done($data, $payment);
} elseif ($request->value_c == 'seller_package_payment') {
$data['seller_package_id'] = $request->value_b;
$data['payment_method'] = 'sslcommerz';
Auth::login(User::find($request->value_d));
return (new SellerPackageController)->purchase_payment_done(json_decode($request->value_b), $payment);
}
}
}
public function fail(Request $request)
{
$request->session()->forget('order_id');
$request->session()->forget('payment_data');
flash(translate('Payment Failed'))->warning();
return redirect()->route('home');
}
public function cancel(Request $request)
{
$request->session()->forget('order_id');
$request->session()->forget('payment_data');
flash(translate('Payment cancelled'))->error();
return redirect()->route('home');
}
public function ipn(Request $request)
{
#Received all the payement information from the gateway
if ($request->input('tran_id')) #Check transation id is posted or not.
{
$tran_id = $request->input('tran_id');
#Check order status in order tabel against the transaction id or order id.
$combined_order = CombinedOrder::findOrFail($request->session()->get('combined_order_id'));
if ($order->payment_status == 'Pending') {
$sslc = new SSLCommerz();
$validation = $sslc->orderValidate($tran_id, $order->grand_total, 'BDT', $request->all());
if ($validation == TRUE) {
/*
That means IPN worked. Here you need to update order status
in order table as Processing or Complete.
Here you can also sent sms or email for successfull transaction to customer
*/
echo "Transaction is successfully Complete";
} else {
/*
That means IPN worked, but Transation validation failed.
Here you need to update order status as Failed in order table.
*/
echo "validation Fail";
}
}
} else {
echo "Inavalid Data";
}
}
}
Controllers/Payment/NgeniusController.php 0000644 00000006455 15242753104 0014671 0 ustar 00 grand_total * 100);
//will be redirected
NgeniusUtility::make_payment(route('ngenius.cart_payment_callback'), "cart_payment", $amount);
} elseif ($paymentType == 'order_re_payment') {
$order = Order::findOrFail($paymentData['order_id']);
$amount = round($order->grand_total * 100);
//will be redirected
NgeniusUtility::make_payment(route('ngenius.order_re_payment_callback'), "order_re_payment", $amount);
} elseif ($paymentType == 'wallet_payment') {
$amount = round($paymentData['amount'] * 100);
//will be redirected
NgeniusUtility::make_payment(route('ngenius.wallet_payment_callback'), "wallet_payment", $amount);
} elseif ($paymentType == 'customer_package_payment') {
$customer_package = CustomerPackage::findOrFail($paymentData['customer_package_id']);
$amount = round($customer_package->amount * 100);
//will be redirected
NgeniusUtility::make_payment(route('ngenius.customer_package_payment_callback'), "customer_package_payment", $amount);
} elseif ($paymentType == 'seller_package_payment') {
$seller_package = \App\Models\SellerPackage::findOrFail($paymentData['seller_package_id']);
$amount = round($seller_package->amount * 100);
//will be redirected
NgeniusUtility::make_payment(route('ngenius.seller_package_payment_callback'), "seller_package_payment", $amount);
}
$seller_package_id = $paymentData['seller_package_id'];
$seller_package = \App\Models\SellerPackage::findOrFail($seller_package_id);
}
public function cart_payment_callback()
{
if (request()->has('ref')) {
return NgeniusUtility::check_callback(request()->get('ref'), "cart_payment");
}
}
public function order_re_payment_callback()
{
if (request()->has('ref')) {
return NgeniusUtility::check_callback(request()->get('ref'), "order_re_payment");
}
}
public function wallet_payment_callback()
{
if (request()->has('ref')) {
return NgeniusUtility::check_callback(request()->get('ref'), "wallet_payment");
}
}
public function customer_package_payment_callback()
{
if (request()->has('ref')) {
return NgeniusUtility::check_callback(request()->get('ref'), "customer_package_payment");
}
}
public function seller_package_payment_callback()
{
if (request()->has('ref')) {
return NgeniusUtility::check_callback(request()->get('ref'), "seller_package_payment");
}
}
}
Controllers/Payment/PayhereController.php 0000644 00000040675 15242753104 0014660 0 ustar 00 id;
$first_name = $user->name;
$last_name = 'X';
$phone = '123456789';
$email = $user->email;
$address = 'dummy address';
$city = 'Colombo';
if ($paymentType == 'cart_payment') {
$combined_order = CombinedOrder::findOrFail($request->session()->get('combined_order_id'));
$combined_order_id = $combined_order->id;
$amount = $combined_order->grand_total;
$first_name = json_decode($combined_order->shipping_address)->name;
$phone = json_decode($combined_order->shipping_address)->phone;
$email = json_decode($combined_order->shipping_address)->email;
$address = json_decode($combined_order->shipping_address)->address;
$city = json_decode($combined_order->shipping_address)->city;
return PayhereUtility::create_checkout_form($combined_order_id, $amount, $first_name, $last_name, $phone, $email, $address, $city);
}
elseif ($paymentType == 'order_re_payment') {
$order = Order::findOrFail($paymentData['order_id']);
$order_id = $order->id;
$amount = $order->grand_total;
$first_name = json_decode($order->shipping_address)->name;
$phone = json_decode($order->shipping_address)->phone;
$email = json_decode($order->shipping_address)->email;
$address = json_decode($order->shipping_address)->address;
$city = json_decode($order->shipping_address)->city;
return PayhereUtility::create_order_re_payment_form($order_id, $amount, $first_name, $last_name, $phone, $email, $address, $city);
}
elseif ($paymentType == 'wallet_payment') {
$order_id = rand(100000, 999999);
$amount = $request->amount;
return PayhereUtility::create_wallet_form($user_id, $order_id, $amount, $first_name, $last_name, $phone, $email, $address, $city);
}
elseif ($paymentType == 'customer_package_payment') {
$customer_package = CustomerPackage::findOrFail($paymentData['customer_package_id']);
$order_id = rand(100000, 999999);
$package_id = $customer_package->id;
$amount = $customer_package->amount;
return PayhereUtility::create_customer_package_form($user_id, $package_id, $order_id, $amount, $first_name, $last_name, $phone, $email, $address, $city);
}
elseif ($paymentType == 'seller_package_payment') {
$seller_package = SellerPackage::findOrFail($paymentData['seller_package_id']);
$order_id = rand(100000, 999999);
$package_id = $seller_package->id;
$amount = $seller_package->amount;
return PayhereUtility::create_seller_package_form($user_id, $package_id, $order_id, $amount, $first_name, $last_name, $phone, $email, $address, $city);
}
}
}
public function checkout_testing()
{
$order_id = rand(100000, 999999);
$amount = 88.00;
$first_name = 'Hasan';
$last_name = 'Taluker';
$phone = '2135421321';
$email = 'hasan@taluker.com';
$address = '22/b baker street';
$city = 'Colombo';
return PayhereUtility::create_checkout_form($order_id, $amount, $first_name, $last_name, $phone, $email, $address, $city);
}
public function wallet_testing()
{
$order_id = rand(100000, 999999);
$user_id = Auth::user()->id;
$amount = 88.00;
$first_name = 'Hasan';
$last_name = 'Taluker';
$phone = '2135421321';
$email = 'hasan@taluker.com';
$address = '22/b baker street';
$city = 'Colombo';
return PayhereUtility::create_wallet_form($user_id, $order_id, $amount, $first_name, $last_name, $phone, $email, $address, $city);
}
public function customer_package_payment_testing()
{
$order_id = rand(100000, 999999);
$user_id = Auth::user()->id;
$package_id = 4;
$amount = 88.00;
$first_name = 'Hasan';
$last_name = 'Taluker';
$phone = '2135421321';
$email = 'hasan@taluker.com';
$address = '22/b baker street';
$city = 'Colombo';
return PayhereUtility::create_customer_package_form($user_id, $package_id, $order_id, $amount, $first_name, $last_name, $phone, $email, $address, $city);
}
//sample response
/*
{
"merchant_id":"1215091",
"order_id":"196696714",
"payment_id":"320025078020",
"payhere_amount":"99.00",
"payhere_currency":"LKR",
"status_code":"2",
"md5sig":"F889DBDF7BF987529C77096E465B749B",
"custom_1":"788392",
"custom_2":"",
"status_message":"Successfully completed the payment.",
"method":"TEST",
"card_holder_name":"ddd",
"card_no":"************1292",
"card_expiry":"1221",
"recurring":"0"
}
*/
//checkout related functions ------------------------------------
public static function checkout_notify()
{
$merchant_id = $_POST['merchant_id'];
$order_id = $_POST['order_id'];
$payhere_amount = $_POST['payhere_amount'];
$payhere_currency = $_POST['payhere_currency'];
$status_code = $_POST['status_code'];
$md5sig = $_POST['md5sig'];
$merchant_secret = env('PAYHERE_SECRET'); // Replace with your Merchant Secret (Can be found on your PayHere account's Settings page)
$local_md5sig = strtoupper(md5($merchant_id . $order_id . $payhere_amount . $payhere_currency . $status_code . strtoupper(md5($merchant_secret))));
if (($local_md5sig === $md5sig) and ($status_code == 2)) {
//custom_1 will have order_id
return PayhereController::checkout_success($_POST['custom_1'], $_POST);
}
return PayhereController::checkout_incomplete();
}
public static function checkout_return()
{
Session::put('cart', collect([]));
Session::forget('payment_type');
Session::forget('delivery_info');
Session::forget('coupon_id');
Session::forget('coupon_discount');
flash(translate('Payment process completed'))->success();
return redirect()->route('order_confirmed');
}
public static function checkout_cancel()
{
return PayhereController::checkout_incomplete();
}
public static function checkout_success($combined_order_id, $responses)
{
$payment_details = json_encode($responses);
return (new CheckoutController)->checkout_done($combined_order_id, $payment_details);
}
public static function checkout_incomplete()
{
Session::forget('order_id');
flash(translate("Incomplete"))->error();
return redirect()->route('home')->send();
}
//checkout related functions ------------------------------------
// Order Re payment Related Functions -----------------------------
public static function orderRepaymentNotify()
{
$merchant_id = $_POST['merchant_id'];
$order_id = $_POST['order_id'];
$payhere_amount = $_POST['payhere_amount'];
$payhere_currency = $_POST['payhere_currency'];
$status_code = $_POST['status_code'];
$md5sig = $_POST['md5sig'];
$merchant_secret = env('PAYHERE_SECRET'); // Replace with your Merchant Secret (Can be found on your PayHere account's Settings page)
$local_md5sig = strtoupper(md5($merchant_id . $order_id . $payhere_amount . $payhere_currency . $status_code . strtoupper(md5($merchant_secret))));
if (($local_md5sig === $md5sig) and ($status_code == 2)) {
//custom_1 will have order_id
return PayhereController::orderRepaymentSuccess($_POST['custom_1'], $_POST);
}
return PayhereController::orderRepaymentIncomplete();
}
public static function orderRepaymentReturn()
{
Session::forget('order_id');
Session::forget('payment_data');
flash(translate('Payment process completed'))->success();
return redirect()->route('dashboard');
}
public static function orderRepaymentCancel()
{
return PayhereController::orderRepaymentIncomplete();
}
public static function orderRepaymentSuccess($order_id, $responses)
{
$payment_details = json_encode($responses);
$data['order_id'] = $order_id;
$data['payment_method'] = 'payhere';
return (new CheckoutController)->orderRePaymentDone($data, $payment_details);
}
public static function orderRepaymentIncomplete()
{
Session::forget('order_id');
Session::forget('payment_data');
flash(translate("Payment Incomplete"))->error();
return redirect()->route('home')->send();
}
// Order Re payment Related Functions End--------------------------
//wallet related functions ------------------------------------
public static function wallet_notify()
{
$merchant_id = $_POST['merchant_id'];
$order_id = $_POST['order_id'];
$payhere_amount = $_POST['payhere_amount'];
$payhere_currency = $_POST['payhere_currency'];
$status_code = $_POST['status_code'];
$md5sig = $_POST['md5sig'];
$merchant_secret = env('PAYHERE_SECRET'); // Replace with your Merchant Secret (Can be found on your PayHere account's Settings page)
$local_md5sig = strtoupper(md5($merchant_id . $order_id . $payhere_amount . $payhere_currency . $status_code . strtoupper(md5($merchant_secret))));
if (($local_md5sig === $md5sig) and ($status_code == 2)) {
//custom_1 will have user_id
return PayhereController::wallet_success($_POST['custom_1'], $payhere_amount, $_POST);
}
return PayhereController::wallet_incomplete();
}
public static function wallet_return()
{
Session::forget('payment_data');
Session::forget('payment_type');
flash(translate('Payment process completed'))->success();
return redirect()->route('wallet.index');
}
public static function wallet_cancel()
{
return PayhereController::wallet_incomplete();
}
public static function wallet_success($id, $amount, $payment_details)
{
$user = User::find($id);
$user->balance = $user->balance + $amount;
$user->save();
$wallet = new Wallet;
$wallet->user_id = $user->id;
$wallet->amount = $amount;
$wallet->payment_method = 'payhere';
$wallet->payment_details = json_encode($payment_details);
$wallet->save();
}
public static function wallet_incomplete()
{
Session::forget('payment_data');
flash(translate('Payment Incomplete'))->error();
return redirect()->route('home')->send();
}
//wallet related functions ------------------------------------
//customer package related functions ------------------------------------
public static function customer_package_notify()
{
$merchant_id = $_POST['merchant_id'];
$order_id = $_POST['order_id'];
$payhere_amount = $_POST['payhere_amount'];
$payhere_currency = $_POST['payhere_currency'];
$status_code = $_POST['status_code'];
$md5sig = $_POST['md5sig'];
$merchant_secret = env('PAYHERE_SECRET'); // Replace with your Merchant Secret (Can be found on your PayHere account's Settings page)
$local_md5sig = strtoupper(md5($merchant_id . $order_id . $payhere_amount . $payhere_currency . $status_code . strtoupper(md5($merchant_secret))));
if (($local_md5sig === $md5sig) and ($status_code == 2)) {
//custom_1 will have user_id custom_2 will have package_id
return PayhereController::customer_package_success($_POST['custom_1'], $_POST['custom_2'], $_POST);
}
return PayhereController::customer_package_incomplete();
}
public static function customer_package_return()
{
Session::forget('payment_data');
flash(translate('Payment process completed'))->success();
return redirect()->route('dashboard');
}
public static function customer_package_cancel()
{
return PayhereController::customer_package_incomplete();
}
public static function customer_package_success($id, $customer_package_id, $payment_details)
{
$user = User::findOrFail($id);
$user->customer_package_id = $customer_package_id;
$customer_package = CustomerPackage::findOrFail($customer_package_id);
$user->remaining_uploads += $customer_package->product_upload;
$user->save();
$customer_package_payment = new CustomerPackagePayment();
$customer_package_payment->user_id = $user->id;
$customer_package_payment->customer_package_id = $customer_package_id;
$customer_package_payment->amount = $customer_package->amount;
$customer_package_payment->payment_method = 'payhere';
$customer_package_payment->payment_details = $payment_details;
$customer_package_payment->save();
}
public static function customer_package_incomplete()
{
Session::forget('payment_data');
flash(translate("Payment Incomplete"))->error();
return redirect()->route('home')->send();
}
//customer package related functions ------------------------------------
//Seller package related functions ------------------------------------
public static function sellerPackageNotify()
{
$merchant_id = $_POST['merchant_id'];
$order_id = $_POST['order_id'];
$payhere_amount = $_POST['payhere_amount'];
$payhere_currency = $_POST['payhere_currency'];
$status_code = $_POST['status_code'];
$md5sig = $_POST['md5sig'];
$merchant_secret = env('PAYHERE_SECRET'); // Replace with your Merchant Secret (Can be found on your PayHere account's Settings page)
$local_md5sig = strtoupper(md5($merchant_id . $order_id . $payhere_amount . $payhere_currency . $status_code . strtoupper(md5($merchant_secret))));
if (($local_md5sig === $md5sig) and ($status_code == 2)) {
return PayhereController::sellerPackageSuccess($_POST);
}
return PayhereController::sellerPackageIncomplete();
}
public static function sellerPackageReturn()
{
Session::forget('payment_data');
flash(translate('Payment process completed'))->success();
return redirect()->route('dashboard');
}
public static function sellerPackageCancel()
{
return PayhereController::sellerPackageIncomplete();
}
public static function sellerPackageSuccess($responses)
{
return (new SellerPackageController)->purchase_payment_done(Session::get('payment_data'), json_encode($responses));
}
public static function sellerPackageIncomplete()
{
Session::forget('payment_data');
flash(translate("Payment Incomplete"))->error();
return redirect()->route('home')->send();
}
//Seller package related functions ------------------------------------