Skip to content

Commit 5fe6a28

Browse files
author
Brian Dillingham
committed
wip
1 parent 3b14398 commit 5fe6a28

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

readme.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,35 @@ composer require dillingham/nova-ajax-select
1212

1313
### Usage
1414

15-
```php
15+
Specify a url for the field to retrieve data from
16+
17+
Optionally, specifiy a parent() `attribute` to trigger the query:
1618

19+
```php
1720
BelongsTo::make('Company'),
1821

19-
AjaxSelect::make('Employee')
20-
->get('/api/employees/{company}')
22+
AjaxSelect::make('Users')
23+
->get('/api/company/{company}/users')
2124
->parent('company'),
2225
```
2326

27+
Example Endpoint
28+
29+
```php
30+
Route::get('api/company/{company}/users', function($company_id) {
31+
32+
$company = \App\Company::findOrFail($company_id);
33+
34+
return $company->users->map(function($user) {
35+
return ['key' => $user->id, 'display' => $user->name ];
36+
});
37+
});
38+
```
39+
2440
### Url Options
2541

2642
| parameter | description | value |
2743
| - | - | - |
2844
| {resource-name} | the resource name | "Order" |
2945
| {resource-id} | the resource being edited | "11"
30-
| {parent} | put the attribute not ie {employee} | "22" |
46+
| {parent} | put the attribute ie {company} | "22" |

0 commit comments

Comments
 (0)