Shankar Thiyagaraajan
Shankar Thiyagaraajan

Reputation: 1795

Laravel 5 | Route Model Binding not working

I'm new to Laravel 5. I am trying to bind my routes with models.

In My RouteServiceProvider.php

public function boot(Router $router)
{
    parent::boot($router);        
    $router->model('messages','App\messages');
}

My Controller is : Message_cont

My Function is :

public function show(Message_cont $id) {
     dd($id);
}

My Output is :

message_cont {#199 ▼
#middleware: []
#validatesRequestErrorBag: null
}

What is wrong with my code...?

Upvotes: 0

Views: 1208

Answers (2)

Neo
Neo

Reputation: 886

Just change the show method to pick the appropriate model

public function show(\App\messages $messages);

Upvotes: 1

Maxim Lanin
Maxim Lanin

Reputation: 4531

Your model's name is App\messages, but you are waiting Message_cont in show method.

Upvotes: 0

Related Questions