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