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


PHP Condition::save方法代码示例

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


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

示例1: saveAction

 /**
  * [saveAction description]
  * @return [type] [description]
  */
 public function saveAction()
 {
     Input::flash();
     $data = Input::all();
     // 'min:3' ensures that the value is greater than or equal to the parameter provided
     // 'max:32' ensure that the value is less than or equql to the parameter provided
     $rules = array('condition_action' => array('required'), 'conditionname' => array('min:3', 'required'));
     // Build the custom messages array.
     $messages = array('conditionname.required' => 'กรุณาระบุชื่อเงื่อนไข', 'condition_action.required' => 'กรุณาระบุชื่อเงื่อนไขค้นหา', 'conditionname.min' => 'กรุณาระบุชื่อเงื่อนไขอย่างน้อย :min ตัวอักษร.');
     // Create a new validator instance.
     $validator = Validator::make($data, $rules, $messages);
     $cond_name = trim($data['conditionname']);
     $cond_action = trim($data['condition_action']);
     if ($validator->passes()) {
         // Normally we would do something with the data.
         $condition = new Condition();
         $rs_check = $condition->checkCondition($cond_name);
         if ($rs_check) {
             $condition->cond_name = $cond_name;
             $condition->condition = $cond_action;
             $condition->save();
             return Redirect::to('condition')->with('success', 'บันทึกสำเร็จ');
         } else {
             return Redirect::to('condition-add')->with('warning', 'มีชื่อเงื่อนไขอยู่ในระบบแล้ว');
         }
     } else {
         //$errors = $validator->messages();
         return Redirect::to('condition-add')->withErrors($validator);
     }
 }
开发者ID:nattaphat,项目名称:cuse2,代码行数:34,代码来源:ConditionController.php

示例2: processImportConditions

 public function processImportConditions($conditions, $id_lang)
 {
     $current_conditions = array();
     $result = Db::getInstance()->ExecuteS('SELECT `id_ps_condition` FROM ' . _DB_PREFIX_ . 'condition');
     foreach ($result as $row) {
         $current_conditions[] = (int) $row['id_ps_condition'];
     }
     foreach ($conditions as $condition) {
         if (isset($condition->id)) {
             unset($condition->id);
         }
         try {
             $cond = new Condition();
             if (in_array($condition->id_ps_condition, $current_conditions)) {
                 $cond = new Condition(Condition::getIdByIdPs($condition->id_ps_condition));
                 unset($current_conditions[(int) array_search($condition->id_ps_condition, $current_conditions)]);
             }
             $cond->hydrate((array) $condition, (int) $id_lang);
             $cond->date_upd = date('Y-m-d H:i:s', strtotime('-' . (int) $cond->calculation_detail . 'DAY'));
             $cond->date_add = date('Y-m-d H:i:s');
             $condition->calculation_detail = trim($condition->calculation_detail);
             $cond->save(false, false);
             if ($condition->calculation_type == 'hook' && !$this->isRegisteredInHook($condition->calculation_detail) && Validate::isHookName($condition->calculation_detail)) {
                 $this->registerHook($condition->calculation_detail);
             }
             unset($cond);
         } catch (Exception $e) {
             continue;
         }
     }
     // Delete conditions that are not in the file anymore
     foreach ($current_conditions as $id_ps_condition) {
         $cond = new Condition(Condition::getIdByIdPs((int) $id_ps_condition));
         $cond->delete();
     }
 }
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:36,代码来源:gamification.php

示例3: store_condition

 public function store_condition($id)
 {
     // Check if user has access to loan
     if (!$this->is_staff()) {
         Session::flash('alert_danger', 'Access denied.');
         return Redirect::to('dashboard');
     } else {
         // Check for Borrower Name and 1 file
         $validator = Validator::make(Input::all(), array('condition_type' => 'required', 'description' => 'required'));
         if ($validator->fails()) {
             return Redirect::back()->withInput()->withErrors($validator);
         }
         try {
             // Organize data and attempt save
             $loan = $this->loan->getById($id);
             $condition = new Condition();
             $condition->loan_id = $loan['id'];
             $condition->condition_type_id = Input::get('condition_type');
             $condition->description = Input::get('description');
             $condition->condition_status_id = '1';
             $condition->active = '1';
             $condition->save();
             // Save Transaction
             $transaction = new Transaction();
             $transaction->loan_id = $loan['id'];
             $transaction->user_id = $this->user->id;
             $transaction->transaction_type_id = "8";
             $transaction->updated_item_id = $condition->id;
             $transaction->transaction_description = "Condition Created: " . $condition->description;
             $transaction->save();
             // On success, redirect to show Loan
             Session::flash('alert_success', 'Created condition successfully.');
             return Redirect::to('loan/' . $loan['id']);
         } catch (\RuntimeException $e) {
             Session::flash('alert_danger', 'Failed to create condition.');
             return Redirect::back()->withInput();
         }
     }
 }
开发者ID:julianfresco,项目名称:documentHub,代码行数:39,代码来源:LoanController.php

示例4: addTerm2

 public function addTerm2()
 {
     $con = Condition::where('number', '=', Input::get('number'))->first();
     if ($con) {
         if ($con->id != Input::get('id')) {
             return Redirect::to('admin/addTerm')->withInput()->withErrors(['warning' => 'Number exist in Terms and Conditions, please update or delete the other to proceed.']);
         }
     }
     $con = new Condition();
     $con->number = Input::get('number');
     $con->title = Input::get('title');
     $con->description = Input::get('desc');
     $con->save();
     return Redirect::action('AdminController@termsncon');
 }
开发者ID:jmramos02,项目名称:catering,代码行数:15,代码来源:AdminController.php


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