public function makeBid($loan_id) { $id = Auth::user()->id; $loan_app = LoanApp::where('loan_id', '=', $loan_id)->first(); $bid_Id; if (!Bid::isMadeBefore($loan_id, $id)) { $bid = new Bid(); $bid->user_id = $id; $bid->loan_id = $loan_id; $bid->bid_date = date('Y-m-d H:i:s'); $bid->bid_amount = $loan_app->amount; /*$bid-> bid_term = $loan_app-> term; $bid-> bid_rate = $loan_app-> pref_rate; */ $bid->save(); /*$bid_Id= $bid-> bid_id;*/ /*$bid_acc = BidAccept::firstOrNew('where','=',$bid_Id); $bid_acc -> loan_id = $loan_id; $bid_acc -> accepte = 0;*/ //update the loan weight $weight = $loan_app->evaluateWeight($id, $loan_id); $loan_app->save(); } /* $bid_acc = BidAccept::firstOrNew(array('bid_id'=>$bid_Id)); $bid_acc -> loan_id = $loan_id; $bid_acc -> accepted = 0; $bid_acc->save();*/ /*$pdata = $profile->getProfile($id); // method defined in its model $fdata = $financial->getFinancialProfile($id); */ // methd defined in its model return Redirect::route('lend'); }
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(); } } } } }