I came across some quirk with L4 routing (maybe symfony2?), For which I cannot find any resources on the Internet or in the beautiful Code Bright, and appeared in IRC empty.
I try to use optional parameters with a named route through the controller, but I get an error when loading the view.
Route:
Route::get('/topic/{topicID?}', array( 'as' => 'topicDetails', 'uses' => ' TopicController@showTopic ' ));
Controller:
class TopicController extends BaseController { public function showTopic($topicID = null) { $data['topicID'] = $topicID; return View::make('topic_view', $data); } }
View
<a href="{{ route('topicDetails') }}">XXX</a>
Error:
Parameter "topicID" for route "topicDetails" must match "[^/]++" ("" given) to generate a corresponding URL.
I assume that this does not pass the null value in $param , but I am not familiar enough with L4 to understand why it does not work, and I have exhausted all my resources.
Any hints would be greatly appreciated Thank you!
source share