PHP code example of cheesegrits / iseed

1. Go to this page and download the library: Download cheesegrits/iseed 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/ */

    

cheesegrits / iseed example snippets


// ...
SchuBu\Iseed\IseedServiceProvider::class,

\Iseed::generateSeed($tableName);

\Iseed::generateSeed('users', 'mysql2', 100);


// File: /database/seeders/UsersTableSeeder.php
namespace Database\Seeders;

use Illuminate\Database\Seeder;

class UsersTableSeeder extends Seeder {

    /**
     * Auto generated seeder file.
     *
     * @return void
     */
    public function run()
    {

        \DB::table('users')->delete();

        \DB::table('users')->insert(array (
            0 =>
            array (
                'id' => '1',
                'email' => '[email protected]',
                'password' => '$2y$10$tUGCkQf/0NY3w1l9sobGsudt6UngnoVXx/lUoh9ElcSOD0ERRkK9C',
                'permissions' => NULL,
                'activated' => '1',
                'activation_code' => NULL,
                'activated_at' => NULL,
                'last_login' => NULL,
                'persist_code' => NULL,
                'reset_password_code' => NULL,
                'first_name' => NULL,
                'last_name' => NULL,
                'created_at' => '2013-06-11 07:47:40',
                'updated_at' => '2013-06-11 07:47:40',
            ),
            1 =>
            array (
                'id' => '2',
                'email' => '[email protected]',
                'password' => '$2y$10$ImNvsMzK/BOgNSYgpjs/3OjMKMHeA9BH/hjl43EiuBuLkZGPMuZ2W',
                'permissions' => NULL,
                'activated' => '1',
                'activation_code' => NULL,
                'activated_at' => NULL,
                'last_login' => '2013-06-11 07:54:57',
                'persist_code' => '$2y$10$C0la8WuyqC6AU2TpUwj0I.E3Mrva8A3tuVFWxXN5u7jswRKzsYYHK',
                'reset_password_code' => NULL,
                'first_name' => NULL,
                'last_name' => NULL,
                'created_at' => '2013-06-11 07:47:40',
                'updated_at' => '2013-06-11 07:54:57',
            ),
        ));
    }

}


// File: /database/seeders/DatabaseSeeder.php
namespace Database\Seeders;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder {

    /**
     * Run the database seeds.
     *
     * @return void
        */
    public function run()
    {
        Eloquent::unguard();

        if(App::environment() == "local")
        {
            throw new \Exception('Only run this from production');
        }

        // All generated seeds are added between #iseed_start & #iseed_end.
        #iseed_start
        $this->call(UsersTableSeeder::class);
        #iseed_end
    }

}
console
$ php artisan iseed users --dumpauto=false
console
$ php artisan iseed users --clean
console
$ php artisan iseed users --database=mysql2
console
$ php artisan iseed users --max=10
console
$ php artisan iseed users --chunksize=100
console
$ php artisan iseed users --max=10 --orderby=id
console
$ php artisan iseed users --max=10 --orderby=id --direction=desc
console
$ php artisan iseed users --prerun=someEvent
console
$ php artisan iseed users,groups --prerun=someUserEvent,someGroupEvent
console
$ php artisan iseed users,groups --prerun=,someGroupEvent
console
$ php artisan iseed users --postrun=someEvent
console
$ php artisan iseed users,groups --postrun=someUserEvent,someGroupEvent
console
$ php artisan iseed users,groups --postrun=,someGroupEvent
console
$ php artisan iseed users --noindex