public function saveFinancialProfile()
 {
     $id = Auth::user()->id;
     $profile = FinancialProfile::firstOrNew(array('user_id' => $id));
     $profile->residence_status = Input::get('residence');
     $profile->year_cur_addr = Input::get('year_cur_addr');
     $profile->year_cur_addr = Input::get('month_cur_addr');
     $profile->year_old_addr = Input::get('year_old_addr');
     $profile->year_old_addr = Input::get('year_old_addr');
     $profile->employ_status = Input::get('employment');
     $profile->employer = Input::get('employer');
     $profile->position = Input::get('position');
     $profile->year_cur_job = Input::get('year_cur_job');
     $profile->month_cur_job = Input::get('month_cur_job');
     $profile->year_old_job = Input::get('year_old_job');
     $profile->month_old_job = Input::get('month_old_job');
     $profile->monthly_income = Input::get('income');
     $profile->loan_repayments = Input::get('payment');
     $profile->other_expense = Input::get('expense');
     $profile->home_loan = Input::get('homeloan');
     $profile->car_loan = Input::get('carloan');
     $profile->other_loan = Input::get('otherloan');
     $profile->property = Input::get('property');
     $profile->vehicle = Input::get('vehicle');
     $profile->share = Input::get('share');
     $profile->others = Input::get('otherproperty');
     $profile->save();
     return Redirect::to("thankyou");
 }
 public function evaluateWeight($id, $loan_id)
 {
     $finance = FinancialProfile::where('user_id', '=', $id)->first();
     $count = LoanApp::where('user_id', '=', $id)->count();
     $loan_app = LoanApp::where('loan_id', '=', $loan_id)->first();
     $current_bids = Bid::where('loan_id', '=', $loan_id)->count();
     $amout = $loan_app->amount;
     $term = $loan_app->term;
     $rate = $loan_app->pref_rate;
     $residence = $finance->residence_status;
     $year_income = $finance->monthly_income * 12;
     $home_loan = $finance->home_loan;
     $car_loan = $finance->car_loan;
     $other_loan = $finance->other_loan;
     $expense = $finance->loan_repayment;
     $other_exp = $finance->other_expense;
     $house_owner = 0;
     if (strcmp($residence, 'Mortage') == 0 || strcmp($residence, 'noMortage') == 0) {
         $house_owner = 1;
     }
     $property = $finance->property;
     $vehicle = $finance->vehicle;
     $share = $finance->share;
     $other_property = $finance->others;
     $active_loan = $total_liab = $home_loan + $car_loan + $other_loan;
     $income_debt_ratio = $year_income / (1 + $count + $total_liab);
     $total_assests = $property + $vehicle + $share + $other_property;
     $disposable_income = $year_income - $total_liab;
     $sum = $rate + $house_owner + $total_assests + $income_debt_ratio + $current_bids + $disposable_income;
     $weight = pow($sum, 1 / 6);
     //$loan_app-> weight = $weight;
     return $weight;
 }
 public function applyLoans()
 {
     $id = Auth::user()->id;
     $loan_app = LoanApp::create(array('user_id' => $id));
     $profile = FinancialProfile::firstOrNew(array('user_id' => $id));
     $loan_app->amount = Input::get('amount');
     $loan_app->term = Input::get('term');
     $loan_app->pref_rate = Input::get('pref_rate');
     $loan_app->purpose = Input::get('purpose');
     $loan_app->description = Input::get('description');
     $profile->residence_status = Input::get('residence');
     $profile->marital_status = Input::get('marital');
     $profile->year_cur_addr = Input::get('year_cur_addr');
     $profile->month_cur_addr = Input::get('month_cur_addr');
     $profile->year_old_addr = Input::get('year_old_addr');
     $profile->month_old_addr = Input::get('month_old_addr');
     $profile->employ_status = Input::get('employment');
     $profile->employer = Input::get('employer');
     $profile->position = Input::get('position');
     $profile->year_cur_job = Input::get('year_cur_job');
     $profile->month_cur_job = Input::get('month_cur_job');
     $profile->year_old_job = Input::get('year_old_job');
     $profile->month_old_job = Input::get('month_old_job');
     $profile->monthly_income = Input::get('income');
     $profile->loan_repayments = Input::get('payment');
     $profile->other_expense = Input::get('expense');
     $profile->home_loan = Input::get('homeloan');
     $profile->car_loan = Input::get('carloan');
     $profile->other_loan = Input::get('otherloan');
     $profile->property = Input::get('property');
     $profile->vehicle = Input::get('vehicle');
     $profile->share = Input::get('share');
     $profile->others = Input::get('otherproperty');
     $profile->save();
     $loanId = $loan_app->loan_id;
     $weight = $loan_app->evaluateWeight($id, $loanId);
     $loan_app->weight = $weight;
     //$loan_app-> user_id=  $id;
     $loan_app->save();
     return Redirect::to('confirm');
     //return $weight;
 }
 public function saveLendPref()
 {
     $id = Auth::user()->id;
     $loanApp = LoanApp::where('user_id', '=', $id)->get();
     $profile = UserProfile::where('id', '=', $id)->first();
     $financial = FinancialProfile::where('user_id', $id)->first();
     $lender_prefers = LenderPref::firstOrNew(array('user_id' => $id));
     $lender_prefers->min_amount = Input::get('minLoan');
     $lender_prefers->min_term = Input::get('minTerm');
     $lender_prefers->min_rate = Input::get('minRate');
     $lender_prefers->max_amount = Input::get('maxLoan');
     $lender_prefers->max_term = Input::get('maxTerm');
     $lender_prefers->max_rate = Input::get('maxRate');
     $lender_prefers->save();
     $results = $this->search();
     $pdata = $profile->getProfile($id);
     // method defined in its model
     $fdata = $financial->getFinancialProfile($id);
     // methd defined in its model
     $bids = DB::table('bids')->join('loan_app', 'bids.loan_id', '=', 'loan_app.loan_id')->join('profile', 'profile.id', '=', 'loan_app.user_id')->select('bid_amount', 'pref_rate', 'term', 'purpose', 'fname', 'lname')->orderBy('bid_date', 'DESC')->get();
     return View::make('myprofiles', compact('bids', 'pdata', 'fdata', 'results', 'loanApp'));
     /*	return Redirect::route('myprofile');   */
 }
 public function getFinancialProfile($user_id)
 {
     $Financial = FinancialProfile::where('user_id', $user_id)->first();
     $data = array('residence' => $Financial->residence_status, 'year_cur_addr' => $Financial->year_cur_addr, 'month_cur_addr' => $Financial->month_cur_addr, 'year_old_addr' => $Financial->year_old_addr, 'month_old_addr' => $Financial->month_old_addr, 'employ_status' => $Financial->employ_status, 'employer' => $Financial->employer, 'position' => $Financial->position, 'year_cur_job' => $Financial->year_cur_job, 'month_old_job' => $Financial->month_old_job, 'loan_repayments' => $Financial->loan_repayments, 'other_expense' => $Financial->other_expense, 'home_loan' => $Financial->home_loan, 'car_loan' => $Financial->car_loan, 'other_loan' => $Financial->other_loan, 'property' => $Financial->property, 'vehicle' => $Financial->vehicle, 'share' => $Financial->share, 'others' => $Financial->others, 'income' => $Financial->monthly_income);
     return $data;
 }
Exemplo n.º 6
0
 public function verify_email($code)
 {
     try {
         $user = User::where('activation_code', '=', $code)->first();
         if ($user == null) {
             echo "Invalide verfication code";
             return;
         } elseif ($user->activated == 1) {
             echo "You have already been verified";
             return;
         }
         $user->activated = 1;
         $user->save();
         $id = $user->id;
         Auth::login($user);
         //verify success and login user
         //create a profile record for this new user
         $profile = UserProfile::firstOrNew(array('id' => $id));
         $financial = FinancialProfile::firstOrNew(array('user_id' => $id));
         $profile->save();
         $financial->save();
         /*DB::table('users')
         			-> where('activation_code',$code)
         			-> update(array('activated'=>1));
         		}catch(Exception $e) {
         			echo $e -> getMessage();
         		}*/
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     return Redirect::route('myprofile');
 }
 public function logHwork()
 {
     $id = Auth::user()->id;
     $usermail = Auth::user()->email;
     // $photos = Auth::user()->photos()->get();
     $profile = UserProfile::where('id', '=', $id)->first();
     $financial = FinancialProfile::where('user_id', $id)->first();
     // think about cacahe below two queries
     $pdata = $profile->getProfile($id);
     //  method defiend in its model
     return View::make('logHworks', compact('id', 'bids', 'pdata', 'fdata', 'loanApp', 'allLoan', 'age', 'comments'));
 }