Create the form(s) to choose the criteria. Then create a MYSQL query or use query builder to select where
those criteria are met. Eg.,
SELECT * FROM products WHERE onsale = '1' AND colour = 'blue'
Yes.. but i would like to use Eloquent i think, is something like this...
public function showcriterio($param)
{
$productos=Producto::where('nombre','like',$param);
return View::make('admin/productospedido/agregar', $productos);
}
How can I do it?
an example
public function getSearch() {
$keyword = Input::get('keyword');
return View::make('store.search')
->with('products', Product::where('title', 'LIKE', '%'.$keyword.'%')->get())
->with('keyword', $keyword);
}
Thanks! it's working... lml But I don't know why...ja...Ok I only add, ->get() but i dont know, what that works...I read the official documentation, and it says nothing about that. I also saw
->take(10)->get();
how that works?
get() is an Eloquent helper function in a query. It is php. It is the same as a requesting data in a query. For example" $this->db->get('users');
where() (and other functions) construct the query. get() execute the query and returns a collection of models.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community