{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/9947","labels_url":"https://api.github.com/repos/laravel/framework/issues/9947/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/9947/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/9947/events","html_url":"https://github.com/laravel/framework/pull/9947","id":101181673,"number":9947,"title":"dependency injection in model factories","user":{"login":"dan-har","id":8581476,"avatar_url":"https://avatars.githubusercontent.com/u/8581476?v=3","gravatar_id":"","url":"https://api.github.com/users/dan-har","html_url":"https://github.com/dan-har","followers_url":"https://api.github.com/users/dan-har/followers","following_url":"https://api.github.com/users/dan-har/following{/other_user}","gists_url":"https://api.github.com/users/dan-har/gists{/gist_id}","starred_url":"https://api.github.com/users/dan-har/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dan-har/subscriptions","organizations_url":"https://api.github.com/users/dan-har/orgs","repos_url":"https://api.github.com/users/dan-har/repos","events_url":"https://api.github.com/users/dan-har/events{/privacy}","received_events_url":"https://api.github.com/users/dan-har/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-15T14:35:41Z","updated_at":"2015-08-15T15:35:11Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/laravel/framework/pulls/9947","html_url":"https://github.com/laravel/framework/pull/9947","diff_url":"https://github.com/laravel/framework/pull/9947.diff","patch_url":"https://github.com/laravel/framework/pull/9947.patch"},"body":"It can be useful to inject some other classes to the factories, like some custom generators for data that is not included in `Faker`\r\n\r\nexample of use : \r\n```\r\n$factory->define(App\\User::class, function (App\\CustomGenerator $customGenerator, $faker, $attributes) {\r\n    \r\n    return [\r\n        'name' => $faker->name,\r\n        'email' => $faker->email,\r\n        'password' => str_random(10),\r\n        'remember_token' => str_random(10),\r\n        'custom_attribute' => $customGenerator->someValue()\r\n    ];\r\n});\r\n```\r\n\r\nAlso, the function `Factory::raw()` was not compatible with the change in #9387, so it was fixed.\r\n"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/131394895","html_url":"https://github.com/laravel/framework/pull/9947#issuecomment-131394895","issue_url":"https://api.github.com/repos/laravel/framework/issues/9947","id":131394895,"user":{"login":"Sladewill","id":6969435,"avatar_url":"https://avatars.githubusercontent.com/u/6969435?v=3","gravatar_id":"","url":"https://api.github.com/users/Sladewill","html_url":"https://github.com/Sladewill","followers_url":"https://api.github.com/users/Sladewill/followers","following_url":"https://api.github.com/users/Sladewill/following{/other_user}","gists_url":"https://api.github.com/users/Sladewill/gists{/gist_id}","starred_url":"https://api.github.com/users/Sladewill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sladewill/subscriptions","organizations_url":"https://api.github.com/users/Sladewill/orgs","repos_url":"https://api.github.com/users/Sladewill/repos","events_url":"https://api.github.com/users/Sladewill/events{/privacy}","received_events_url":"https://api.github.com/users/Sladewill/received_events","type":"User","site_admin":false},"created_at":"2015-08-15T15:35:11Z","updated_at":"2015-08-15T15:35:11Z","body":"Because the first expected parameter is supposed to be faker, anyone currently using that it will break for."}}