Skip to content

Commit

Permalink
Explained how to obtain data in action from the field
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjacho committed Jun 27, 2019
1 parent 2393d51 commit 0af8dfa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ public function fields(Request $request){
BelongsToManyField::make('Role Label', 'roles', 'App\Nova\Role')->options(\App\Role::all())->isAction(),
}
```
To obtain the data that is send in action do it:

```php
public function handle(ActionFields $fields, Collection $models)
{
// Get the expenseTypes from the request because the Field BelongsToManyField does not send it

$values = array_column(json_decode(request()->roles, true),'id');

foreach ($models as $model) {
$model->roles()->sync($values);
}
}
```

### Validations
This package implement all Laravel Validations, you need to pass the rules in rules method, rules are listed on laravel validations rules for arrays*.
Expand Down

0 comments on commit 0af8dfa

Please sign in to comment.