repository = $car_model; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Autos\Car\Repositories\Criteria\CarModelResourceCriteria::class); } /** * Display a list of car_model. * * @return Response */ public function index(CarModelRequest $request) { return $this->repository ->setPresenter(\Autos\Car\Repositories\Presenter\CarModelPresenter::class) ->paginate(); } /** * Display car_model. * * @param Request $request * @param Model $car_model * * @return Response */ public function show(CarModelRequest $request, CarModel $car_model) { return $car_model->setPresenter(\Autos\Car\Repositories\Presenter\CarModelListPresenter::class); ; } /** * Create new car_model. * * @param Request $request * * @return Response */ public function store(CarModelRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('car::car_model.name')]); $code = 204; $status = 'success'; $url = guard_url('car/car_model/' . $car_model->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('car/car_model'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the car_model. * * @param Request $request * @param Model $car_model * * @return Response */ public function update(CarModelRequest $request, CarModel $car_model) { try { $data = $request->all(); $car_model->update($data); $message = trans('messages.success.updated', ['Module' => trans('car::car_model.name')]); $code = 204; $status = 'success'; $url = guard_url('car/car_model/' . $car_model->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('car/car_model/' . $car_model->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the car_model. * * @param Model $car_model * * @return Response */ public function destroy(CarModelRequest $request, CarModel $car_model) { try { $car_model->delete(); $message = trans('messages.success.deleted', ['Module' => trans('car::car_model.name')]); $code = 202; $status = 'success'; $url = guard_url('car/car_model/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('car/car_model/' . $car_model->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }