Issue
I have a table: Email, and the attributes: id, subject, content, to, cc, ...
Then in the index, there is only one search box. I want this search-box can search all value in each attribute.
Like this picture above, we can search by "To" attribute, or "Subject" attribute or other attributes in 1 search textbox.
Should i code in the controller or in the index view?
I hope all of you can share the code, so can complete this task.
Thank you and have a great day
Solution
After search value filtered in following fields if $search variable is empty then orFilterWhere function ignore that condition in query
$model = User::find()
$model
->orFilterWhere(['like', 'name', $search])
->orFilterWhere(['like', 'email', $search])
->orFilterWhere(['like', 'address', $search])
->asArray()
->all();
Answered By - Shringiraj Dewangan


0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.