public function index(WidgetBoxHandler $handler) { $widgetboxPrefix = 'dashboard-'; $userId = auth()->id(); $id = $widgetboxPrefix . $userId; $widgetbox = $handler->find($id); if ($widgetbox === null) { $dashboard = $handler->find('dashboard'); $widgetbox = $handler->create(['id' => $id, 'title' => 'Dashboard', 'content' => $dashboard->content]); } \XeFrontend::title('XpressEngine3 Settings'); return \XePresenter::make('settings.dashboard', compact('widgetbox')); }
/** * 주어진 id의 widgetbox의 code(content)를 반환한다. * * @param Request $request * @param WidgetBoxHandler $handler * @param string $id * * @return \Xpressengine\Presenter\RendererInterface */ public function code(Request $request, WidgetBoxHandler $handler, $id) { if (\Gate::denies('edit', new Instance('widgetbox.' . $id))) { throw new AccessDeniedHttpException(); } /** @var WidgetBox $widgetbox */ $widgetbox = $handler->find($id); if ($widgetbox === null) { throw new NotFoundWidgetBoxException(); } return XePresenter::makeApi(['code' => $widgetbox->content]); }