![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/job-board.corals.io/Corals/modules/Ecommerce/Http/Controllers/API/ |
<?php namespace Corals\Modules\Ecommerce\Http\Controllers\API; use Corals\Foundation\Http\Controllers\APIBaseController; use Corals\Modules\Ecommerce\DataTables\BrandsDataTable; use Corals\Modules\Ecommerce\Http\Requests\BrandRequest; use Corals\Modules\Ecommerce\Models\Brand; use Corals\Modules\Ecommerce\Services\BrandService; use Corals\Modules\Ecommerce\Transformers\API\BrandPresenter; class BrandsController extends APIBaseController { protected $brandService; /** * BrandsController constructor. * @param BrandService $brandService * @throws \Exception */ public function __construct(BrandService $brandService) { $this->brandService = $brandService; $this->brandService->setPresenter(new BrandPresenter()); parent::__construct(); } /** * @param BrandRequest $request * @param BrandsDataTable $dataTable * @return mixed * @throws \Exception */ public function index(BrandRequest $request, BrandsDataTable $dataTable) { $brands = $dataTable->query(new Brand()); return $this->brandService->index($brands, $dataTable); } /** * @param BrandRequest $request * @return \Illuminate\Http\JsonResponse */ public function store(BrandRequest $request) { try { $brand = $this->brandService->store($request, Brand::class); return apiResponse($this->brandService->getModelDetails(), trans('Corals::messages.success.created', ['item' => $brand->name])); } catch (\Exception $exception) { return apiExceptionResponse($exception); } } /** * @param BrandRequest $request * @param Brand $brand * @return \Illuminate\Http\JsonResponse */ public function update(BrandRequest $request, Brand $brand) { try { $this->brandService->update($request, $brand); return apiResponse($this->brandService->getModelDetails(), trans('Corals::messages.success.updated', ['item' => $brand->name])); } catch (\Exception $exception) { return apiExceptionResponse($exception); } } /** * @param BrandRequest $request * @param Brand $brand * @return \Illuminate\Http\JsonResponse */ public function destroy(BrandRequest $request, Brand $brand) { try { $this->brandService->destroy($request, $brand); return apiResponse([], trans('Corals::messages.success.deleted', ['item' => $brand->name])); } catch (\Exception $exception) { return apiExceptionResponse($exception); } } }