public function createContract($loan_id)
 {
     // Find the profile of the person who's id matches the id of the person currently logged in.  Find it in DB.
     $profile = UserProfile::where('id', '=', Auth::user()->id)->first();
     try {
         $loan = LoanApp::findOrFail($loan_id);
     } catch (Exception $e) {
         return Redirect::route('mytransaction')->with('message', "Could not load loan: " . $e->getMessage());
     }
     $lenders = $this->getLenders($loan_id);
     if (empty($lenders)) {
         return Redirect::route('mytransaction')->with('message', 'Could not find lenders for this loan request');
     }
     $contract = Contract::firstOrCreate(array('offer_id' => Input::get('offer_id', $loan_id)));
     if ($contract->getAttribute('status') === 'complete') {
         return Redirect::to('previewContract/' . $loan_id);
     }
     // todo: set these using the form
     $contract->setAttribute('start_date', date('d/m/Y'));
     $contract->setAttribute('end_date', date('d/m/Y'));
     if (Request::isMethod('post')) {
         // Check if actually posting data.
         $save = $contract->fill(Input::all())->save();
         $errors = Session::pull('messages', array());
         if ($save === false && empty($errors)) {
             $errors[] = 'Failed to save contract';
         }
         if (empty($errors)) {
             return Redirect::to('previewContract/' . $loan_id);
         }
     }
     $prepayment_rules = array("There are no penalties for paying off the loan early.", "Borrower must pay 5% of the original loan amount.", "Borrower must pay the complete interest of the loan.", "Borrower must pay \$100");
     return View::make('createContract', compact('loan', 'lenders', 'profile', 'errors', 'contract', 'prepayment_rules'));
 }