{"action":"closed","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/10391","labels_url":"https://api.github.com/repos/laravel/framework/issues/10391/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/10391/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/10391/events","html_url":"https://github.com/laravel/framework/issues/10391","id":108472024,"number":10391,"title":"[feature request] automagically mass assign models and their relationships","user":{"login":"Evertt","id":1267282,"avatar_url":"https://avatars.githubusercontent.com/u/1267282?v=3","gravatar_id":"","url":"https://api.github.com/users/Evertt","html_url":"https://github.com/Evertt","followers_url":"https://api.github.com/users/Evertt/followers","following_url":"https://api.github.com/users/Evertt/following{/other_user}","gists_url":"https://api.github.com/users/Evertt/gists{/gist_id}","starred_url":"https://api.github.com/users/Evertt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Evertt/subscriptions","organizations_url":"https://api.github.com/users/Evertt/orgs","repos_url":"https://api.github.com/users/Evertt/repos","events_url":"https://api.github.com/users/Evertt/events{/privacy}","received_events_url":"https://api.github.com/users/Evertt/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-26T14:47:19Z","updated_at":"2015-09-30T07:56:24Z","closed_at":"2015-09-30T07:56:24Z","body":"Lets say I make a form like this:\r\n\r\n```html\r\n<form>\r\n    <input type=\"text\" name=\"User[person][name]\">\r\n    <input type=\"text\" name=\"User[person][infix]\">\r\n    <input type=\"text\" name=\"User[person][surname]\">\r\n\r\n    <input type=\"text\" name=\"User[email]\">\r\n    <input type=\"text\" name=\"User[password]\">\r\n    <input type=\"text\" name=\"User[password_confirmation]\">\r\n\r\n    <input type=\"checkbox\" name=\"User[person][tags][]\" value=\"1\"> hot\r\n    <input type=\"checkbox\" name=\"User[person][tags][]\" value=\"2\"> cool\r\n</form>\r\n```\r\n\r\nAs you can see, all the relationships between the models are apparent from the way I've set up the form. The resulting array might look something like:\r\n\r\n![screen shot 2015-09-26 at 16 43 22](https://cloud.githubusercontent.com/assets/1267282/10118057/c48be58e-646d-11e5-919d-3bfc39774e0e.png)\r\n\r\nNow in my UserController's store method I'd still need to separately assign everything to the corresponding models, because mass-assignment doesn't work for relationships. But that's so unnecessary work and over the course of a big project it adds up.\r\n\r\nI think it would be cool if the model would automagically be built up in the Request object, so you could do this:\r\n\r\n```php\r\n// In UsersController\r\n\r\npublic function store(CreateUserRequest $request)\r\n{\r\n    // We know it's validated, because otherwise we'd never hit this code\r\n    $user = $request['User'];\r\n    $user->save();\r\n}\r\n```\r\n\r\nOr if you'd like a slightly different syntax then I'm all ears. I'm not invested in the syntax per se, I just want the \"write less code\" side of it.\r\n\r\nOf course I'd prefer if this process isn't tightly coupled with Eloquent, but via some contracts so I can build the same contracts in [Analogue](https://github.com/analogueorm/analogue)."}}