Example #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateVideoRequest $request)
 {
     $video = Video::create(['project_id' => $request->input('project_id'), 'youtube_id' => $request->input('youtube_id')]);
     if ($video) {
         flash()->success('Video added successfully.');
     } else {
         flash()->error('Oops! Something went wrong.');
     }
     return redirect(route('backend'));
 }
Example #2
0
 public function update(Requests\CreateVideoRequest $request, $id)
 {
     $params = $request->except(['video', '_token']);
     $newVideo = $request->file('video');
     if ($newVideo) {
         $params = $this->setVideoParams($params, $newVideo);
     }
     $existingVideo = Video::findOrFail($id);
     if ($existingVideo) {
         if ($newVideo) {
             $formerFile = $existingVideo->upload_filename;
             //to be deleted
         }
         $existingVideo->update($params);
         if ($newVideo) {
             $this->uploader->pushFile($newVideo, $existingVideo, $params['original_filename'], $params['upload_filename'], $formerFile);
         }
     }
     $request->session()->flash("notif", "Video successfully updated");
     return redirect('admin/videos');
 }
 /**
  * Store a newly created Video in storage.
  *
  * @param CreateVideoRequest $request
  *
  * @return Response
  */
 public function store(CreateVideoRequest $request)
 {
     $input = $request->all();
     $video_url = '';
     $thumb_picture_url = '';
     if ($request->hasFile('video_url')) {
         $name = $request->file('video_url')->getClientOriginalName();
         $video_url = config('app.url') . ':' . config('app.video_service_port') . '/' . $request->video_url->storeAs('mp4', $name, 'public');
     }
     if ($request->hasFile('thumb_picture_url')) {
         $name = $request->file('thumb_picture_url')->getClientOriginalName();
         $thumb_picture_url = config('app.url') . ':' . config('app.http_service_port') . '/' . $request->thumb_picture_url->storeAs('thumb_pictures', $name, 'public');
     }
     $video = new Video();
     $video->title = $input['title'];
     $video->description = $input['description'];
     $video->video_url = $video_url;
     $video->thumb_picture_url = $thumb_picture_url;
     $video->save();
     Flash::success('Video saved successfully.');
     return redirect(route('videos.index'));
 }