Пример #1
0
 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();
 }
Пример #2
0
 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();
 }