. * * @package LibreNMS * @link http://librenms.org * @copyright 2018 Tony Murray * @author Tony Murray */ namespace App\Http\Controllers\Form; use App\Http\Controllers\Controller; use App\Models\UserWidget; use Illuminate\Http\Request; class WidgetSettingsController extends Controller { public function update(Request $request, $widget_settings) { $this->validate($request, ['settings' => 'array']); $widget = UserWidget::with('dashboard')->findOrFail($widget_settings); $widget_settings = (array)$request->get('settings', []); if (!$widget->dashboard->canWrite($request->user())) { return response()->json([ 'status' => 'error', 'message' => 'ERROR: You have no write-access to this dashboard' ]); } $widget->settings = $widget_settings; if ($widget->save()) { return response()->json([ 'status' => 'ok', 'message' => 'Updated widget settings' ]); } return response()->json([ 'status' => 'error', 'message' => 'ERROR: Could not update' ]); } }