当前位置: 首页>>代码示例>>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;未经允许,请勿转载。