Also what is the best why to achieve the controller (above) to say what ever the user input in a input field to find that number (id) and return to view ?
See the route docs to learn about routing. You'd have a post route, and a 'uses' key for the controller and the specific method.
Route::post('pricing', array('as' => 'pricing', 'uses' => 'PricingController@pricing'));
Additionally, you need some kind of validation here. What if the user enters in an id that doesn't exist? Here's a start:
$pricing = Pricing::find(intval(Input::get('term'))); /* or you can use firstOrFail to bypass the checks below */
if ($pricing)
{
return View::make('layouts.buyresults', compact('pricing'));
}
App::abort('404');
Also, this is somewhat of a strange setup, generally you shouldn't have the users interacting with your primary keys at all. Look at Eloquent more, and probably use ->where() instead of find().
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community