/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { //dd($request->all()); $this->validate($request, ['name' => 'required', 'slug' => 'unique:pages,slug', 'body' => 'required']); $page = new Page(); if ($request->hasFile('featured_image')) { $featured_image = $page->uploadImage($request->featured_image); } $page->fill($request->all()); if (isset($featured_image)) { $page->featured_image = $featured_image; } $page->save(); Session::flash('flash_message', 'Síðan var vistuð'); return redirect()->back(); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $page = new Page(); $page->fill($request->all()); $slug = Helpers::makeSlug($request->input('title_geo'), 'pages'); if ($slug == "") { return Redirect::route('admin.index'); } $page->slug = $slug; $image = $request->file('image'); $fileName = ""; if ($image->isValid()) { $path = public_path() . '/uploads/pages/'; $fileName = str_random(32) . '.' . $image->getClientOriginalExtension(); $image->move($path, $fileName); } else { App::abort(404); } $page->image = $fileName; $page->save(); return Redirect::route('admin.pages.show'); }
/** * Update the specified page in storage. * * @param Page $page * @param PageRequest $request * @return Response */ public function update(Page $page, PageRequest $request) { $page->fill($request->all()); $page->save() == true ? Flash::success(trans('admin.update.success')) : Flash::error(trans('admin.update.fail')); return redirect(route('admin.page.index')); }
public function update(PageRequest $request, Page $page) { if (!Entrust::can('edit_page')) { return redirect('/dashboard')->withErrors(config('constants.NA')); } $data = $request->all(); $page->fill($data); $page->page_slug = Helper::createSlug($data['page_title']); $page->save(); Helper::updateCustomField($this->form, $page->id, $data); $activity = 'Edit a page'; Activity::log($activity); return redirect('/page')->withSuccess(config('constants.SAVED')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Page $page * @return \Illuminate\Http\Response */ public function update(Request $request, Page $page) { $request->replace(['name' => $request->get('name'), 'title' => str_slug($request->get('name')), 'body' => $request->get('body')]); $this->validate($request, ['name' => ["required", "unique:pages,name,{$page->page_id},page_id", "max:255"], 'title' => ["required", "unique:pages,title,{$page->page_id},page_id", "max:255"], 'body' => 'required']); $page->fill(['name' => $request->get('name'), 'title' => $request->get('title'), 'body' => $request->get('body')]); Session::flash('success', trans('config.success')); $page->save(); return $this->edit($page); }