Created
May 24, 2019 22:27
-
-
Save WyattCast44/de4b01f59dc4b15794913a789eb065f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Video; | |
use Illuminate\Http\Request; | |
use App\Jobs\UploadVideoToVimeo; | |
class VideosController extends Controller | |
{ | |
public function __construct() | |
{ | |
$this->middleware('auth'); | |
} | |
public function index() | |
{ | |
$videos = Video::latest()->get(); | |
return view('videos.index', ['videos' => $videos]); | |
} | |
public function show(Video $video) | |
{ | |
return view('videos.show', ['video' => $video]); | |
} | |
public function create() | |
{ | |
return view('videos.create'); | |
} | |
public function store(Request $request) | |
{ | |
$this->validate($request, [ | |
'title' => 'required|string|max:255', | |
'description' => 'required|string|max:2500', | |
'video' => 'required|file|mimetypes:video/avi,video/mpeg,video/quicktime,video/mp4', | |
]); | |
$video = Video::create([ | |
'title' => $request->title, | |
'description' => $request->description, | |
'source_path' => $request->file('video')->store('uploads/videos'), | |
]); | |
dispatch(new UploadVideoToVimeo($video)); | |
return redirect()->route('videos.index'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment