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