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

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'
Last updated 2 years ago.
0

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?

Last updated 2 years ago.
0

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);
}
Last updated 2 years ago.
0

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?

Last updated 2 years ago.
0

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');

Last updated 2 years ago.
0

where() (and other functions) construct the query. get() execute the query and returns a collection of models.

Last updated 2 years ago.
0

Ok, thank you to all!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.