create() публичный Метод

위젯박스를 생성한다.
public create ( array $data ) : void
$data array 생성할 위젯박스의 데이터
Результат void
 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'));
 }
 public function store(Request $request, WidgetBoxHandler $handler, SessionManager $session)
 {
     if (!$request->user()->isAdmin()) {
         throw new AccessDeniedHttpException();
     }
     $this->validate($request, ['id' => 'required', 'title' => 'required']);
     $inputs = $request->only(['id', 'title']);
     $widgetbox = $handler->find($inputs['id']);
     if ($widgetbox) {
         throw new IDAlreadyExistsException();
     }
     $widgetbox = $handler->create($inputs);
     $session->flash('alert', ['type' => 'success', 'message' => '위젯박스가 생성되었습니다.']);
     return XePresenter::makeApi(['type' => 'success', 'message' => '생성했습니다.']);
 }