示例#1
0
文件: factory.php 项目: ajb/rfpez
 public static function question()
 {
     $faker = Faker\Factory::create();
     $p = Project::order_by(\DB::raw('RAND()'))->first();
     $v = Vendor::order_by(\DB::raw('RAND()'))->first();
     $q = new Question(array('project_id' => $p->id, 'question' => $faker->paragraph(3)));
     // Answer 1/2 of the questions
     if (rand(0, 1) === 0) {
         $q->answer = rand(0, 1) === 0 ? $faker->sentence : $faker->paragraph;
         $q->answered_by = $p->owner()->id;
     }
     $q->vendor_id = $v->id;
     $q->save();
 }