I have 2 tables "messages" and "users", structures as the following:
users
id | first_name | last_name | ...
messages
id | subject | message | from_user | to_user
I want to implement a search function where a user can search for example "Hello World" and the result would include all matching columns from both tables for first_name, last_name, subject, message for "Hello" and "World".
I am using laravel 4, tried doing something like this:
return Message::where(function($query) use ($userId, $keyword)
{
$query->where('subject', 'like', $keyword)
->orWhere('message', '=', $keyword);
})
->where('is_deleted', '=', false)
->orderBy('is_seen', 'asc')
->paginate(20);
No idea, how to loop to get search results for each of "Hello" and "world". Also how to put in the join and search first_name and last_name from users table. Would very much appreciate help.