dimanche 29 novembre 2015

LaravelLocalization::localizeURL with variable

I have got some problem. I create edit form - http://localhost/article/edit/{id}. This form redirect to http://localhost/article/edit/{id} with POST method.

{!! Form::open(array('route' => array('article_edit', $article->id))) !!}

If something was wrong redirecto to edit form with:

return redirect()->back()->withErrors($validator)
                        ->withInput();

but when everything is okay i would like redirect to article show

return redirect(
    LaravelLocalization::localizeURL(
        LaravelLocalization::transRoute('routes.article_show')
    )
)->with('slug', $slug);

but this not work.

What i should do?

My router file:

Route::group(['prefix' => LaravelLocalization::setLocale()], function()
{
    Route::get(
        LaravelLocalization::transRoute('routes.article_edit'),
        array(
            'as' => 'article_edit',
            'uses' => 'ArticlesController@edit'
        )
    )->where('id', '[0-9]+');
    Route::post(
        LaravelLocalization::transRoute('routes.article_edit'),
        array(
            'as' => 'article_edit',
            'uses' => 'ArticlesController@update'
        )
    )->where('id', '[0-9]+');
    Route::get(
        LaravelLocalization::transRoute('routes.article_show'),
        array(
            'as' => 'article_show',
            'uses' => 'ArticlesController@showByString'
        )
    )->where('slug', '[A-Za-z]+');
}

lang router:

return [
    "article_edit"  =>  "article/edit/{id}",
    "article_show"  =>  "article/show/{slug}",
];

Thanks for answer



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire