/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); DB::statement('SET FOREIGN_KEY_CHECKS=0;'); CodeProject\Entities\ProjectTask::truncate(); CodeProject\Entities\ProjectNote::truncate(); CodeProject\Entities\Project::truncate(); CodeProject\Entities\Client::truncate(); CodeProject\Entities\User::truncate(); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); $this->call(ClientTableSeeder::class); $this->call(UserTableSeeder::class); $this->call(ProjectTableSeeder::class); $this->call(ProjectNoteTableSeeder::class); $this->call(ProjectTaskTableSeeder::class); DB::table('oauth_clients')->insert(['id' => 'appid1', 'secret' => 'secret', 'name' => 'AngularAPP']); Model::reguard(); }
/* |-------------------------------------------------------------------------- | Model Factories |-------------------------------------------------------------------------- | | Here you may define all of your model factories. Model factories give | you a convenient way to create models for testing and seeding your | database. Just tell the factory how a default model should look. | */ $factory->define(CodeProject\Entities\User::class, function (Faker\Generator $faker) { return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)]; }); $factory->define(CodeProject\Entities\Client::class, function (Faker\Generator $faker) { return ['name' => $faker->name, 'responsible' => $faker->name, 'email' => $faker->email, 'phone' => $faker->phoneNumber, 'address' => $faker->address, 'obs' => $faker->sentence]; }); $factory->define(CodeProject\Entities\Project::class, function (Faker\Generator $faker) { return ['owner_id' => CodeProject\Entities\User::all()->random()->id, 'client_id' => CodeProject\Entities\Client::all()->random()->id, 'name' => $faker->name, 'description' => $faker->sentence, 'progress' => rand(1, 100), 'status' => rand(1, 3), 'due_date' => $faker->dateTime('now')]; }); $factory->define(CodeProject\Entities\ProjectNote::class, function (Faker\Generator $faker) { return ['project_id' => CodeProject\Entities\Project::all()->random()->id, 'title' => $faker->word, 'note' => $faker->paragraph]; }); $factory->define(CodeProject\Entities\ProjectTask::class, function (Faker\Generator $faker) { return ['project_id' => CodeProject\Entities\Project::all()->random()->id, 'name' => $faker->word, 'start_date' => $faker->dateTime, 'due_date' => $faker->dateTime, 'status' => rand(1, 3)]; }); $factory->define(CodeProject\Entities\ProjectMember::class, function (Faker\Generator $faker) { return ['project_id' => CodeProject\Entities\Project::all()->random()->id, 'user_id' => CodeProject\Entities\User::all()->random()->id]; }); $factory->define(CodeProject\Entities\Oauth_client::class, function (Faker\Generator $faker) { return ['id' => $faker->word, 'secret' => $faker->word, 'name' => $faker->word]; });
/** * Run the database seeds. * * @return void */ public function run() { CodeProject\Entities\Project::truncate(); factory(\CodeProject\Entities\Project::class, 10)->create(); // }