Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

helpmyworld's avatar

Missing required parameter for [Route: album.show]

The error is this "Missing required parameter for [Route: album.show] [URI: admin/album/{album}] [Missing parameter: album]. (View: C:\XampFolder\htdocs\vuledangale.com\resources\views\backend\album\index.blade.php)"

What am I missing because the slug is stored in the database.

my view

    <a href="{{ route('album.show', $album->slug) }}" class="btn btn-default ">View</a>

Controller


public function show(Album $album)
    {
        $data["album"] = $album;
        return view('backend.album.show',$data);
    }

I am using resource route. Route::resource('/album','AlbumController');

0 likes
6 replies
tykus's avatar
tykus
Best Answer
Level 104

The most likely reason is one or more of your Album instance evaluated $album->slug as null; check your database records

1 like
tykus's avatar

@helpmyworld you probably need to make sure that records cannot be created without a slug if they are so integral to your routing. You can use Model Events to compute and set the slug whenever the model is being created. Also, making the column on the database table not nullable would be useful

Shivamyadav's avatar

Because laravel uses I'd for route model binding. You can achieve it by using slug like this

class Album extends Model
{
   //Add this method to work route model binding using slug

    public function getRouteKeyName()
    {
        return 'slug';
    }
}
Shivamyadav's avatar

@helpmyworld yeah, if the page doesn't open when you click on the link based on slug . Url you need to add it for model binding

Please or to participate in this conversation.