/** * Update the specified resource in storage. * * @param VideoRequest $request * @param int $id * @return \Illuminate\Http\Response */ public function update(VideoRequest $request, $id) { try { $video = Video::findOrFail($id); $inputs = $request->all(); $thumbnail = getVideoThumbnail($inputs['link']); $inputs['thumbnail'] = $thumbnail; $video->fill($inputs)->save(); } catch (ModelNotFoundException $ex) { Flash::error('No video found' . $ex); return redirect()->route('videos.index'); } Flash::success('Video updated successfully'); return back(); }
/** * Update the specified resource in storage. * * @param FeedRequest $request * @param int $id * @return \Illuminate\Http\Response */ public function update(FeedRequest $request, $id) { try { $feed = Feed::findOrFail($id); $inputs = $request->all(); if ($inputs['url'] == "" && $request->hasFile('media')) { if (substr($request->file('media')->getMimeType(), 0, 5) == 'video') { $inputs['is_video'] = 1; } $fileName = upload($request->file('media'), 'feeds', $feed->media); if (isset($inputs['is_video'])) { $parts = explode('.', $fileName); $inputs['thumbnail'] = 'thumb_' . $parts[0] . '.jpg'; } $inputs['media'] = $fileName; } if ($inputs['url'] != "") { $thumbnail = getVideoThumbnail($inputs['url']); $inputs['thumbnail'] = $thumbnail; $inputs['media'] = ''; } $feed->fill($inputs)->save(); } catch (ModelNotFoundException $ex) { Flash::error('No feed found' . $ex); return redirect()->route('feeds.index'); } Flash::success('Feed updated successfully'); return redirect()->route('feeds.index'); }