AdminDeviceProfileMaster = $AdminDeviceProfileMaster; } public function deviceprofileMasterList() { try { $deviceMaster = DeviceProfileMaster::select('id', 'name')->get(); return jsonResponseWithSuccessMessage('Device profile master fetched successfully', [ 'deviceprofilemaster' => $deviceMaster ]); } catch (Exception $e) { Log::error("An error occurred: " . $e->getMessage()); return jsonResponseWithErrorMessage($e->getMessage(), 500); } } public function updateDevice(Request $request, $deviceId) { try { $deviceProfileMaster = DeviceProfileMaster::find($deviceId); if (!$deviceProfileMaster) { return jsonResponseWithErrorMessage('No device found', 404); } $request->validate([ 'name' => 'required|string|max:255' ]); $deviceProfileMaster->name = $request->name; $deviceProfileMaster->save(); $updatedDevice = $deviceProfileMaster->only(['id', 'name']); return jsonResponseWithSuccessMessage('Device name updated successfully', [ 'device' => $updatedDevice ]); } catch (Exception $e) { return jsonResponseWithErrorMessage('Failed to update device: ' . $e->getMessage(), 500); } } }