public function getMRPendingServicesRequests() { $serviceRequests = ServiceRequest::pending()->get(); return count($serviceRequests); }
public function declinePendingServiceRequest($id) { $serviceRequest = ServiceRequest::findOrFail($id); $serviceRequest->approved = 0; try { $serviceRequest->save(); return redirect()->back()->with('message', 'Service Request has been declined successfully !'); } catch (ParseException $ex) { echo 'Failed to decline service request , with error message: ' . $ex->getMessage(); } }
public function doCreateServiceRequest(CreateServiceRequestRequest $request) { $serviceRequest = new ServiceRequest(); $serviceRequest->mr_id = \Auth::user()->id; $serviceRequest->month = $request->month . '-' . date('Y'); $serviceRequest->date = $request->date; $serviceRequest->request_text = $request->request_text; try { $serviceRequest->save(); return redirect()->back()->with('message', 'Service Request has been sent to your managers successfully !'); } catch (ParseException $ex) { echo 'Failed to create new service request , with error message: ' . $ex->getMessage(); } }