Created
October 29, 2015 20:13
-
-
Save neilcrookes/1f7fa60136f6adebde65 to your computer and use it in GitHub Desktop.
Example syntax for validating multi-record forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ProductController { | |
/** | |
* Store a new product that belongs to multiple categories. | |
* | |
* @param Request $request | |
* @return Response | |
*/ | |
public function store(Request $request) | |
{ | |
$this->validate($request, [ | |
'name' => 'required|unique:products|max:255', | |
'description' => 'required', | |
'category.*.id' => 'exists:categories' | |
]); | |
// The product is valid, store in database... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment