Support the ongoing development of Laravel.io →
Eloquent Forms
Last updated 2 years ago.
0

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 ?

Last updated 2 years ago.
0

Anyone ?

Last updated 2 years ago.
0

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().

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

lstables lstables Joined 5 Jan 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.