Elmasry
Elmasry

Reputation: 53

Call to undefined method - Laravel

I'm new to Laravel, I'm using Laravel 4, I'm trying to create a user controller as the following:

class UserController extends BaseController {

    public function getIndex (){
    }

    public function showProfile($id){

        echo "$id";

        View::make('user.profile');
    }


    public function getNew(){
    }

    public function postNew(){

    }

    public function getLogin(){
    }

In the route I want to use: Route::controller('user', 'UserController');

and it's working fine with all expect (showProfile), for example when I go to ../user/profile/2 I get Call to undefined method.

Notice: I can use

Route::get('user', 'UserController@getIndex');
Route::get('user/new', 'UserController@getNew');
Route::post('user/new', 'UserController@postNew');
Route::get('user/login', 'UserController@getLogin');
Route::get('user/{id}', 'UserController@showProfile');

and it will work fine but I don't think it's a good practice

Upvotes: 0

Views: 3588

Answers (1)

Glad To Help
Glad To Help

Reputation: 5387

There is no route you have defined for

 ../user/profile/2

Have you tried something like:

Route::get('user/profile/{id}', 'UserController@showProfile');

Upvotes: 1

Related Questions