示例#1
0
 /**
  * [editedAction description]
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function editedAction($id)
 {
     //return 'test-->'.$id;
     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('obligationname' => array('min:3', 'required'));
     // Build the custom messages array.
     $messages = array('obligationname.required' => 'กรุณาระบุชื่อข้อผูกพัน', 'obligationname.min' => 'กรุณาระบุชื่อข้อผูกพันอย่างน้อย :min ตััวอักษร');
     // Create a new validator instance.
     $validator = Validator::make($data, $rules, $messages);
     $obl_name = trim($data['obligationname']);
     if ($validator->passes()) {
         $obligation = new Obligation();
         $rs_ckeck = $obligation->checkObligation($obl_name);
         if ($rs_ckeck) {
             // Normally we would do something with the data.
             $obligation = Obligation::find($id);
             $obligation->obl_name = $data['obligationname'];
             $obligation->save();
             return Redirect::to('obligation')->with('success', 'ข้อผูกพันรหัส = ' . $id . ' แก้ไขสำเร็จ');
         } else {
             return Redirect::to('obligation-edit/' . $id)->with('warning', 'มีชื่อข้อผูกพันนี้ในระบบแล้ว');
         }
     } else {
         //$errors = $validator->messages();
         return Redirect::to('obligation-edit/' . $id)->withErrors($validator);
     }
 }