!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/Contact/Persons/   drwxrwxrwx
Free 13.14 GB of 57.97 GB (22.67%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace Webkul\Admin\Http\Controllers\Contact\Persons;

use 
Exception;
use 
Illuminate\Http\JsonResponse;
use 
Illuminate\Http\RedirectResponse;
use 
Illuminate\Http\Resources\Json\JsonResource;
use 
Illuminate\Support\Facades\Event;
use 
Illuminate\View\View;
use 
Prettus\Repository\Criteria\RequestCriteria;
use 
Webkul\Admin\DataGrids\Contact\PersonDataGrid;
use 
Webkul\Admin\Http\Controllers\Controller;
use 
Webkul\Admin\Http\Requests\AttributeForm;
use 
Webkul\Admin\Http\Requests\MassDestroyRequest;
use 
Webkul\Admin\Http\Resources\PersonResource;
use 
Webkul\Contact\Repositories\PersonRepository;

class 
PersonController extends Controller
{
    
/**
     * Create a new class instance.
     *
     * @return void
     */
    
public function __construct(protected PersonRepository $personRepository)
    {
        
request()->request->add(['entity_type' => 'persons']);
    }

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

        return 
view('admin::contacts.persons.index');
    }

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

    
/**
     * Store a newly created resource in storage.
     */
    
public function store(AttributeForm $request): RedirectResponse|JsonResponse
    
{
        
Event::dispatch('contacts.person.create.before');

        
$person $this->personRepository->create($request->all());

        
Event::dispatch('contacts.person.create.after'$person);

        if (
request()->ajax()) {
            return 
response()->json([
                
'data'    => $person,
                
'message' => trans('admin::app.contacts.persons.index.create-success'),
            ]);
        }

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

        return 
redirect()->route('admin.contacts.persons.index');
    }

    
/**
     * Display the specified resource.
     */
    
public function show(int $id): View
    
{
        
$person $this->personRepository->findOrFail($id);

        return 
view('admin::contacts.persons.view'compact('person'));
    }

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

        return 
view('admin::contacts.persons.edit'compact('person'));
    }

    
/**
     * Update the specified resource in storage.
     */
    
public function update(AttributeForm $requestint $id): RedirectResponse|JsonResponse
    
{
        
Event::dispatch('contacts.person.update.before'$id);

        
$person $this->personRepository->update($request->all(), $id);

        
Event::dispatch('contacts.person.update.after'$person);

        if (
request()->ajax()) {
            return 
response()->json([
                
'data'    => $person,
                
'message' => trans('admin::app.contacts.persons.index.update-success'),
            ], 
200);
        }

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

        return 
redirect()->route('admin.contacts.persons.index');
    }

    
/**
     * Search person results.
     */
    
public function search(): JsonResource
    
{
        if (
$userIds bouncer()->getAuthorizedUserIds()) {
            
$persons $this->personRepository
                
->pushCriteria(app(RequestCriteria::class))
                ->
findWhereIn('user_id'$userIds);
        } else {
            
$persons $this->personRepository
                
->pushCriteria(app(RequestCriteria::class))
                ->
all();
        }

        return 
PersonResource::collection($persons);
    }

    
/**
     * Remove the specified resource from storage.
     */
    
public function destroy(int $id): JsonResponse
    
{
        
$person $this->personRepository->findOrFail($id);

        if (
            
$person->leads
            
&& $person->leads->count() > 0
        
) {
            return 
response()->json([
                
'message' => trans('admin::app.contacts.persons.index.delete-failed'),
            ], 
400);
        }

        try {
            
Event::dispatch('contacts.person.delete.before'$person);

            
$person->delete();

            
Event::dispatch('contacts.person.delete.after'$person);

            return 
response()->json([
                
'message' => trans('admin::app.contacts.persons.index.delete-success'),
            ], 
200);

        } catch (
Exception $exception) {
            return 
response()->json([
                
'message' => trans('admin::app.contacts.persons.index.delete-failed'),
            ], 
400);
        }
    }

    
/**
     * Mass destroy the specified resources from storage.
     */
    
public function massDestroy(MassDestroyRequest $request): JsonResponse
    
{
        try {
            
$persons $this->personRepository->findWhereIn('id'$request->input('indices', []));

            
$deletedCount 0;

            
$blockedCount 0;

            foreach (
$persons as $person) {
                if (
                    
$person->leads
                    
&& $person->leads->count() > 0
                
) {
                    
$blockedCount++;

                    continue;
                }

                
Event::dispatch('contact.person.delete.before'$person);

                
$this->personRepository->delete($person->id);

                
Event::dispatch('contact.person.delete.after'$person);

                
$deletedCount++;
            }

            
$statusCode 200;

            switch (
true) {
                case 
$deletedCount && $blockedCount === 0:
                    
$message trans('admin::app.contacts.persons.index.all-delete-success');

                    break;

                case 
$deletedCount && $blockedCount 0:
                    
$message trans('admin::app.contacts.persons.index.partial-delete-warning');

                    break;

                case 
$deletedCount === && $blockedCount 0:
                    
$message trans('admin::app.contacts.persons.index.none-delete-warning');

                    
$statusCode 400;

                    break;

                default:
                    
$message trans('admin::app.contacts.persons.index.no-selection');

                    
$statusCode 400;

                    break;
            }

            return 
response()->json(['message' => $message], $statusCode);
        } catch (
Exception $exception) {
            return 
response()->json([
                
'message' => trans('admin::app.contacts.persons.index.delete-failed'),
            ], 
400);
        }
    }
}

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