Created
November 17, 2021 22:08
-
-
Save NandoKstroNet/2b45b73a29db64fbb1e2d8fb142442db to your computer and use it in GitHub Desktop.
Componente Livewire Video Create, projeto VideoFlix do curso Laravel Mastery em https://laravelmastery.com.br
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\Livewire\Content; | |
use Livewire\{ | |
WithFileUploads, | |
Component | |
}; | |
use App\Models\Content; | |
class VideoCreate extends Component | |
{ | |
use WithFileUploads; | |
public $videos; | |
public $content; | |
protected $rules = [ | |
'video' => 'required|file|mimetypes:video/mp4,video/mpeg,video/x-matroska', | |
]; | |
public function mount(Content $content) | |
{ | |
$this->content = $content; | |
} | |
public function uploadVideos() | |
{ | |
$videoUploadedFile = $this->videos; | |
$video = [ | |
'name' => $videoUploadedFile->getClientOriginalName(), | |
'video' => $videoUploadedFile->store('videos', 'public'), | |
'slug' => \Illuminate\Support\Str::slug($videoUploadedFile->getClientOriginalName()) | |
]; | |
$this->content->videos()->create($video); | |
} | |
public function render() | |
{ | |
return view('livewire.content.video-create'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment