From 5fe6a28d27573e5a5a23a8c2d450b72807f867de Mon Sep 17 00:00:00 2001 From: Brian Dillingham Date: Sun, 10 Feb 2019 16:07:58 -0500 Subject: [PATCH] wip --- readme.md | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index ca0956b..e86c648 100644 --- a/readme.md +++ b/readme.md @@ -12,19 +12,35 @@ composer require dillingham/nova-ajax-select ### Usage -```php +Specify a url for the field to retrieve data from + +Optionally, specifiy a parent() `attribute` to trigger the query: +```php BelongsTo::make('Company'), -AjaxSelect::make('Employee') - ->get('/api/employees/{company}') +AjaxSelect::make('Users') + ->get('/api/company/{company}/users') ->parent('company'), ``` +Example Endpoint + +```php +Route::get('api/company/{company}/users', function($company_id) { + + $company = \App\Company::findOrFail($company_id); + + return $company->users->map(function($user) { + return ['key' => $user->id, 'display' => $user->name ]; + }); +}); +``` + ### Url Options | parameter | description | value | | - | - | - | | {resource-name} | the resource name | "Order" | | {resource-id} | the resource being edited | "11" -| {parent} | put the attribute not ie {employee} | "22" | \ No newline at end of file +| {parent} | put the attribute ie {company} | "22" | \ No newline at end of file