示例#1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\BlogCreateRequest $request)
 {
     $blog = new Blog();
     $blog->title = Input::get('title');
     $blog->content = Input::get('content');
     // dd($blog);
     $blog->save();
     $blog->tags()->attach([1, 3]);
     $blog->save();
     return "Your blog created successfully! Your id is" . $blog->id;
 }
 /**
  * Sync up the list of tags in the database.
  *
  * @param Blog $blog
  * @param array $tags
  */
 private function syncTags(Blog $blog, array $tags)
 {
     $blog->tags()->sync($tags);
 }