Skip to content

Instantly share code, notes, and snippets.

@NandoKstroNet
Created November 17, 2021 22:08
Show Gist options
  • Save NandoKstroNet/2b45b73a29db64fbb1e2d8fb142442db to your computer and use it in GitHub Desktop.
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
<?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