-
Notifications
You must be signed in to change notification settings - Fork 66
Other Examples
Selahattin edited this page Oct 8, 2015
·
7 revisions
/api/users?columns=name,age,city_id
-
The resulting query =
Users::select(['name', 'age', 'city_id'])
For relations
/api/users?columns=*,city.id,city.name&includes=city
- The resulting query =
User::with(['city' => function($q) {
return $q->select(['id', 'name']);
}])->select(['*'])
/api/users?includes=city,country,town
-
The resulting query =
Users::with(['city', 'country', 'town'])
/api/users?limit=3
-
The resulting query =
Users::take(3)
For unlimited
/api/users?limit=unlimited
/api/users?order_by=name,asc
-
The resulting query =
Users::orderBy('name', 'asc')
You can sort by multiple columns:
/api/users?order_by=name,asc|age,desc|...
-
The resulting query =
Users::orderBy('name', 'asc')->orderBy('age', 'desc')
/api/users?page=2
-
The resulting query =
Users::skip(2 - 1 * {limit})
/api/users?name=Selahattin
-
The resulting query =
Users::where('name', '=', 'Selahattin')
/api/users?name!=Selahattin
-
The resulting query =
Users::where('name', '!=', 'Selahattin')
/api/users?name=*se
-
The resulting query =
Users::where('name', 'like', '%se')
/api/users?name=se*
-
The resulting query =
Users::where('name', 'like', 'se%')
/api/users?name=\*se\*
-
The resulting query =
Users::where('name', 'like', '%se%')
/api/users?age<18
-
The resulting query =
Users::where('age', '<', 18)
/api/users?age>18
-
The resulting query =
Users::where('age', '>', 18)
/api/users?age<=18
-
The resulting query =
Users::where('age', '<=', 18)
/api/users?age>=18
-
The resulting query =
Users::where('age', '>=', 18)
For whereBetween:
/api/users?age>10&age<20
-
The resulting query
Users::where('age', '>', 10)->where('age', '<', 20)