initial commit
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run

This commit is contained in:
Edward Tirado Jr 2025-12-12 23:07:04 -06:00
commit 0c42bef077
109 changed files with 16545 additions and 0 deletions

View file

@ -0,0 +1,58 @@
<?php
namespace App\Livewire;
use App\Livewire\Forms\MovieListForm;
use App\Models\Interfaces\MovieDbInterface;
use App\Models\MovieList as MovieListModel;
use Livewire\Component;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class MovieList extends Component
{
public int $id;
public string $query;
public MovieListModel $list;
public $movies = [];
public MovieListForm $form;
public function mount($id): void
{
$this->id = $id;
$this->getList();
}
public function getList()
{
$list = MovieListModel::with('movies')
->find($this->id);
if ($list) {
$this->list = $list;
$this->movies = $list->movies;
} else {
abort(404);
}
}
public function addMovie(MovieDbInterface $movie_db)
{
$this->resetErrorBag();
try {
$movie = $movie_db->search($this->query);
} catch (NotFoundHttpException $e) {
$this->addError('query', 'Movie not found');
return;
}
$this->list->movies()->syncWithoutDetaching($movie->id);
$this->getList();
$this->form->reset();
}
public function render()
{
return view('livewire.movie-list');
}
}