{"id":28548972,"url":"https://github.com/stydenet/seeder","last_synced_at":"2025-07-04T12:30:31.968Z","repository":{"id":33769451,"uuid":"37425807","full_name":"StydeNet/seeder","owner":"StydeNet","description":"Improved seeders for Laravel 5.0 and 5.1","archived":false,"fork":false,"pushed_at":"2016-08-23T19:35:48.000Z","size":27,"stargazers_count":8,"open_issues_count":1,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-10T01:39:13.183Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StydeNet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-14T19:12:14.000Z","updated_at":"2020-02-13T12:12:15.000Z","dependencies_parsed_at":"2022-09-01T13:01:13.367Z","dependency_job_id":null,"html_url":"https://github.com/StydeNet/seeder","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/StydeNet/seeder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StydeNet%2Fseeder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StydeNet%2Fseeder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StydeNet%2Fseeder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StydeNet%2Fseeder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StydeNet","download_url":"https://codeload.github.com/StydeNet/seeder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StydeNet%2Fseeder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263538600,"owners_count":23477454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-10T01:35:23.131Z","updated_at":"2025-07-04T12:30:31.962Z","avatar_url":"https://github.com/StydeNet.png","language":"PHP","readme":"# Styde Seeder\n\nThis package for [Laravel](https://laravel.com/) allow seeding your database with faker data. It is an alternative to Model Factories of Laravel 5.1. With this package you can seed a model of your application and its related models too, using the package [Faker](https://github.com/fzaninotto/Faker).\n\n## Installation\n\nTo install through [Composer](https://getcomposer.org/):\n\n1. Add the following instruction to the \"require\" object in your composer.json:\n```\n\"styde/seeder\": \"^1.0\"\n```\nor simply execute on your console:\n```\ncomposer require styde/seeder\n```\nThen run `composer update`.\n\n2. After **Styde Seeder** is installed, you need to add the service provider to the `providers` array in `config/app.php`\n```\n'providers' =\u003e [\n    // ...\n    Styde\\Seeder\\SeederServiceProvider::class,\n    // ...\n],\n```\n\n3. Then add the following to your `database/seeds/DatabaseSeeder.php`:\n```\n\u003c?php\n\nuse Styde\\Seeder\\BaseSeeder;\n\nclass DatabaseSeeder extends BaseSeeder\n{\n    protected $truncate = array(\n        //'users',\n    );\n\n    protected $seeders = array(\n        //'User',\n    );\n}\n```\nSpecify the tables of database you want to `$truncate` (order does not matter since the foreign key check will be disabled) Then add the `$seeders`, by default it will autocomplete the suffix `\"TableSeeder\"` so no need to add it.\n\n## Usage\n\nTo create a new seeder file you can run:\n```\nphp artisan styde:seeder NameOfSeeder\n```\nAnd a new file called `NameOfSeederTableSeeder.php` will be created at `database/seeds` directory.\n\nThen complete your seeder with new instance of the Model in the `getModel()` method and its attributes in the `getDummyData` method. You can use [Faker](https://github.com/fzaninotto/Faker) for generates fake data, for example:\n\n```\nphp artisan styde:seeder User\n```\nCompleting the Model in getModel() and some attributes with faker data:\n```\n\u003c?php\n\nuse Styde\\Seeder\\Seeder;\nuse Faker\\Generator;\nuse App\\User;\n\nclass UserTableSeeder extends Seeder\n{\n    protected $total = 50;\n\n    public function getModel()\n    {\n        return new User();\n    }\n\n    public function getDummyData(Generator $faker, array $customValues = array())\n    {\n        return [\n            'name' =\u003e $faker-\u003ename,\n            'email' =\u003e $faker-\u003eemail,\n            'password'  =\u003e bcrypt('secret'),\n        ];\n    }\n}\n```\n\nOnce you run the seed command in Laravel `php artisan db:seed` it will create 50 users with random data by default.\n\n### Helpers\n\nAlso, you can use these two helpers when you are working with tests or `php artisan tinker`:\n```\n/**\n     * Create one instance or a collection of the given model and persist them to the database.\n     *\n     * @param  string  $seeder\n     * @param  integer $total\n     * @param  array   $customValues\n     *\n     * @return mixed\n     */\n    function seed($seeder, $total = 1, array $customValues = array())\n```\nFor example to create 5 users `seed('User', 5)` or to create one user with specific data `seed('User', ['name' =\u003e 'John', 'email' =\u003e 'john@example.com'])`.\n\n```\n/**\n     * Create one instance or a collection of a given model.\n     *\n     * @param  string  $seeder\n     * @param  integer $total\n     * @param  array   $customValues\n     *\n     * @return mixed\n     */\n    function model($seeder, $total = 1, array $customValues = array())\n```\nWith this helper you only can create an instance or collection, but will not be persisted to the database.\n\n## About\n\nStyde Seeder was created by [Duilio Palacios](https://twitter.com/sileence) as part of the code for the course [Crea tu primera aplicación con Laravel 5](https://styde.net/cursos/crea-tu-primera-aplicacion-con-laravel-5/) (in Spanish)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstydenet%2Fseeder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstydenet%2Fseeder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstydenet%2Fseeder/lists"}