https://github.com/karakhanyans/seeder
Export Your Database Into Seeds
https://github.com/karakhanyans/seeder
database laravel laravel-5-package seeder
Last synced: about 2 months ago
JSON representation
Export Your Database Into Seeds
- Host: GitHub
- URL: https://github.com/karakhanyans/seeder
- Owner: karakhanyans
- Created: 2017-02-02T15:08:08.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-02T15:37:44.000Z (over 8 years ago)
- Last Synced: 2025-03-20T11:09:28.272Z (7 months ago)
- Topics: database, laravel, laravel-5-package, seeder
- Language: PHP
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Database Seeder
Seeder creates an artisan command that lets you quickly create seeds from your existing database.
## Install
Via Composer
```
composer require karakhanyans/seeder
```In your app/config/app.php file, add the following to the providers array:
```
Karakhanyans\Seeder\SeederServiceProvider::class,
```## Usage
Once installed, you should see generate:seed as one of the artisan commands when you run:
```
php artisan list
```For example:
```
php artisan generate:seed
```This would create seed files in your database/seeds directory with a php files, which would contain the following stub:
```
users = //serialized data;
}public function run(){
$this->setUsers();
foreach(unserialize($this->users) as $item){
try{
\App\User::create((array)$item);
}catch (\Exception $e){
\Illuminate\Support\Facades\Log::info('Duplicate entry for user: '.$item['id']);
}
}
}}
```
In your database/seeds/DatabaseSeeder.php file, add the following to the run() action to call all new seeds:
```
$this->call(GlobalSeeder::class);
```
If your models in specific folder you should use {folder} argument to generate your Seeds from that folder.
```
php artisan generate:seed Models
```
If you want to get all your models recursively you can use the following command with -r flag:
```
php artisan generate:seed Models -r
```
## NoteFor Users table please remove $hidden array to make sure that Seeder will contain all database fields.
```
protected $hidden = ['password', 'remember_token'];
```
## Change logPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.
## Security
If you discover any security related issues, please email karakhanyansa@gmail.com.
## Credits
- [Sergey Karakhanyan](https://github.com/karakhanyans)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
[ico-version]: https://img.shields.io/packagist/v/karakhanyans/seeder.svg
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg
[ico-downloads]: https://img.shields.io/packagist/dt/karakhanyans/seeder.svg[link-packagist]: https://packagist.org/packages/karakhanyans/seeder
[link-downloads]: https://packagist.org/packages/karakhanyans/seeder/stats
[link-author]: https://github.com/karakhanyans