public function updateInfo(Request $request) { $v = Validator::make($request->all(), ['password' => 'min:6|confirmed']); if ($v->fails()) { $response = new ResponseEntity(); $response->setMessages((array) $v->errors()->getMessages()); return $response->toArray(); } else { return $this->profileService->save(Input::all())->toArray(); } }
public function store(Request $request) { $messages = ['product_id.required' => 'Select product', 'customer.first_name.max' => 'The customer first name may not be greater than :max characters.', 'customer.last_name.max' => 'The customer last name may not be greater than :max characters.', 'customer.phone_number.max' => 'The customer phone number may not be greater than :max characters.', 'customer.first_name.required' => 'The customer first name is required.', 'customer.last_name.required' => 'The customer last name is required.', 'customer.phone_number.required' => 'The customer phone number is required.']; $v = Validator::make($request->all(), ['product_id' => 'required|min:1', 'date_sold' => 'required', 'order_number' => 'required|unique:sales,order_number|max:30', 'customer.first_name' => 'required|max:255', 'customer.last_name' => 'required|max:255', 'customer.phone_number' => 'required|max:15'], $messages); if ($v->fails()) { $response = new ResponseEntity(); $response->setSuccess(false); $response->setMessages((array) $v->errors()->getMessages()); return $response->toArray(); } else { return $this->saleService->save($request->all())->toArray(); } }
function process() { $params = Input::get(); $response = new ResponseEntity(); try { if ($params) { $leave = LeaveApplication::where('id', $params['id'])->where('status', 'Pending')->first(); if ($leave) { $leave->status = $params['status']; $leave->save(); $response->setSuccess(true); $response->setMessage('Leave application successfully processed!'); } else { $response->setMessage('Leave application is not available'); } } else { $response->setMessage('Invalid parameters'); } } catch (\Exception $ex) { $response->setMessages(['Exception: ' . $ex->getMessage()]); } return $response->toArray(); }
function cancel($id) { $response = new ResponseEntity(); try { $leave = LeaveApplication::where('id', $id)->where('employee_id', $this->employeeId)->where('status', 'Pending')->first(); if ($leave) { $leave->status = 'Cancelled'; $leave->save(); $response->setSuccess(true); $response->setMessage('Leave application successfully cancelled!'); } else { $response->setMessage('Leave application is not available'); } } catch (\Exception $ex) { $response->setMessages(['Exception: ' . $ex->getMessage()]); } return $response->toArray(); }