/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $video = Video::firstOrCreate(['title' => $request->input('title')]);
     return redirect()->route('videos.show', $video->id);
 }
 public function insertVideosAndTags($title, $tags)
 {
     $video = Video::firstOrCreate(['title' => $title]);
     foreach ($tags as $tag) {
         $tag = Tag::firstOrCreate(['tag' => $tag]);
         $video->tags()->sync([$tag->id], false);
     }
 }
Exemplo n.º 3
0
 public function insertVideosAndTags($title, $tags)
 {
     $this->comment($title . ' with ' . implode(',', $tags));
     $video = Video::firstOrCreate(['title' => $title]);
     foreach ($tags as $tag) {
         $tag = Tag::firstOrCreate(['tag' => $tag]);
         $video->tags()->sync([$tag->id], false);
     }
 }