public static function bid($attributes = array(), $project_id = false) { $faker = Faker\Factory::create(); $p = $project_id ? Project::find($project_id) : Project::where_not_null('posted_to_fbo_at')->order_by(\DB::raw('RAND()'))->first(); $v = Vendor::order_by(\DB::raw('RAND()'))->first(); $prices = array(); foreach (array_keys($p->deliverables) as $d) { $prices[$d] = rand(100, 10000); } $b = new Bid(array('project_id' => $p->id, 'approach' => $faker->paragraph, 'previous_work' => $faker->paragraph, 'employee_details' => "Adam Becker\n" . "Craig Collyer", 'prices' => $prices)); $b->starred = rand(0, 1); $b->vendor_id = $v->id; $b->save(); if (rand(0, 6) === 0) { $b->delete_by_vendor(); } else { if (rand(0, 1) === 0) { $submitted_at = new \DateTime(); $b->submitted_at = rand(0, 1) === 0 ? $submitted_at : null; $b->submit(); // Dismiss 1/3 of the bids if (rand(0, 2) === 0) { $b->dismiss(Bid::$dismissal_reasons[array_rand(Bid::$default_dismissal_reasons)], $faker->paragraph(2)); // Un-dismiss 1/2 of these if (rand(0, 1) === 0) { $b->undismiss(); } } } } }