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