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