Reputation: 41
Using a view with user input. I then want to pass to a route. This what I found so far: href="{{URL::to('customers/single'$params')}}"
I want to pass the user input as the above $params to my route. This is sample of my route:
Route::get('customer/{id}', function($id) {
$customer = Customer::find($id);
return View::make('customers/single')
->with('customer', $customer);
As soon as I can pass the parameter I can do what I want with the route, which I know how.
Upvotes: 2
Views: 8646
Reputation: 709
You can user it in View as I used:
<a class="stocks_list" href="/profile/{{ Auth::user()->username }}">Profile</a>
Hope it helps you.
Upvotes: 0
Reputation: 4814
This worked for me in my view anchor tag
href="{{ URL::to('user/'.$param) }}"
instead of what was specified above
href="{{ URL::to('user/$param') }}"
Upvotes: 0
Reputation: 41
This is what I have and works:
<a <button type="button" class="buttonSmall" id="customerView" href="{{URL::to('customer',array('id'=>'abf'))}}" >View</button></a>
But I need the array value 'abf' to be the value of a textbox.
Upvotes: 0
Reputation: 7474
Basically you can pass parameter to routes by doing:
Route::get('user/{name}', function($name)
{
//
})
->where('name', '[A-Za-z]+');
In your anchor tag, instead of doing href={{URL...}}, do something like:
{{ URL::to('user/$param') }}
For more information on routing, visit link
Upvotes: 3