Skip to content
Advertisement

Search is not working although item exists in DB

I am using laravel 6 : need user to find records by search bar, but it shows No Available Records

enter image description here this in my model:Category model:

JavaScript

Then in my controller I used in the index when search function:categoryController

JavaScript

Advertisement

Answer

'%$search%' is literally searching for the string $search, not whatever $search contains… Using '(single quotes) in PHP doesn’t extract the value from the variable, you need to concatenate the value or use "(double quotes):

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement