Form input as parameters Laravel Eloquent -
i want dynamically query using dynamic values form inputs
my form looks this
<form action="{{url('search')}} method="post"> <input name="min" type="number"> <input name="max" type="number"> <button type="submit">submit</button>
routes
route::post('search', 'searchcontroller@search');
action
public function search($min, $max) { $max = //this should form $min= //this should form $result = $this->users->showresultbyageminmax($max,$min);//some code repository }
how whould pass data form values min, max parameters?
$min = 15;//works $max = 100;//works//
but want dynamically populated form user
there few methods that.
1. request object (recommended).
public function search(request $request) { $max = $request->input("max"); $min= $request->input("min"); $result = $this->users->showresultbyageminmax($max,$min);//some code repository }
or:
public function search(request $request) { $max = $request->get("max"); $min= $request->get("min"); $result = $this->users->showresultbyageminmax($max,$min);//some code repository }
2. input facade.
public function search() { $max = input::get("max"); $min= input::get("min"); $result = $this->users->showresultbyageminmax($max,$min);//some code repository }
3. php $_post superglobal.
public function search() { $max = $_post["max"]; $min= $_post["min"]; $result = $this->users->showresultbyageminmax($max,$min);//some code repository }
Comments
Post a Comment