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