1. Go to this page and download the library: Download brad-denver/paris-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/ */
namespace Seeds;
class Roles extends \Model {
/*
* use the Paris filter pattern to create a new fake record
*/
public function create_fake($orm, $faker) {
$orm->create(array(
'title' => $faker->word
));
return $orm;
}
}
class Users extends \Model {
/*
* use the Paris filter pattern to create a new fake record
*/
public function create_fake($orm, $faker) {
$orm->create(array(
'name' => $faker->name,
'role_id' => $faker->randomDigit
));
return $orm;
}
}
$faker = Faker\Factory::create('fr_FR'); // create a French faker
Seeder::seed('Seeds\Users', 5, null, null, $faker);
// a paris model pointing to our production roles table
$source_model = Model::factory('Roles', 'remote');
// a paris model pointing to our dev roles table that needs to mirror production
$target_model = Model::factory('Roles', 'local');
Seeder::replicate($source_model, $target_model);
Seeder::delete_all('Seeds\Users');
Seeder::delete_all_and_seed('Seeds\Users', 5);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.