我想使用concat和eloquent,我有两个表(用户)和(汽车) 从users表我想使用first_name,last_name字段,并从cars表中我想使用名为(vin)的字段。
$cars = Car::where(DB::raw('concat(first_name," ",vin," ",make)') , 'LIKE' , '%$search%')->paginate();
来自Users表的first_name字段,其余来自Cars表
答案 0 :(得分:0)
您可以将join()
用作:
$cars = Car::join('users', 'cars.user_id', '=', 'users.id')
->where(DB::raw('concat(users.first_name," ",cars.vin," ",cars.make)') , 'LIKE' , "%$search%")
->select('cars.*')
->paginate();