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