我有这个问题:
SELECT * FROM table
WHERE ( name = '%alex%'
OR address = '%alex%'
OR lastname = '%alex%'
) AND id = '%alex%'
AND email = '%alex%'
如何将上述SQL查询转换为Laravel Query构建器标准?
答案 0 :(得分:1)
Illuminate\Support\Facades\DB::table('table')
->where('name', 'LIKE', '%alex%')
->orWhere('address', 'LIKE', '%alex%')
->orWhere('lastname', 'LIKE', '%alex%')
->where('id', 'LIKE', '%alex%')
->where('email', 'LIKE', '%alex%')
->get();