sendResponse($jobs, 'Jobs retrieved successfully.'); } public function show($job) : JsonResponse { $job = Job::find($job); if (is_null($job)) { return $this->sendError('Job not found.'); } return $this->sendResponse($job, 'Job retrieved successfully.'); } public function store(StoreJobRequest $request) : JsonResponse { // Validate the request... $validated = $request->validated(); // Store the Job... if ($validated) { try { $data = Job::create($validated); return $this->sendResponse($data, 'Job created successfully.'); } catch (Exception $e) { return $this->sendError($e->getMessage(), $e->getCode()); } } return $this->sendError('Job created failed.', 400); } public function update(UpdateJobRequest $request, Job $job) : JsonResponse { // Validate the request... $validated = $request->validated(); // Store the Job... if ($validated) { try { $data = $job->update($validated); return $this->sendResponse($data, 'Job updated successfully.'); } catch (Exception $e) { return $this->sendError($e->getMessage(), $e->getCode()); } } return $this->sendError('Job created failed.', 400); } public function destroy($id) : JsonResponse { $job = Job::find($id); if (is_null($job)) { return $this->sendError('Job not found.'); } try { $job->delete(); return $this->sendResponse($job, 'Job deleted successfully.'); } catch (Exception $e) { return $this->sendError($e->getMessage(), $e->getCode()); } } }