Reputation: 1155
I'm trying to use this http://api.jqueryui.com/autocomplete/#option-source with Laravel and so I need to send a GET request to a url which ends with "?term=foo". I've tried to escape the "?" with a backslash, which doesn't work. To clarify, this is what I want:
Route::get('search\?term=(:any)', function()
{
//do something
}
Is it possible to have questionmarks in the url with Laravel?
Upvotes: 2
Views: 3796
Reputation: 1539
Just for others who may want a Clear Answer :
you have to write and use your code as follows:
Route::get('search', function()
{
$term = Input::get('term');
if(isset($term)){
//do other stuff !
}
}
Upvotes: 4
Reputation: 2476
Having a question mark in the URL should make no difference. You're using a PHP framework, and simply speaking, ...?term=parameters
should not be problematic. To my knowledge, there should be no need to escape such a question mark... It is handled appropriately by default.
Upvotes: 2
Reputation: 590
I believe the slug function is what you are looking for: http://laravel.com/api/class-Laravel.Str.html
From the API Doc:
slug( string $title, string $separator = '-' )
Generate a URL friendly "slug" from a given string.
Upvotes: 2