repository = $calls; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Cart\Call\Repositories\Criteria\CallsResourceCriteria::class); } /** * Display a list of calls. * * @return Response */ public function index(CallsRequest $request) { return $this->repository ->setPresenter(\Cart\Call\Repositories\Presenter\CallsPresenter::class) ->paginate(); } /** * Display calls. * * @param Request $request * @param Model $calls * * @return Response */ public function show(CallsRequest $request, Calls $calls) { return $calls->setPresenter(\Cart\Call\Repositories\Presenter\CallsListPresenter::class); ; } /** * Create new calls. * * @param Request $request * * @return Response */ public function store(CallsRequest $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('call::calls.name')]); $code = 204; $status = 'success'; $url = guard_url('call/calls/' . $calls->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('call/calls'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the calls. * * @param Request $request * @param Model $calls * * @return Response */ public function update(CallsRequest $request, Calls $calls) { try { $data = $request->all(); $calls->update($data); $message = trans('messages.success.updated', ['Module' => trans('call::calls.name')]); $code = 204; $status = 'success'; $url = guard_url('call/calls/' . $calls->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('call/calls/' . $calls->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the calls. * * @param Model $calls * * @return Response */ public function destroy(CallsRequest $request, Calls $calls) { try { $calls->delete(); $message = trans('messages.success.deleted', ['Module' => trans('call::calls.name')]); $code = 202; $status = 'success'; $url = guard_url('call/calls/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('call/calls/' . $calls->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); } }