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