!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/laravel-crm/packages/Webkul/Admin/src/Http/Controllers/Settings/   drwxrwxrwx
Free 12.95 GB of 57.97 GB (22.34%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace Webkul\Admin\Http\Controllers\Settings;

use 
Illuminate\Http\JsonResponse;
use 
Illuminate\Http\RedirectResponse;
use 
Illuminate\Support\Facades\Event;
use 
Illuminate\View\View;
use 
Webkul\Admin\DataGrids\Settings\RoleDataGrid;
use 
Webkul\Admin\Http\Controllers\Controller;
use 
Webkul\User\Repositories\RoleRepository;

class 
RoleController extends Controller
{
    
/**
     * Create a new controller instance.
     *
     * @return void
     */
    
public function __construct(protected RoleRepository $roleRepository) {}

    
/**
     * Display a listing of the resource.
     */
    
public function index(): View|JsonResponse
    
{
        if (
request()->ajax()) {
            return 
datagrid(RoleDataGrid::class)->process();
        }

        return 
view('admin::settings.roles.index');
    }

    
/**
     * Show the form for creating a new resource.
     */
    
public function create(): View
    
{
        return 
view('admin::settings.roles.create');
    }

    
/**
     * Store a newly created resource in storage.
     */
    
public function store(): RedirectResponse
    
{
        
$this->validate(request(), [
            
'name'            => 'required',
            
'permission_type' => 'required|in:all,custom',
            
'description'     => 'required',
        ]);

        if (
request('permission_type') == 'custom') {
            
$this->validate(request(), [
                
'permissions' => 'required',
            ]);
        }

        
Event::dispatch('settings.role.create.before');

        
$data request()->only([
            
'name',
            
'description',
            
'permission_type',
            
'permissions',
        ]);

        
$role $this->roleRepository->create($data);

        
Event::dispatch('settings.role.create.after'$role);

        
session()->flash('success'trans('admin::app.settings.roles.index.create-success'));

        return 
redirect()->route('admin.settings.roles.index');
    }

    
/**
     * Show the form for editing the specified resource.
     */
    
public function edit(int $id): View
    
{
        
$role $this->roleRepository->findOrFail($id);

        return 
view('admin::settings.roles.edit'compact('role'));
    }

    
/**
     * Update the specified resource in storage.
     */
    
public function update(int $id): RedirectResponse
    
{
        
$this->validate(request(), [
            
'name'            => 'required',
            
'permission_type' => 'required|in:all,custom',
            
'description'     => 'required',
            
'permissions'     => 'required_if:permission_type,custom',
        ]);

        
Event::dispatch('settings.role.update.before'$id);

        
$data array_merge(request()->only([
            
'name',
            
'description',
            
'permission_type',
        ]), [
            
'permissions' => request()->has('permissions') ? request('permissions') : [],
        ]);

        
$role $this->roleRepository->update($data$id);

        
Event::dispatch('settings.role.update.after'$role);

        
session()->flash('success'trans('admin::app.settings.roles.index.update-success'));

        return 
redirect()->back();
    }

    
/**
     * Remove the specified resource from storage.
     */
    
public function destroy(int $id): JsonResponse
    
{
        
$response = [
            
'responseCode' => 400,
        ];

        
$role $this->roleRepository->findOrFail($id);

        if (
$role->users && $role->users->count() >= 1) {
            
$response['message'] = trans('admin::app.settings.roles.index.being-used');

            
session()->flash('error'$response['message']);
        } elseif (
$this->roleRepository->count() == 1) {
            
$response['message'] = trans('admin::app.settings.roles.index.last-delete-error');

            
session()->flash('error'$response['message']);
        } else {
            try {
                
Event::dispatch('settings.role.delete.before'$id);

                if (
auth()->guard('user')->user()->role_id == $id) {
                    
$response['message'] = trans('admin::app.settings.roles.index.current-role-delete-error');
                } else {
                    
$this->roleRepository->delete($id);

                    
Event::dispatch('settings.role.delete.after'$id);

                    
$message trans('admin::app.settings.roles.index.delete-success');

                    
$response = [
                        
'responseCode' => 200,
                        
'message'      => $message,
                    ];

                    
session()->flash('success'$message);
                }
            } catch (
\Exception $exception) {
                
$message $exception->getMessage();

                
$response['message'] = $message;

                
session()->flash('error'$message);
            }
        }

        return 
response()->json($response$response['responseCode']);
    }
}

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