model = $v_a_l_u_e; parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(VALUEAdminRequest $request) { if ($request->wantsJson()) { $array = $this->model->json(); foreach ($array as $key => $row) { $array[$key] = array_only($row, config('1.v_a_l_u_e.listfields')); } return ['data' => $array]; } $this->theme->prependTitle(trans('1::v_a_l_u_e.names').' :: '); return $this->theme->of('1::admin.v_a_l_u_e.index')->render(); } /** * Display the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function show(VALUEAdminRequest $request, $id) { $v_a_l_u_e = $this->model->find($id); if (empty($v_a_l_u_e)) { if ($request->wantsJson()) { return []; } return view('1::admin.v_a_l_u_e.new'); } if ($request->wantsJson()) { return $v_a_l_u_e; } Former::populate($v_a_l_u_e); return view('1::admin.v_a_l_u_e.show', compact('v_a_l_u_e')); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(VALUEAdminRequest $request) { $v_a_l_u_e = $this->model->findOrNew(0); Former::populate($v_a_l_u_e); return view('1::admin.v_a_l_u_e.create', compact('v_a_l_u_e')); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(VALUEAdminRequest $request) { try { $attributes = $request->all(); $v_a_l_u_e = $this->model->create($attributes); return $this->success(trans('messages.success.created', ['Module' => trans('1::v_a_l_u_e.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function edit(VALUEAdminRequest $request, $id) { $v_a_l_u_e = $this->model->find($id); Former::populate($v_a_l_u_e); return view('1::admin.v_a_l_u_e.edit', compact('v_a_l_u_e')); } /** * Update the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function update(VALUEAdminRequest $request, $id) { try { $attributes = $request->all(); $v_a_l_u_e = $this->model->update($attributes, $id); return $this->success(trans('messages.success.updated', ['Module' => trans('1::v_a_l_u_e.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(VALUEAdminRequest $request, $id) { try { $this->model->delete($id); return $this->success(trans('message.success.deleted', ['Module' => trans('1::v_a_l_u_e.name')]), 200); } catch (Exception $e) { return $this->error($e->getMessage()); } } }