public function destroy_conditions($id) { // Check if user has access to loan if (!$this->is_staff()) { Session::flash('alert_danger', 'Access denied.'); return Redirect::to('dashboard'); } else { try { // Organize data $loan = $this->loan->getById($id); $condition = Condition::find(Input::get('condition_id')); $condition->active = 0; $condition->save(); // Save Transaction $transaction = new Transaction(); $transaction->loan_id = $loan['id']; $transaction->user_id = $this->user->id; $transaction->transaction_type_id = "10"; $transaction->updated_item_id = $condition->id; $transaction->transaction_description = "Condition Deleted: " . $condition->description; $transaction->save(); // On success, redirect to show Loan Session::flash('alert_success', 'Deleted condition successfully.'); return Redirect::to('loan/' . $loan['id']); } catch (\RuntimeException $e) { Session::flash('alert_danger', 'Failed to delete condition.'); return Redirect::back()->withInput(); } } }
/** * [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('conditionname' => array('min:3', 'required'), 'condition_action' => array('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 = Condition::find($id); $condition->cond_name = $data['conditionname']; $condition->condition = $data['condition_action']; $condition->save(); return Redirect::to('condition')->with('success', 'ชื่อเงื่อนไขรหัส = ' . $id . ' แก้ไขสำเร็จ'); } else { return Redirect::to('condition-edit/' . $id)->with('warning', 'มีชื่อเงื่อนไขอยู่ในระบบแล้ว'); } } else { //$errors = $validator->messages(); return Redirect::to('condition-edit/' . $id)->withErrors($validator); } }
public function updateTerm($id) { if ($term = Condition::find($id)) { return View::make('admin.viewTerm')->withTerm(Condition::find($id)); } return Redirect::back()->withErrors('Could not find reservation'); }