示例#1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $questions = App\Question::all();
     factory(App\Answer::class, 400)->make()->each(function ($answer) use($questions) {
         $question = $questions->random();
         $answer->question()->associate($question);
         $answer->user()->associate($question->course->users->random());
         $answer->save();
     });
 }
示例#2
0
    $firs_name = $faker->firstName;
    $last_name = $faker->lastName;
    return ['identification' => $faker->unique()->numberBetween(5000000, 39999999), 'first_name' => $firs_name, 'last_name' => $last_name, 'avatar' => 'vendor/AdminTheme/images/avatar/default.png', 'type' => $faker->randomElement(['teacher', 'student']), 'email' => $faker->unique()->email, 'password' => '123456'];
});
$factory->define(App\Course::class, function ($faker) {
    return ['title' => $faker->sentence(3), 'description' => $faker->paragraph(10), 'image' => $faker->imageUrl(660, 260), 'user_id' => App\User::all()->random()->id];
});
$factory->define(App\Unit::class, function ($faker) {
    return ['pos' => $faker->randomNumber(1), 'title' => $faker->sentence(5), 'description' => $faker->paragraph(10), 'image' => $faker->imageUrl(660, 260), 'user_id' => App\User::all()->random()->id, 'course_id' => App\Course::all()->random()->id];
});
$factory->define(App\Lesson::class, function ($faker) {
    return ['pos' => $faker->randomNumber(1), 'title' => $faker->sentence(5), 'content' => $faker->paragraph(10), 'user_id' => App\User::all()->random()->id, 'unit_id' => App\Unit::all()->random()->id];
});
$factory->define(App\Question::class, function ($faker) {
    return ['title' => $faker->sentence(2) . '?', 'unit_id' => App\Unit::all()->random()->id, 'user_id' => App\User::all()->random()->id];
});
$factory->define(App\Answer::class, function ($faker) {
    return ['content' => $faker->sentence(5), 'correct' => rand(0, 1), 'question_id' => App\Question::all()->random()->id, 'user_id' => App\User::all()->random()->id];
});
$factory->define(App\Comment::class, function ($faker) {
    return ['content' => $faker->paragraph(5), 'user_id' => App\User::all()->random()->id, 'lesson_id' => App\Lesson::all()->random()->id];
});
$factory->define(App\Reply::class, function ($faker) {
    return ['content' => $faker->paragraph(5), 'user_id' => App\User::all()->random()->id, 'comment_id' => App\Comment::all()->random()->id];
});
$factory->define(App\Evaluation::class, function ($faker) {
    return ['value' => $faker->numberBetween(15, 20), 'min_value' => $faker->numberBetween(50, 85), 'max_question' => $faker->numberBetween(5, 6), 'unit_id' => App\Unit::all()->random()->id, 'user_id' => App\User::all()->random()->id];
});
$factory->define(App\CourseUser::class, function ($faker) {
    return ['course_id' => App\Course::all()->random()->id, 'user_id' => App\User::all()->random()->id];
});