I've ran into a bit of a quirk with L4 (possibly symfony2?) routing for which I can't seem to find any resources online or in the wonderful Code Bright, and came up empty in IRC.
I'm trying to use optional params with a named route through a controller, but receive an error when loading the view.
Route::get('/topic/{topicID?}', array(
'as' => 'topicDetails',
'uses' => 'TopicController@showTopic'
));
class TopicController extends BaseController {
public function showTopic($topicID = null)
{
$data['topicID'] = $topicID;
return View::make('topic_view', $data);
}
}
<a href="{{ route('topicDetails') }}">XXX</a>
Parameter "topicID" for route "topicDetails" must match "[^/]++" ("" given) to generate a corresponding URL.
I'm assuming this isn't passing the null
value to the $param
but I'm not familiar enough with L4 to figure out why it isn't working, and I've exhausted all my resources.
Any clues would be greatly appreciated Thanks!
this
<a href="{{ route('topicDetails') }}">XXX</a>
should be
<a href="{{ route('topicDetails', null) }}">XXX</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With