當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Contract::firstOrNew方法代碼示例

本文整理匯總了PHP中Contract::firstOrNew方法的典型用法代碼示例。如果您正苦於以下問題:PHP Contract::firstOrNew方法的具體用法?PHP Contract::firstOrNew怎麽用?PHP Contract::firstOrNew使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Contract的用法示例。


在下文中一共展示了Contract::firstOrNew方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: previewContract

 public function previewContract($loan_id)
 {
     //  Is what I did last night?  I hope so, else I'm lost.
     $id = Auth::user()->id;
     $usermail = Auth::user()->email;
     $profile = UserProfile::where('id', '=', $id)->first();
     // Retreive from the DB details about loan, where loanid = input for function and user_id = id of person logged in.
     // This should return object.
     $loan = DB::table('loan_app')->select('amount', 'term', 'pref_rate', 'purpose', 'progress', 'loan_id', 'match_date')->where('user_id', '=', $id)->where('loan_id', '=', $loan_id)->orderBy('match_date', 'DESC')->first();
     // Run the getLenders function and store the returned value as $lenders.
     $lenders = $this->getLenders($loan_id);
     // If there is no value for lenders...
     if (empty($lenders)) {
         // fail and redirect somewhere else
         return Redirect::route('mytransaction')->with('message', 'Could not find lenders for this loan request');
     }
     $contract = Contract::firstOrNew(array('offer_id' => Input::get('offer_id', $loan_id)));
     if (!$contract->getAttribute('offer_id')) {
         return Redirect::to('mytransaction')->with('message', 'No dice!');
     }
     $success = null;
     $errors = array();
     if (Request::isMethod('post')) {
         // update contract record with new status
         if (Input::get('i_agree') !== null) {
             $contract->setAttribute('status', 'complete');
             if ($contract->save()) {
                 $success = 'Your contract was finalised';
             } else {
                 $errors[] = 'Your contract was not finalised';
             }
         }
     }
     $backurl = route('createContract', array($loan_id));
     return View::make('previewContract', compact('loan', 'profile', 'success', 'errors', 'contract', 'lenders', 'backurl'));
 }
開發者ID:Clare-E-Rich,項目名稱:DECO7381_MoneyLink_IndividualComponant,代碼行數:36,代碼來源:ContractController.php


注:本文中的Contract::firstOrNew方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。