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

Your like query implementation is not correct.

Try this :

public function findTag()
{
    $term = Input::get('tag_name');
    
    return Tag::where('tag_name', 'LIKE', '%' .$term . '%')->lists('tag_name');
}
Last updated 2 years ago.
0

When I exactly what you have there it returns all of the results. When I only replace the query and leave the rest alone, it doesn't return anything.

Last updated 2 years ago.
0

Anyone have any ideas?

Last updated 2 years ago.
0

Check this http://www.w3schools.com/sql/sql_like.asp how to use % in LIKE operator.

Last updated 2 years ago.
0

Maybe die/dump the query so you can see what the DB is actually getting... prior to your foreach() you could try:

$search = Tag::where('tag_name', 'LIKE', '%' . $term . '%')->get();
dd(DB::getQueryLog());
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jerauf jerauf Joined 16 Feb 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.