Example #1
0
 public function store(Requests\StorePostRequest $request, $post_id = null)
 {
     $post = Posts::findOrNew($post_id);
     if (empty($post)) {
         redirect()->back()->withInput();
     }
     $seo_title = $request->get('seo_title', '') != '' ? $request->get('seo_title') : $request->get('title');
     if ($request->hasFile('img')) {
         $filename = $this->_uploadMiniature($request->file('img'));
         $post->img = $filename;
     }
     $post->user_id = auth()->user()->id;
     $post->category_id = $request->get('category_id');
     $post->title = $request->get('title');
     $post->excerpt = $request->get('excerpt');
     $post->content = $request->get('content');
     $post->seo_title = strip_tags($seo_title);
     $post->seo_description = strip_tags($request->get('seo_description'));
     $post->seo_keywords = mb_strtolower(strip_tags($request->get('seo_keywords')));
     $post->status = $request->get('status');
     $post->published_at = $request->get('published_at');
     if ($request->has('update_slug')) {
         $post->resluggify();
     }
     $post->save();
     $this->_setTags($request->get('tags'), $post->id);
     if ($request->has('ping')) {
         Pinger::pingAll($post->title, route('view', ['slug' => $post->slug]));
     }
     Notifications::add('Blog post saved', 'success');
     return Redirect::route('root-post-edit', ['post_id' => $post->id]);
 }