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/Modules/AdminReport/Repositories/SellerReportRepository.php
<?php

namespace Modules\AdminReport\Repositories;

use App\Models\Order;
use App\Models\OrderPackageDetail;
use App\Models\OrderPayment;
use App\Models\Wishlist;
use Illuminate\Support\Facades\DB;
use Modules\PaymentGateway\Entities\PaymentMethod;
use Modules\Product\Entities\Product;
use Modules\Review\Entities\ProductReview;
use Modules\Review\Entities\SellerReview;
use Modules\MultiVendor\Entities\SellerAccount;
use Modules\Seller\Entities\SellerProduct;
use Modules\Wallet\Entities\WalletBalance;

class SellerReportRepository
{

    public function topSeller()
    {
        return SellerAccount::orderBy('total_sale_qty', 'desc')->with('user');
    }



    public function topCustomer()
    {
        $orderPackage = OrderPackageDetail::where('seller_id', auth()->id())->pluck('order_id')->toArray();
        $customers = Order::whereIn('id', $orderPackage)->pluck('customer_id')->toArray();

        return OrderPayment::whereIn('user_id', $customers)
            ->where('status', 1)
            ->select(DB::raw('user_id as user_id'), DB::raw('sum(amount) as total'))
            ->groupBy(DB::raw('user_id'))
            ->with('user')
            ->orderBy('total', 'desc');
    }



    public function topSellingItem()
    {
        return SellerProduct::where('user_id', auth()->id())->where('status', 1)->with('product', 'seller')->orderBy('total_sale', 'desc');
    }



    public function review()
    {
        return SellerReview::where('seller_id', auth()->id())
            ->where('status', 1)
            ->select('seller_id', DB::raw('avg(rating) as rating'), DB::raw('count(*) as number_of_review'))
            ->groupBy('seller_id')
            ->with('seller');
    }



    public function products()
    {
        return Product::with('brand', 'category', 'seller')->where('is_approved', 1)->latest();
    }



    public function order()
    {
        $orderPackage = OrderPackageDetail::where('seller_id', auth()->id())->pluck('order_id')->toArray();
        return Order::whereIn('id', $orderPackage)->with('packages', 'customer')->latest();
    }
}