PHP code example of styde / seeder

1. Go to this page and download the library: Download styde/seeder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

styde / seeder example snippets




use Styde\Seeder\BaseSeeder;

class DatabaseSeeder extends BaseSeeder
{
    protected $truncate = array(
        //'users',
    );

    protected $seeders = array(
        //'User',
    );
}

php artisan styde:seeder NameOfSeeder

php artisan styde:seeder User



use Styde\Seeder\Seeder;
use Faker\Generator;
use App\User;

class UserTableSeeder extends Seeder
{
    protected $total = 50;

    public function getModel()
    {
        return new User();
    }

    public function getDummyData(Generator $faker, array $customValues = array())
    {
        return [
            'name' => $faker->name,
            'email' => $faker->email,
            'password'  => bcrypt('secret'),
        ];
    }
}

/**
     * Create one instance or a collection of the given model and persist them to the database.
     *
     * @param  string  $seeder
     * @param  integer $total
     * @param  array   $customValues
     *
     * @return mixed
     */
    function seed($seeder, $total = 1, array $customValues = array())

/**
     * Create one instance or a collection of a given model.
     *
     * @param  string  $seeder
     * @param  integer $total
     * @param  array   $customValues
     *
     * @return mixed
     */
    function model($seeder, $total = 1, array $customValues = array())