![]() 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/syn.corals.io/Corals/modules/Syndicate/Http/Controllers/ |
<?php namespace Corals\Modules\Syndicate\Http\Controllers; use Corals\Foundation\Http\Controllers\BaseController; use Corals\Modules\Syndicate\DataTables\FactoriesDataTable; use Corals\Modules\Syndicate\Http\Requests\FactoryRequest; use Corals\Modules\Syndicate\Models\Factory; use Corals\Modules\Syndicate\Services\FactoryService; use Exception; use Illuminate\Contracts\View\View; use Illuminate\Foundation\Application; use Illuminate\Http\JsonResponse; class FactoriesController extends BaseController { protected $factoriesService; public function __construct(FactoryService $factoriesService) { $this->factoriesService = $factoriesService; $this->resource_url = config('syndicate.models.factory.resource_url'); $this->title = trans('Syndicate::module.factory.title'); $this->title_singular = trans('Syndicate::module.factory.title_singular'); parent::__construct(); } /** * @param FactoryRequest $request * @param FactoriesDataTable $dataTable * @return mixed */ public function index(FactoryRequest $request, FactoriesDataTable $dataTable) { return $dataTable->render('Syndicate::factories.index'); } /** * @param FactoryRequest $request * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|View */ public function create(FactoryRequest $request) { $factory = new Factory(); $this->setViewSharedData([ 'title_singular' => trans('Corals::labels.create_title', ['title' => $this->title_singular]) ]); return view('Syndicate::factories.create_edit')->with(compact('factory')); } /** * @param FactoryRequest $request * @return Application|JsonResponse|mixed */ public function store(FactoryRequest $request) { try { $factories = $this->factoriesService->store($request, Factory::class); flash(trans('Corals::messages.success.created', ['item' => $this->title_singular]))->success(); } catch (Exception $exception) { log_exception($exception, Factory::class, 'store'); } return redirectTo($this->resource_url); } /** * @param FactoryRequest $request * @param Factory $factory * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|View */ public function show(FactoryRequest $request, Factory $factory) { $this->setViewSharedData([ 'title_singular' => trans('Corals::labels.show_title', ['title' => $factory->getIdentifier()]), 'showModel' => $factory, ]); return view('Syndicate::factories.show')->with(compact('factory')); } /** * @param FactoryRequest $request * @param Factory $factory * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|View */ public function edit(FactoryRequest $request, Factory $factory) { $this->setViewSharedData([ 'title_singular' => trans('Corals::labels.update_title', ['title' => $factory->name]) ]); return view('Syndicate::factories.create_edit')->with(compact('factory')); } /** * @param FactoryRequest $request * @param Factory $factory * @return Application|JsonResponse|mixed */ public function update(FactoryRequest $request, Factory $factory) { try { $this->factoriesService->update($request, $factory); flash(trans('Corals::messages.success.updated', ['item' => $this->title_singular]))->success(); } catch (Exception $exception) { log_exception($exception, Factory::class, 'update'); } return redirectTo($this->resource_url); } /** * @param FactoryRequest $request * @param Factory $factory * @return JsonResponse */ public function destroy(FactoryRequest $request, Factory $factory) { try { $this->factoriesService->destroy($request, $factory); $message = [ 'level' => 'success', 'message' => trans('Corals::messages.success.deleted', ['item' => $this->title_singular]) ]; } catch (Exception $exception) { log_exception($exception, Factory::class, 'destroy'); $message = ['level' => 'error', 'message' => $exception->getMessage()]; } return response()->json($message); } }