Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,18 @@ $two->questions()->create([
The `Entry` model comes with a `fromArray` function.
This is especially useful when you're creating an entry from a form submission.
```php
(new Entry)->for($survey)->fromArray([
(new Entry())->for($survey)->fromArray([
'q1' => 'Yes',
'q2' => 5
])->push();
```

The answer array should be in the format of `q + question_id => answer`, thus becoming `'q1' => 'my answer'`.

#### By a Specific User
You may fluently specify the participant using the `by()` function.
```php
(new Entry)->for($survey)->by($user)->fromArray($answers)->push();
(new Entry())->for($survey)->by($user)->fromArray($answers)->push();
```

### Setting Constraints
Expand Down Expand Up @@ -137,11 +139,11 @@ Validate user's input against the entire rule set of your `Survey` using Laravel
```php
class SurveyEntriesController extends Controller
{
public function store(Survey $survey, Request $request)
public function store(Request $request, Survey $survey)
{
$answers = $request->validate($request, $survey->rules);
$answers = $request->validate($survey->rules, $request->all());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can drop the second argument.

Suggested change
$answers = $request->validate($survey->rules, $request->all());
$answers = $request->validate($survey->rules);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out. I confirmed that it's working without the 2nd param.


(new Entry)->for($survey)->fromArray($answers)->push();
(new Entry())->for($survey)->fromArray($answers)->push();
}
}
```
Expand Down