44 lines
968 B
PHP
44 lines
968 B
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Models\Movie;
|
|
use Livewire\Component;
|
|
use function Laravel\Prompts\select;
|
|
|
|
class MovieDetailsPanel extends Component
|
|
{
|
|
public $showDetails = false;
|
|
public ?Movie $selectedMovie = null;
|
|
|
|
protected $listeners = ['openMovieDetails' => 'openPanel'];
|
|
|
|
public function openPanel(int $movieId): void
|
|
{
|
|
$this->selectedMovie = Movie::where('id', $movieId)
|
|
->select(
|
|
'id',
|
|
'title',
|
|
'plot',
|
|
'poster',
|
|
'director',
|
|
'year',
|
|
'actors',
|
|
'genre',
|
|
'mpaa_rating'
|
|
)
|
|
->first();
|
|
$this->showDetails = true;
|
|
}
|
|
|
|
public function closePanel(): void
|
|
{
|
|
$this->showDetails = false;
|
|
$this->selectedMovie = null;
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.movie-details-panel');
|
|
}
|
|
}
|