{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/16990","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/16990/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/16990/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/16990/events","html_url":"https://github.com/laravel/framework/pull/16990","id":197607973,"number":16990,"title":"[5.3] Idea to add onlyRulesValues for FormRequest","user":{"login":"allok","id":561064,"avatar_url":"https://avatars.githubusercontent.com/u/561064?v=3","gravatar_id":"","url":"https://api.github.com/users/allok","html_url":"https://github.com/allok","followers_url":"https://api.github.com/users/allok/followers","following_url":"https://api.github.com/users/allok/following{/other_user}","gists_url":"https://api.github.com/users/allok/gists{/gist_id}","starred_url":"https://api.github.com/users/allok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allok/subscriptions","organizations_url":"https://api.github.com/users/allok/orgs","repos_url":"https://api.github.com/users/allok/repos","events_url":"https://api.github.com/users/allok/events{/privacy}","received_events_url":"https://api.github.com/users/allok/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-26T17:45:01Z","updated_at":"2016-12-27T16:56:10Z","closed_at":"2016-12-27T16:56:10Z","pull_request":{"url":"https://api.github.com/repos/laravel/framework/pulls/16990","html_url":"https://github.com/laravel/framework/pull/16990","diff_url":"https://github.com/laravel/framework/pull/16990.diff","patch_url":"https://github.com/laravel/framework/pull/16990.patch"},"body":"Right now we don't have a simple way to get from FormRequest only those fields which were described in rules. It is very will be useful when you have a big list of **$fillable** properties (for mass assignable) in Model and you want to use save() or update() for just add only described(safe) **attributes** (Or you don't want to use $request->only() with described manually attributes).\r\nMy idea to add onlyRulesValues which help in simple way:\r\n```php\r\n    public function onlyRulesValues()\r\n    {\r\n        $rules = $this->rules();\r\n\r\n        if (!empty($rules)) {\r\n            return $this->only(array_keys($rules));\r\n        }\r\n\r\n        return [];\r\n    }\r\n\r\n$attributes = $request->getOnlyRulesValues();\r\n\r\n$model->save($attributes);\r\n// or\r\n$model->update($attributes);\r\n```"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/269352012","html_url":"https://github.com/laravel/framework/pull/16990#issuecomment-269352012","issue_url":"https://api.github.com/repos/laravel/framework/issues/16990","id":269352012,"user":{"login":"taylorotwell","id":463230,"avatar_url":"https://avatars.githubusercontent.com/u/463230?v=3","gravatar_id":"","url":"https://api.github.com/users/taylorotwell","html_url":"https://github.com/taylorotwell","followers_url":"https://api.github.com/users/taylorotwell/followers","following_url":"https://api.github.com/users/taylorotwell/following{/other_user}","gists_url":"https://api.github.com/users/taylorotwell/gists{/gist_id}","starred_url":"https://api.github.com/users/taylorotwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taylorotwell/subscriptions","organizations_url":"https://api.github.com/users/taylorotwell/orgs","repos_url":"https://api.github.com/users/taylorotwell/repos","events_url":"https://api.github.com/users/taylorotwell/events{/privacy}","received_events_url":"https://api.github.com/users/taylorotwell/received_events","type":"User","site_admin":false},"created_at":"2016-12-27T16:56:10Z","updated_at":"2016-12-27T16:56:10Z","body":"You should be able to add this to a base request class all your other form requests extend."}}
{"actor":{"display_login":"taylorotwell"}}