Syntax errors.
Route::get('sale_add_item/{alias}/{item_id}', function($alias, $item_id)
{
});
$item_id is an optional parameter, so i need to leave {item_id?}. Am i wrong?
Try this :
Route::get('sale_add_item/{alias}/{item_id?}', function($alias, $item_id=null) {
})->where('alias', '[a-zA-z_]+')->where('item_id', '[a-zA-z-]+');
Nope you're not wrong! Try this:
Route::get('sale_add_item/{alias}/{item_id?}', function($alias, $item_id = null)
{
});
@feelinc : Same problem... If there are special characters in $alias for Redirect::to('sale_add_item/'.$alias), Laravel doesn't go in this route (Route::get('sale_add_item/{alias}/{item_id?})
AnthonyVipond said:
Nope you're not wrong! Try this:
Route::get('sale_add_item/{alias}/{item_id?}', function($alias, $item_id = null) { });
That's what i do, and it doesn't "catch" the Redirect::to() with special characters in $alias
You just need to find the correct Regex at :
where('alias', '[a-zA-z_]+')
What are the special characters? Many are not allowed in URLs, and it's always easier not to use them.
Mei
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community