Select Join Where and orWhere in Laravel 5 -
i have 2 tables- jobseekers , resumes. try achieve 3 search options- entering 1. "first name", 2. "last name", , 3. "first name + last name". current code below:
$q = \request::get('keyword'); $data['resume'] = resume::join('jobseekers', 'jobseekers.user_id', '=', 'resumes.user_id') ->where('jobseekers.first_name','like','%'.$q.'%') ->orwhere('jobseekers.last_name','like','%'.$q.'%') ->orderby('resumes.updated_at','desc')->paginate(50);
using texbox (keywords), when search last / first name, works fine. however, when type both first + last name in textbox, shows no result.
please share me how achieve this.
using concat()
:
->orwhere(db::raw("concat(jobseekers.first_name, ' ', jobseekers.last_name)"), 'like','%'.$q.'%');
Comments
Post a Comment