Reputation: 269
How does one go about linking to a specific id in a view with Laravel?
My controller:
public function services() {
return View::make('services.custom_paint', array('pageTitle' => 'Custom Paint'))->with('default_title', $this->default_title);
}
My route:
Route::get('/custom_paint', 'PagesController@services');
I have tried to add #id
to the route, to the controller, and even to the view's URL::to
. Nothing seems to work.
I assumed that simply adding the id on to the URI would do the trick, but clearly I am missing something.
Upvotes: 3
Views: 19509
Reputation: 7683
If you pass id to controller as parameter and need to point to correct result with #id
<a href="{{ route('custom_paint',['id'=>'$id_value','#id']) }}">Try</a>
I assume above will render as http://localhost/custom_paint/id=123#id
Or Just point to ID:
<a href="{{ route('custom_paint',['#id']) }}">Try</a>
I assume above will render as http://localhost/custom_paint/#id
Upvotes: 2
Reputation: 1739
Simply use
<a href="{{ route('custom_paint') }}">LINK</a>
if parameter is needed use it like this
<a href="{{ route('custom_paint', 'param1') }}">LINK</a>
Upvotes: -1
Reputation: 694
// Controller
Route::get('/custom_paint', array('as' => 'custom_paint', 'uses' => 'PagesController@services'));
// View
<a href="{{ URL::route('custom_paint') }}#id">LINK</a>
Try this code ;) hope it works..
Upvotes: 11