Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Webkul\Shop\Http\Controllers\API; use Illuminate\Http\Resources\Json\Jso..
Decoded Output download
<?php
namespace Webkul\Shop\Http\Controllers\API;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\Attribute\Repositories\AttributeRepository;
use Webkul\Category\Repositories\CategoryRepository;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\Shop\Http\Resources\AttributeResource;
use Webkul\Shop\Http\Resources\CategoryResource;
use Webkul\Shop\Http\Resources\CategoryTreeResource;
class CategoryController extends APIController
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(
protected AttributeRepository $attributeRepository,
protected CategoryRepository $categoryRepository,
protected ProductRepository $productRepository
) {
}
/**
* Get all categories.
*/
public function index(): JsonResource
{
/**
* These are the default parameters. By default, only the enabled category
* will be shown in the current locale.
*/
$defaultParams = [
'status' => 1,
'locale' => app()->getLocale(),
];
$categories = $this->categoryRepository->getAll(array_merge($defaultParams, request()->all()));
return CategoryResource::collection($categories);
}
/**
* Get all categories in tree format.
*/
public function tree(): JsonResource
{
$categories = $this->categoryRepository->getVisibleCategoryTree(core()->getCurrentChannel()->root_category_id);
return CategoryTreeResource::collection($categories);
}
/**
* Get filterable attributes for category.
*/
public function getAttributes(): JsonResource
{
if (! request('category_id')) {
$filterableAttributes = $this->attributeRepository->getFilterableAttributes();
return AttributeResource::collection($filterableAttributes);
}
$category = $this->categoryRepository->findOrFail(request('category_id'));
if (empty($filterableAttributes = $category->filterableAttributes)) {
$filterableAttributes = $this->attributeRepository->getFilterableAttributes();
}
return AttributeResource::collection($filterableAttributes);
}
/**
* Get product maximum price.
*/
public function getProductMaxPrice($categoryId = null): JsonResource
{
$maxPrice = $this->productRepository->getMaxPrice(['category_id' => $categoryId]);
return new JsonResource([
'max_price' => core()->convertPrice($maxPrice),
]);
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Webkul\Shop\Http\Controllers\API;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\Attribute\Repositories\AttributeRepository;
use Webkul\Category\Repositories\CategoryRepository;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\Shop\Http\Resources\AttributeResource;
use Webkul\Shop\Http\Resources\CategoryResource;
use Webkul\Shop\Http\Resources\CategoryTreeResource;
class CategoryController extends APIController
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(
protected AttributeRepository $attributeRepository,
protected CategoryRepository $categoryRepository,
protected ProductRepository $productRepository
) {
}
/**
* Get all categories.
*/
public function index(): JsonResource
{
/**
* These are the default parameters. By default, only the enabled category
* will be shown in the current locale.
*/
$defaultParams = [
'status' => 1,
'locale' => app()->getLocale(),
];
$categories = $this->categoryRepository->getAll(array_merge($defaultParams, request()->all()));
return CategoryResource::collection($categories);
}
/**
* Get all categories in tree format.
*/
public function tree(): JsonResource
{
$categories = $this->categoryRepository->getVisibleCategoryTree(core()->getCurrentChannel()->root_category_id);
return CategoryTreeResource::collection($categories);
}
/**
* Get filterable attributes for category.
*/
public function getAttributes(): JsonResource
{
if (! request('category_id')) {
$filterableAttributes = $this->attributeRepository->getFilterableAttributes();
return AttributeResource::collection($filterableAttributes);
}
$category = $this->categoryRepository->findOrFail(request('category_id'));
if (empty($filterableAttributes = $category->filterableAttributes)) {
$filterableAttributes = $this->attributeRepository->getFilterableAttributes();
}
return AttributeResource::collection($filterableAttributes);
}
/**
* Get product maximum price.
*/
public function getProductMaxPrice($categoryId = null): JsonResource
{
$maxPrice = $this->productRepository->getMaxPrice(['category_id' => $categoryId]);
return new JsonResource([
'max_price' => core()->convertPrice($maxPrice),
]);
}
}
Function Calls
None |
Stats
MD5 | 96a80dc1ab5519311d66f46ca6fcfc90 |
Eval Count | 0 |
Decode Time | 142 ms |