0

It is possible to pass parameter to the page using controller via ->with() for example

public function two(){

 return View::make('page2')->with('id', 2);

}

and now $id can be accessible in page2.blade.php

But i want to pass parameters via url with array like the way below

routes.php

<?php
Route::get('page1', 
array(
'uses' => 'pagecontroller@page1'

));

Route::get('page2/{$id}',
 array(
 'uses'=>'pagecontroller@page2'
 ));

pagecontroller.php

<?php

class pagecontroller extends BaseController{


  public function page1(){

   return View::make('page1');

  }

  public function page2($id){

    return "ID : $id";

  }

page1.blade.php

<p>This Is Page1</p>

<a href="{{action('pagecontroller@page2', array('id'=>1)  )}}">Page2</a>

And it is showing the error : Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

Where is it going wrong?

1 Answer 1

1

You have a little typo in your routes. The parameter is defined without the "$" prefix.

Route::get('page2/{$id}',

should be

Route::get('page2/{id}',

Remember to do composer dump-autoload after you change your routes.php file.

You might want to take a moment and check out the docs on routing params http://laravel.com/docs/routing#route-parameters

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.