/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request\PostRequest $request * @param int $id * @return \Illuminate\Http\Response */ public function update(PostRequest $request, Post $post) { $this->authorize('update', $post); $post->title = $request->get('title'); $post->text = $request->get('text'); $post->abstract = $post->getAbstract($request->get('text')); $post->user_id = Auth::user()->id; $post->save(); Flash::success('Post successfully updated'); return redirect('posts'); }
/** * PUT admin/posts/{post} * * @param Post $post * @param PostRequest $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update(Post $post, PostRequest $request) { $post->update($request->all()); if ($request->has('tag_list')) { $post->tags()->sync(Tag::findOrCreateMany($request->get('tag_list'))); } flash()->success('The post has been updated'); return redirect('/admin/posts'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(PostRequest $request) { $post = $request->all(); $archive = Archive::whereYearAndMonth(date("Y"), date("n"))->first(); if ($archive) { $post['archive_id'] = $archive->id; } else { $newArchive = Archive::create(['year' => date("Y"), 'month' => date("n")]); $post['archive_id'] = $newArchive->id; } $post['slug'] = str_slug($post['title']); $post = Post::create($post); CategoryPost::create(['category_id' => $request->get("category_id"), 'post_id' => $post->id]); }
/** * @param PostRequest $request * @param $id * @return \Illuminate\Http\RedirectResponse */ public function update(PostRequest $request, $id) { $post = Post::findOrFail($id); $post->name = $request->get("name"); $post->content = $request->get("content"); $post->save(); $this->sync($post, $request->input("tags")); return redirect()->route("posts.index")->with("message", "The post was updated"); }
/** * Return the fields and values */ public function modifyInput(PostRequest $request) { return ['title' => $request->title, 'subtitle' => $request->subtitle, 'images' => $request->images, 'text' => $request->get('text'), 'preview' => $request->preview, 'meta_description' => $request->meta_description, 'meta_keywords' => $request->meta_keywords, 'enabled' => (bool) $request->enabled, 'date_from' => $request->date_from]; }