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