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$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();
1$book = array('book2','book3','book5');
2
3$name = DB::Table('bookinfo')
4 ->select('BookName', 'bookId')
5 ->Where(function ($query) use($book) {
6 for ($i = 0; $i < count($book); $i++){
7 $query->orwhere('bookname', 'like', '%' . $book[$i] .'%');
8 }
9 })->get();
10
1$admin_permissions = Permission::all();
2// Teacher Role
3$teacher_permissions = $admin_permissions->filter(function ($permission) {
4 return substr($permission->title, 0, 8) == 'teacher_';
5});