You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-15Lines changed: 35 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -40,21 +40,21 @@ You can override the methods by simply putting in your own methods to override -
40
40
41
41
For the get command you can filter by using the following url patterns
42
42
43
-
| Seperator | Description | Example | Result |
44
-
| --- | --- | --- | --- |
45
-
|*`=`*| Equals | ?field=hello | select ... where field = 'hello' |
46
-
|*`!=`*| Not Equals | ?field!=hello | select ... where field != 'hello' |
47
-
|*`<>`*| Not Equals (alt) | ?field<>hello | select ... where field != 'hello' |
48
-
|*`>`*| Greater Than | ?field>5 | select ... where field > 5 |
49
-
|*`>=`*| Greater Or Equal to | ?field=>5 | select ... where field >= 5 |
50
-
|*`<`*| Less Than | ?field<5 | select ... where field <> 5 |
51
-
|*`<=`*| Less Or Equal to | ?field=<5 | select ... where field <= 5 |
52
-
|*`~`*| Contains (LIKE with wildcard on both sides)| ?field~hello | select ... where field like '%hello%' |
53
-
|*`^`*| Starts with (LIKE with wildcard on end)| ?field^hello | select ... where field like 'hello%' |
54
-
|*`$`*| Ends with (LIKE with wildcard on start)| ?field$hello | select ... where field like 'hello%' |
55
-
|*`!~`*| Not Contains (LIKE with wildcard on both sides)| ?field!~hello | select ... where field not like '%hello%' |
56
-
|*`!^`*| Not Starts with (LIKE with wildcard on end)| ?field!^hello | select ... where field not like 'hello%' |
57
-
|*`!$`*| Not Ends with (LIKE with wildcard on start)| ?field!$hello | select ... where field not like 'hello%' |
43
+
| Seperator | Description | Example | Result |
44
+
| --- | --- | --- | --- |
45
+
|*`=`*| Equals | ?filter[field]=hello| select ... where field = 'hello' |
46
+
|*`!=`*| Not Equals | ?filter[field!]=hello| select ... where field != 'hello' |
47
+
|*`<>`*| Not Equals (alt) | ?filter[field<>]=hello | select ... where field != 'hello' |
48
+
|*`>`*| Greater Than | ?filter[field>]=5 | select ... where field > 5 |
49
+
|*`>=`*| Greater Or Equal to | ?filter[field=>]=5 | select ... where field >= 5 |
50
+
|*`<`*| Less Than | ?filter[field<]=5 | select ... where field <> 5 |
51
+
|*`<=`*| Less Or Equal to | ?filter[field=<]=5 | select ... where field <= 5 |
52
+
|*`~`*| Contains (LIKE with wildcard on both sides)| ?filter[field~]=hello| select ... where field like '%hello%' |
53
+
|*`^`*| Starts with (LIKE with wildcard on end)| ?filter[field^]=hello| select ... where field like 'hello%' |
54
+
|*`$`*| Ends with (LIKE with wildcard on start)| ?filter[field$]=hello| select ... where field like 'hello%' |
55
+
|*`!~`*| Not Contains (LIKE with wildcard on both sides)| ?filter[field!~]=hello | select ... where field not like '%hello%' |
56
+
|*`!^`*| Not Starts with (LIKE with wildcard on end)| ?filter[field!^]=hello | select ... where field not like 'hello%' |
57
+
|*`!$`*| Not Ends with (LIKE with wildcard on start)| ?filter[field!$]=hello | select ... where field not like 'hello%' |
58
58
59
59
60
60
# Fields, Relationships, Sorting & Pagination
@@ -80,8 +80,28 @@ By default all fields are returned, you can limit that to specific fields in the
80
80
* pagination can also be passed via the url using `limit=xx&page=y`
81
81
* pagination can also be limited to a max per page by overriding the `protected $maximumLimit = false;` parameter
82
82
83
+
## Validation
84
+
* When Posting a new record, validation can be done by adding a `rulesForCreate` method to your controller returning an array eg
85
+
```php
86
+
[
87
+
'email' => 'required|email',
88
+
'games' => 'required|numeric',
89
+
]
90
+
```
91
+
see https://laravel.com/docs/5.8/validation#conditionally-adding-rules
92
+
* for updating a record, add a method `rulesForUpdate` per above.
93
+
94
+
## Defaults
83
95
96
+
The following parameters are set in the Base Api controller and can be overwritten by your Controller on a case by case basis:
84
97
98
+
*`protected $resourceKeySingular = 'data';` Resource key for an item.
99
+
*`protected $resourceKeyPlural = 'data';` Resource key for a collection.
100
+
*`protected $defaultFields = ['*'];` Default Fields to respond with
101
+
*`protected $defaultSort = null;` Set the default sorting for queries.
102
+
*`protected $defaultLimit = 25;` Number of items displayed at once if not specified. (0 = maximumLimit)
103
+
*`protected $maximumLimit = 0;` Maximum limit that can be set via $_GET['limit']. - this ties in with the defaultLimit aswell, and if wanting to disable pagination , both should be 0. ) will allow all records to be returned in a single call.
104
+
*`protected $unguard = false;` Do we need to unguard the model before create/update?
0 commit comments