1User::query()
2 ->where('name', 'LIKE', "%{$searchTerm}%")
3 ->orWhere('email', 'LIKE', "%{$searchTerm}%")
4 ->get();
5
6reference:
7https://freek.dev/1182-searching-models-using-a-where-like-query-in-laravel
1$data = DB::table('borrowers')
2 ->join('loans', 'borrowers.id', '=', 'loans.borrower_id')
3 ->select('borrowers.*', 'loans.*')
4 ->where('loan_officers', 'like', '%' . $officerId . '%')
5 ->where('loans.maturity_date', '<', date("Y-m-d"))
6 ->get();
7
1$camps = $field->camps()->where('status', 0)->where(function ($q) {
2 $q->where('sex', Auth::user()->sex)->orWhere('sex', 0);
3})->get();
1$users = DB::table('users')
2 ->where('votes', '>=', 100)
3 ->get();
4
5$users = DB::table('users')
6 ->where('votes', '<>', 100)
7 ->get();
8
9$users = DB::table('users')
10 ->where('name', 'like', 'T%')
11 ->get();