initial commit
This commit is contained in:
commit
0c42bef077
109 changed files with 16545 additions and 0 deletions
39
app/Livewire/MovieLists.php
Normal file
39
app/Livewire/MovieLists.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Livewire\Forms\MovieListForm;
|
||||
use App\Models\MovieList;
|
||||
use Livewire\Component;
|
||||
|
||||
class MovieLists extends Component
|
||||
{
|
||||
public MovieListForm $form;
|
||||
public $lists = [];
|
||||
|
||||
public function addList(): void
|
||||
{
|
||||
if (!auth()->check()) {
|
||||
$this->redirectRoute('login');
|
||||
return;
|
||||
}
|
||||
|
||||
$user = auth()->user();
|
||||
$validated = $this->form->validate();
|
||||
MovieList::create(array_merge($validated, ["user_id" => $user->id]));
|
||||
|
||||
$this->getLists();
|
||||
$this->form->reset();
|
||||
}
|
||||
|
||||
public function getLists()
|
||||
{
|
||||
$this->lists = MovieList::all();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$this->getLists();
|
||||
return view('livewire.lists');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue