Add following code
@props(['Movie'])
<div>
<h2>
<a href="/movies/{{$Movie['id']}}">
{{$Movie['Title']}}
</a>
</h2>
<h3>
Year: <a href="/movies?year={{$Movie['Year']}}"> {{$Movie['Year']}} </a>
</h3>
<h3>
Genre: <a href="/movies?genre={{$Movie['Genre']}}"> {{$Movie['Genre']}} </a>
</h3>
<h3>
Director: <a href="/movies?director={{$Movie['Director']}}"> {{$Movie['Director']}} </a>
</h3>
<h3>
Producer: {{$Movie['Producer']}}
</h3>
<h3>
Actors: {{$Movie['Actors']}}
</h3>
<p>
{{$Movie['Description']}}
</p>
</div>
Replace the code in 'movies.blade.php' file with the following code
<h1>{{$title}}</h1>
@foreach($movies as $Movie)
<x-movie-card :Movie="$Movie" />
@endforeach
Run the following command
php artisan make:controller MoviesController
A new file with be created in 'app/Http/Controllers'
Replace all the file content with the following code
<?php
namespace App\Http\Controllers;
use App\Models\Movie;
class MoviesController extends Controller
{
public function index()
{
return view('movies', [
'title' => 'Movies',
'movies' => Movie::all()
]);
}
public function show(Movie $movie)
{
return view('movie', [
'Movie' => $movie
]);
}
}
Replace the code in 'web.php' with the following code
<?php
use App\Http\Controllers\MoviesController;
use Illuminate\Support\Facades\Route;
use App\Models\Movie;
Route::get('/movies', [MoviesController::class, 'index']);
Route::get('/movies/{movie}', [MoviesController::class, 'show']);