0

Laravelでこれを行うと、次のようになります。

Route::get('news/read/{year}/{month}/{date}/{title}/{id}', 'PageController@index_page');

すべての{var}名前をコントローラーのパラメーターとして使用できます。しかし、コントローラーでそれらすべての代わりに{id}andのみを使用したい場合はどうすればよいでしょうか?{title}

これは現在私のコントローラーです:

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);
    }
}

$titleandのみを入れてみましたが、代わりにand$idから読み取られます。考えられる唯一の解決策は、ルートの順序を に変更することですが、以前の形式を維持しようとしていますが、可能ですか?{year}{month}news/read/{title}/{id}/{year}/{month}/{date}

4

1 に答える 1