/**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(StoreBlogPostRequest $request)
 {
     $post = Post::create($request->all());
     $tags = $request->input('tag_list') ? $request->input('tag_list') : [];
     $post->tags()->sync($this->syncUpTags($tags));
     return redirect('/blog');
 }
Ejemplo n.º 2
0
 public function store(StoreBlogPostRequest $request)
 {
     $id = $request->input('id');
     $title = $request->input('title');
     $content = $request->input('content');
     $summary = str_summary($content, 100);
     $thumb_img = $request->input('thumb_img');
     $category = $request->input('category');
     $tags = $request->input('tags');
     if ($id) {
         $post = Post::find($id);
     } else {
         $post = new Post();
         $post->author = Auth::user()->id;
     }
     $post->title = $title;
     $post->summary = $summary;
     $post->content = $content;
     $post->thumb_img = $thumb_img;
     $post->save();
     $relations = [];
     $relations[] = ['term_id' => $category];
     if ($tags) {
         foreach ($tags as $tag) {
             $relations[] = ['term_id' => $tag];
         }
     }
     if ($relations) {
         $post->save_relations($relations);
     }
     return redirect()->action('Admin\\PostController@index');
 }
Ejemplo n.º 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\StoreBlogPostRequest $request, $id)
 {
     $discussion = Discussion::findOrFail($id);
     $discussion->update($request->all());
     return redirect()->action('DiscussionController@show', ['id' => $discussion->id]);
 }