HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: //www/wwwroot/www.shooperm.com/app/Repositories/NewUserZoneRepository.php
<?php
namespace App\Repositories;

use Modules\Marketing\Entities\CustomerCouponStore;
use Modules\Marketing\Entities\NewUserZone;
use Modules\Marketing\Entities\NewUserZoneCategory;
use Modules\Marketing\Entities\NewUserZoneCouponCategory;
use Modules\Marketing\Entities\NewUserZoneProduct;
use Modules\Product\Entities\Category;
use Modules\Seller\Entities\SellerProduct;

class NewUserZoneRepository{

    public function getById($slug){

        return NewUserZone::with('products', 'categories', 'coupon', 'couponCategories', 'products.product.skus', 'categories.category', 'coupon.coupon','couponCategories.category')->where('slug',$slug)->firstOrFail();
    }

    public function getCategoryById($id){

        return NewUserZoneCategory::findOrFail($id);
    }
    public function getCouponCategoryById($id){

        return NewUserZoneCouponCategory::findOrFail($id);

    }

    public function getSellerProducts(){
        $products =  SellerProduct::where('status', 1)->activeSeller()->paginate(12);
        $products->appends([
            'item' => 'category'
        ]);
        return $products;
    }

    public function getAllProductsForCategories($slug){
        $new_user_zone = NewUserZone::where('slug', $slug)->first();
        $categories = Category::whereHas('newUserZoneCategories', function($query) use($new_user_zone){
            $query->where('new_user_zone_id', $new_user_zone->id);
        })->where('status', 1)->pluck('id');
        $products =  SellerProduct::with('product','reviews','wishList','skus')->where('status', 1)->whereHas('product', function($query) use($categories){
            $query->whereHas('categories', function($q1)use($categories){
                $q1->whereIn('category_id',$categories);
            })->where('status', 1);
        })->activeSeller()->paginate(12);
        $products->appends([
            'item' => 'category'
        ]);
        return $products;
    }

    public function getAllProductsForCouponCategories($slug){
        $new_user_zone = NewUserZone::where('slug', $slug)->first();
        $categories = Category::whereHas('newUserZoneCouponCategories', function($query) use($new_user_zone){
            $query->where('new_user_zone_id', $new_user_zone->id);
        })->where('status', 1)->pluck('id');
        $products =  SellerProduct::with('product','reviews','wishList','skus')->where('status', 1)->whereHas('product', function($query) use($categories){
            $query->whereHas('categories', function($q1)use($categories){
                $q1->whereIn('category_id',$categories);
            })->where('status', 1);
        })->activeSeller()->paginate(12);
        $products->appends([
            'item' => 'category'
        ]);
        return $products;
    }
    
    public function newUserZoneProducts($id){
        return NewUserZoneProduct::where('new_user_zone_id', $id)->get();
    }

    public function couponStore($data){
        return CustomerCouponStore::create([
            'coupon_id' => $data['coupon_id'],
            'customer_id' => auth()->user()->id
        ]);
    }
    
}