/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['title' => 'required|min:3', 'video-url' => 'required|min:3', 'description' => 'required|min:10', 'category' => 'required']); $haystacks = ['=', '/']; foreach ($haystacks as $haystack) { $video_url = substr(trim($request->input('video-url')), strrpos(trim($request->input('video-url')), $haystack, -1) + 1); if ($this->videoExist($video_url)) { $video = new Video(); $video->video_title = trim($request->input('title')); $video->video_category = trim($request->input('category')); $video->video_url = $video_url; $video->video_description = trim($request->input('description')); $video->user_id = Auth::user()->id; $video->save(); } } return redirect()->route('videos.index'); }