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