I understand that when you do this in Laravel:
Route::get('news/read/{year}/{month}/{date}/{title}/{id}', 'PageController@index_page');
We can use all {var}
name as parameters in the controller. But how if I only want to use {id}
and {title}
instead of all of them in the controller?
This is currently my controller:
public function index_page($year=null, $month=date, $date=null, $title=null, $id=null) {
$plugin_files = $this->addJqueryPlugin(array('unslider'));
$data['css_files'] = $this->addCSS(array('styles'));
$data['js_files'] = $this->addJS(array('main'), false);
$data['css_plugin'] = $plugin_files['css_files'];
$data['js_plugin'] = $plugin_files['js_files'];
if (is_null($id)) {
$data['title'] = 'Homepage';
$this->layout->content = View::make('page.home', $data);
}
else {
$data['isModal'] = true;
$data['title'] = ucwords(str_replace("-", " ", $title . '--' . $id));
$this->layout->content = View::make('page.home', $data);
}
}
I tried putting only $title
and $id
but it reads from {year}
and {month}
instead. Only solution I can think of is change the order of the route to news/read/{title}/{id}/{year}/{month}/{date}
, but I'm trying to keep the format like the previous one, is it possible?