In this tutorial we're going to investigate how we can reuse the logic in Laravel Form requests for the difference between Create and Update requests. Laravel form requests are great, they allow you to include all the validation and authentication logic in the request object and you will know everything in the controller has already been validated.
* * @return array */ public function rules() { return [ 'title' => 'required|string', 'content' => 'required|string' ]; }} https://paulund.co.uk/dry-create-and-update-laravel-form-requests#update-post class UpdatePost extends FormRequest { /** * Get the validation rules that apply to the request.
As the UpdatePost request is the same as the CreatePost but with an extra field, why not just reuse the CreatePost request rules.
class UpdatePost extends CreatePost { /** * Get the validation rules that apply to the request.