Actualizacuion de Rama Kquiroz

This commit is contained in:
ellecio2
2023-09-04 19:53:37 -04:00
parent d2e9ba53ab
commit 2e99d7b290
2206 changed files with 100145 additions and 467275 deletions

View File

@@ -1,27 +1,50 @@
<?php
use Carbon\Carbon;
use App\Models\Tax;
use App\Models\Cart;
use App\Models\City;
use App\Models\Shop;
use App\Models\User;
use App\Models\Addon;
use App\Models\Brand;
use App\Models\Color;
use App\Models\Order;
use App\Models\Coupon;
use App\Models\Seller;
use App\Models\Upload;
use App\Models\Wallet;
use App\Models\Address;
use App\Models\Carrier;
use App\Models\Country;
use App\Models\Product;
use App\Models\Category;
use App\Models\Currency;
use App\Models\Language;
use App\Models\Wishlist;
use App\Models\Attribute;
use App\Models\ClubPoint;
use App\Models\FlashDeal;
use App\Models\CouponUsage;
use App\Models\DeliveryBoy;
use App\Models\OrderDetail;
use App\Models\PickupPoint;
use App\Models\Translation;
use App\Models\BlogCategory;
use App\Models\Conversation;
use App\Models\FollowSeller;
use App\Models\ProductStock;
use App\Models\CombinedOrder;
use App\Models\SellerPackage;
use App\Models\AffiliateConfig;
use App\Models\AffiliateOption;
use App\Models\BusinessSetting;
use App\Models\CustomerPackage;
use App\Models\CustomerProduct;
use App\Utility\SendSMSUtility;
use App\Utility\CategoryUtility;
use App\Models\AuctionProductBid;
use App\Models\ManualPaymentMethod;
use App\Models\SellerPackagePayment;
use App\Utility\NotificationUtility;
use App\Http\Resources\V2\CarrierCollection;
@@ -29,11 +52,6 @@ use App\Http\Controllers\AffiliateController;
use App\Http\Controllers\ClubPointController;
use App\Http\Controllers\CommissionController;
use AizPackages\ColorCodeConverter\Services\ColorCodeConverter;
use App\Models\Brand;
use App\Models\Category;
use App\Models\CustomerProduct;
use App\Models\FlashDeal;
use App\Models\Language;
//sensSMS function for OTP
if (!function_exists('sendSMS')) {
@@ -91,6 +109,15 @@ if (!function_exists('convert_to_kes')) {
}
}
// get all active countries
if (!function_exists('get_active_countries')) {
function get_active_countries()
{
$country_query = Country::query();
return $country_query->isEnabled()->get();
}
}
//filter products based on vendor activation system
if (!function_exists('filter_products')) {
function filter_products($products)
@@ -214,7 +241,6 @@ if (!function_exists('format_price')) {
}
}
//formats price to home default price with convertion
if (!function_exists('single_price')) {
function single_price($price)
@@ -1145,11 +1171,11 @@ if (!function_exists('my_asset')) {
*/
function my_asset($path, $secure = null)
{
if (env('FILESYSTEM_DRIVER') == 's3') {
return Storage::disk('s3')->url($path);
} else {
return app('url')->asset('public/' . $path, $secure);
}
if (env('FILESYSTEM_DRIVER') != 'local') {
return Storage::disk(env('FILESYSTEM_DRIVER'))->url($path);
}
return app('url')->asset('public/' . $path, $secure);
}
}
@@ -1189,11 +1215,11 @@ if (!function_exists('getBaseURL')) {
if (!function_exists('getFileBaseURL')) {
function getFileBaseURL()
{
if (env('FILESYSTEM_DRIVER') == 's3') {
return env('AWS_URL') . '/';
} else {
return getBaseURL() . 'public/';
if (env('FILESYSTEM_DRIVER') != 'local') {
return env(Str::upper(env('FILESYSTEM_DRIVER')).'_URL') . '/';
}
return getBaseURL() . 'public/';
}
}
@@ -1328,6 +1354,20 @@ if (!function_exists('checkout_done')) {
}
}
// get user total ordered products
if (!function_exists('get_user_total_ordered_products')) {
function get_user_total_ordered_products()
{
$orders_query = Order::query();
$orders = $orders_query->where('user_id', Auth::user()->id)->get();
$total = 0;
foreach ($orders as $order) {
$total += count($order->orderDetails);
}
return $total;
}
}
//for api
if (!function_exists('wallet_payment_done')) {
function wallet_payment_done($user_id, $amount, $payment_method, $payment_details)
@@ -1475,11 +1515,20 @@ if (!function_exists('get_url_params')) {
}
}
// get Admin
if (!function_exists('get_admin')) {
function get_admin()
{
$admin_query = User::query();
return $admin_query->where('user_type', 'admin')->first();
}
}
if (!function_exists('get_featured_flash_deal')) {
function get_featured_flash_deal()
{
$featured_flash_deal_query = FlashDeal::query();
$featured_flash_deal = $featured_flash_deal_query->where('status', 1)->where('featured', 1)
$featured_flash_deal = $featured_flash_deal_query->isActiveAndFeatured()
->where('start_date', '<=', strtotime(date('Y-m-d H:i:s')))
->where('end_date', '>=', strtotime(date('Y-m-d H:i:s')))
->first();
@@ -1488,6 +1537,26 @@ if (!function_exists('get_featured_flash_deal')) {
}
}
if (!function_exists('get_active_flash_deals')) {
function get_active_flash_deals()
{
$activated_flash_deal_query = FlashDeal::query();
$activated_flash_deal_query = $activated_flash_deal_query->where("status", 1);
return $activated_flash_deal_query->get();
}
}
if (!function_exists('get_active_taxes')) {
function get_active_taxes()
{
$activated_tax_query = Tax::query();
$activated_tax_query = $activated_tax_query->where("tax_status", 1);
return $activated_tax_query->get();
}
}
if (!function_exists('get_system_language')) {
function get_system_language()
{
@@ -1514,6 +1583,15 @@ if (!function_exists('get_all_active_language')) {
}
}
// get Session langauge
if (!function_exists('get_session_language')) {
function get_session_language()
{
$language_query = Language::query();
return $language_query->where('code', Session::get('locale', Config::get('app.locale')))->first();
}
}
if (!function_exists('get_system_currency')) {
function get_system_currency()
{
@@ -1532,34 +1610,131 @@ if (!function_exists('get_system_currency')) {
if (!function_exists('get_all_active_currency')) {
function get_all_active_currency()
{
$language_query = Currency::query();
$language_query->where('status', 1);
$currency_query = Currency::query();
$currency_query->where('status', 1);
return $language_query->get();
return $currency_query->get();
}
}
if (!function_exists('get_single_product')) {
function get_single_product($product_id)
{
$product_query = Product::query();
$product_query = Product::query()->with('thumbnail');
return $product_query->find($product_id);
}
}
if (!function_exists('get_single_brand')) {
function get_single_brand($brand_id)
// get multiple Products
if (!function_exists('get_multiple_products')) {
function get_multiple_products($product_ids)
{
$brand_query = Brand::query();
return $brand_query->find($brand_id);
$products_query = Product::query();
return $products_query->whereIn('id', $product_ids)->get();
}
}
if (!function_exists('get_single_category')) {
function get_single_category($category_id)
// get count of products
if (!function_exists('get_products_count')) {
function get_products_count($user_id = null)
{
$category_query = Category::query();
return $category_query->find($category_id);
$products_query = Product::query();
if($user_id){
$products_query = $products_query->where('user_id', $user_id);
}
return $products_query->isApprovedPublished()->count();
}
}
// get minimum unit price of products
if (!function_exists('get_product_min_unit_price')) {
function get_product_min_unit_price($user_id = null)
{
$product_query = Product::query();
if($user_id){
$product_query = $product_query->where('user_id', $user_id);
}
return $product_query->isApprovedPublished()->min('unit_price');
}
}
// get maximum unit price of products
if (!function_exists('get_product_max_unit_price')) {
function get_product_max_unit_price($user_id = null)
{
$product_query = Product::query();
if($user_id){
$product_query = $product_query->where('user_id', $user_id);
}
return $product_query->isApprovedPublished()->max('unit_price');
}
}
if (!function_exists('get_featured_products')) {
function get_featured_products()
{
return Cache::remember('featured_products', 3600, function () {
$product_query = Product::query();
return filter_products($product_query->where('featured', '1'))->latest()->limit(12)->get();
});
}
}
if (!function_exists('get_best_selling_products')) {
function get_best_selling_products($limit, $user_id=null)
{
$product_query = Product::query();
if($user_id){
$product_query = $product_query->where('user_id', $user_id);
}
return filter_products($product_query->orderBy('num_of_sale', 'desc'))->limit($limit)->get();
}
}
// Get Seller Products
if (!function_exists('get_all_sellers')) {
function get_all_sellers()
{
$seller_query = Seller::query();
return $seller_query->get();
}
}
// Get Seller Products
if (!function_exists('get_seller_products')) {
function get_seller_products($user_id)
{
$product_query = Product::query();
return $product_query->where('user_id', $user_id)->isApprovedPublished()->orderBy('created_at', 'desc')->limit(15)->get();
}
}
// Get Seller Best Selling Products
if (!function_exists('get_shop_best_selling_products')) {
function get_shop_best_selling_products($user_id)
{
$product_query = Product::query();
return $product_query->where('user_id', $user_id)->isApprovedPublished()->orderBy('num_of_sale', 'desc')->paginate(24);
}
}
// Get all auction Products
if (!function_exists('get_all_auction_products')) {
function get_auction_products($limit=null, $paginate=null)
{
$product_query = Product::query();
$products = $product_query->latest()->where('published', 1)->where('auction_product', 1);
if (get_setting('seller_auction_product') == 0) {
$products = $products->where('added_by', 'admin');
}
$products = $products->where('auction_start_date', '<=', strtotime("now"))->where('auction_end_date', '>=', strtotime("now"));
if($limit){
$products = $products->limit($limit);
}elseif($paginate){
return $products->paginate($paginate);
}
return $products->get();
}
}
@@ -1597,6 +1772,119 @@ if (!function_exists('get_home_page_classified_products')) {
}
}
// Get related product
if (!function_exists('get_related_products')) {
function get_related_products($product)
{
$product_query = Product::query();
return filter_products($product_query->where('id', '!=', $product->id)->where('category_id', $product->category_id))->limit(10)->get();
}
}
// Get all brands
if (!function_exists('get_all_brands')) {
function get_all_brands()
{
$brand_query = Brand::query();
return $brand_query->get();
}
}
// Get single brands
if (!function_exists('get_single_brand')) {
function get_single_brand($brand_id)
{
$brand_query = Brand::query();
return $brand_query->find($brand_id);
}
}
// Get Brands by products
if (!function_exists('get_brands_by_products')) {
function get_brands_by_products($usrt_id)
{
$product_query = Product::query();
$brand_ids = $product_query->where('user_id', $usrt_id)->isApprovedPublished()->whereNotNull('brand_id')->pluck('brand_id')->toArray();
$brand_query = Brand::query();
return $brand_query->whereIn('id', $brand_ids)->get();
}
}
// Get single category
if (!function_exists('get_single_category')) {
function get_single_category($category_id)
{
$category_query = Category::query()->with('coverImage');
return $category_query->find($category_id);
}
}
// Get categories by level zero
if (!function_exists('get_level_zero_categories')) {
function get_level_zero_categories()
{
$categories_query = Category::query();
return $categories_query->where('level', 0)->orderBy('order_level', 'desc')->get();
}
}
// Get categories by products
if (!function_exists('get_categories_by_products')) {
function get_categories_by_products($user_id)
{
$product_query = Product::query();
$category_ids = $product_query->where('user_id', $user_id)->isApprovedPublished()->pluck('category_id')->toArray();
$category_query = Category::query();
return $category_query->whereIn('id', $category_ids)->get();
}
}
// Get single Color name
if (!function_exists('get_single_color_name')) {
function get_single_color_name($color)
{
$color_query = Color::query();
return $color_query->where('code', $color)->first()->name;
}
}
// Get single Attribute
if (!function_exists('get_single_attribute_name')) {
function get_single_attribute_name($attribute)
{
$attribute_query = Attribute::query();
return $attribute_query->find($attribute)->getTranslation('name');
}
}
// Get user cart
if (!function_exists('get_user_cart')) {
function get_user_cart()
{
$cart = null;
if (auth()->user() != null) {
$cart = Cart::where('user_id', Auth::user()->id)->get();
} else {
$temp_user_id = Session()->get('temp_user_id');
if ($temp_user_id) {
$cart = Cart::where('temp_user_id', $temp_user_id)->get();
}
}
return $cart;
}
}
// Get user Wishlist
if (!function_exists('get_user_wishlist')) {
function get_user_wishlist()
{
$wishlist_query = Wishlist::query();
return $wishlist_query->where('user_id', Auth::user()->id)->get();
}
}
//Get best seller
if (!function_exists('get_best_sellers')) {
function get_best_sellers($limit = '')
@@ -1607,6 +1895,271 @@ if (!function_exists('get_best_sellers')) {
}
}
//Get users followed sellers
if (!function_exists('get_followed_sellers')) {
function get_followed_sellers()
{
$followed_seller_query = FollowSeller::query();
return $followed_seller_query->where('user_id', Auth::user()->id)->pluck('shop_id')->toArray();
}
}
// Get Order Details
if (!function_exists('get_order_details')) {
function get_order_details($order_id)
{
$order_detail_query = OrderDetail::query();
return $order_detail_query->find($order_id);
}
}
// Get Order Details by review
if (!function_exists('get_order_details_by_review')) {
function get_order_details_by_review($review)
{
$order_detail_query = OrderDetail::query();
return $order_detail_query->with(['order' => function ($q) use($review) {
$q->where('user_id', $review->user_id);
}])->where('product_id', $review->product_id)->where('delivery_status', 'delivered')->first();
}
}
// Get user total expenditure
if (!function_exists('get_user_total_expenditure')) {
function get_user_total_expenditure()
{
$user_expenditure_query = Order::query();
return $user_expenditure_query->where('user_id', Auth::user()->id)->where('payment_status', 'paid')->sum('grand_total');
}
}
// Get count by delivery viewed
if (!function_exists('get_count_by_delivery_viewed')) {
function get_count_by_delivery_viewed()
{
$order_query = Order::query();
return $order_query->where('user_id', Auth::user()->id)->where('delivery_viewed', 0)->get()->count();
}
}
// Get delivery boy info
if (!function_exists('get_delivery_boy_info')) {
function get_delivery_boy_info()
{
$delivery_boy_info_query = DeliveryBoy::query();
return $delivery_boy_info_query->where('user_id', Auth::user()->id)->first();
}
}
// Get count by completed delivery
if (!function_exists('get_delivery_boy_total_completed_delivery')) {
function get_delivery_boy_total_completed_delivery()
{
$delivery_boy_delivery_query = Order::query();
return $delivery_boy_delivery_query->where('assign_delivery_boy', Auth::user()->id)
->where('delivery_status', 'delivered')
->count();
}
}
// Get count by pending delivery
if (!function_exists('get_delivery_boy_total_pending_delivery')) {
function get_delivery_boy_total_pending_delivery()
{
$delivery_boy_delivery_query = Order::query();
return $delivery_boy_delivery_query->where('assign_delivery_boy', Auth::user()->id)
->where('delivery_status', '!=', 'delivered')
->where('delivery_status', '!=', 'cancelled')
->where('cancel_request', '0')
->count();
}
}
// Get count by cancelled delivery
if (!function_exists('get_delivery_boy_total_cancelled_delivery')) {
function get_delivery_boy_total_cancelled_delivery()
{
$delivery_boy_delivery_query = Order::query();
return $delivery_boy_delivery_query->where('assign_delivery_boy', Auth::user()->id)
->where('delivery_status', 'cancelled')
->count();
}
}
// Get count by payment status viewed
if (!function_exists('get_order_info')) {
function get_order_info($order_id = null)
{
$order_query = Order::query();
return $order_query->where('id',$order_id)->first();
}
}
// Get count by payment status viewed
if (!function_exists('get_user_order_by_id')) {
function get_user_order_by_id($order_id = null)
{
$order_query = Order::query();
return $order_query->where('id',$order_id)->where('user_id',Auth::user()->id)->first();
}
}
// Get Auction Product Bid Info
if (!function_exists('get_auction_product_bid_info')) {
function get_auction_product_bid_info($bid_id = null)
{
$product_bid_info_query = AuctionProductBid::query();
return $product_bid_info_query->where('id',$bid_id)->first();
}
}
// Get count by payment status viewed
if (!function_exists('get_count_by_payment_status_viewed')) {
function get_count_by_payment_status_viewed()
{
$order_query = Order::query();
return $order_query->where('user_id', Auth::user()->id)->where('payment_status_viewed', 0)->get()->count();
}
}
// Get Uploaded file
if (!function_exists('get_single_uploaded_file')) {
function get_single_uploaded_file($file_id)
{
$file_query = Upload::query();
return $file_query->find($file_id);
}
}
// Get single customer package file
if (!function_exists('get_single_customer_package')) {
function get_single_customer_package($package_id)
{
$customer_package_query = CustomerPackage::query();
return $customer_package_query->find($package_id);
}
}
// Get single Seller package file
if (!function_exists('get_single_seller_package')) {
function get_single_seller_package($package_id)
{
$seller_package_query = SellerPackage::query();
return $seller_package_query->find($package_id);
}
}
// Get user last wallet recharge
if (!function_exists('get_user_last_wallet_recharge')) {
function get_user_last_wallet_recharge()
{
$recharge_query = Wallet::query();
return $recharge_query->where('user_id', Auth::user()->id)->orderBy('id', 'desc')->first();
}
}
// Get user total Club point
if (!function_exists('get_user_total_club_point')) {
function get_user_total_club_point()
{
$club_point_query = ClubPoint::query();
return $club_point_query->where('user_id', Auth::user()->id)->where('convert_status', 0)->sum('points');
}
}
// Get all manual payment methods
if (!function_exists('get_all_manual_payment_methods')) {
function get_all_manual_payment_methods()
{
$manual_payment_methods_query = ManualPaymentMethod::query();
return $manual_payment_methods_query->get();
}
}
// Get all blog category
if (!function_exists('get_all_blog_categories')) {
function get_all_blog_categories()
{
$blog_category_query = BlogCategory::query();
return $blog_category_query->get();
}
}
// Get all Pickup Points
if (!function_exists('get_all_pickup_points')) {
function get_all_pickup_points()
{
$pickup_points_query = PickupPoint::query();
return $pickup_points_query->isActive()->get();
}
}
// get Shop by user id
if (!function_exists('get_shop_by_user_id')) {
function get_shop_by_user_id($user_id)
{
$shop_query = Shop::query();
return $shop_query->where('user_id', $user_id)->first();
}
}
// get Coupons
if (!function_exists('get_coupons')) {
function get_coupons($user_id = null, $paginate = null)
{
$coupon_query = Coupon::query();
$coupon_query = $coupon_query->where('start_date', '<=', strtotime(date('d-m-Y')))->where('end_date', '>=', strtotime(date('d-m-Y')));
if($user_id){
$coupon_query = $coupon_query-> where('user_id', $user_id);
}
if($paginate){
return $coupon_query->paginate($paginate);
}
return $coupon_query->get();
}
}
// get non-viewed Conversations
if (!function_exists('get_non_viewed_conversations')) {
function get_non_viewed_conversations()
{
$Conversation_query = Conversation::query();
return $Conversation_query->where('sender_id', Auth::user()->id)->where('sender_viewed', 0)->get();
}
}
// get affliate option status
if (!function_exists('get_affliate_option_status')) {
function get_affliate_option_status($status = false)
{
if(AffiliateOption::where('type', 'product_sharing')->first()->status ||
AffiliateOption::where('type', 'category_wise_affiliate')->first()->status){
$status = true;
}
return $status;
}
}
// get affliate option purchase status
if (!function_exists('get_affliate_purchase_option_status')) {
function get_affliate_purchase_option_status($status = false)
{
if(AffiliateOption::where('type', 'user_registration_first_purchase')->first()->status){
$status = true;
}
return $status;
}
}
// get affliate config
if (!function_exists('get_Affiliate_onfig_value')) {
function get_Affiliate_onfig_value()
{
return AffiliateConfig::where('type', 'verification_form')->first()->value;
}
}
if (!function_exists('timezones')) {
function timezones()
{