当前位置: 首页>>代码示例>>PHP>>正文


PHP Contract::firstOrCreate方法代码示例

本文整理汇总了PHP中Contract::firstOrCreate方法的典型用法代码示例。如果您正苦于以下问题:PHP Contract::firstOrCreate方法的具体用法?PHP Contract::firstOrCreate怎么用?PHP Contract::firstOrCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contract的用法示例。


在下文中一共展示了Contract::firstOrCreate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createContract

 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'));
 }
开发者ID:Clare-E-Rich,项目名称:DECO7381_MoneyLink_IndividualComponant,代码行数:34,代码来源:ContractController.php


注:本文中的Contract::firstOrCreate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。