diff --git a/routes/api.php b/routes/api.php index c7a5d5a..59f0837 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,14 +1,15 @@ PreventRegularBrowserAccess::class], function () { Route::post('_native/api/booted', NativeAppBootedController::class); Route::post('_native/api/events', DispatchEventFromAppController::class); -})->withoutMiddleware(\App\Http\Middleware\VerifyCsrfToken::class); +})->withoutMiddleware(VerifyCsrfToken::class); Route::get('_native/api/cookie', CreateSecurityCookieController::class); diff --git a/src/Dialog.php b/src/Dialog.php index 0913a69..fb7f89c 100644 --- a/src/Dialog.php +++ b/src/Dialog.php @@ -121,18 +121,23 @@ public function asSheet(string $windowId = null): self return $this; } - public function open() + public function dataArray(): array { - $result = $this->client->post('dialog/open', [ + return [ 'title' => $this->title, 'windowReference' => $this->windowReference, 'defaultPath' => $this->defaultPath, 'filters' => $this->filters, 'buttonLabel' => $this->buttonLabel, 'properties' => array_unique($this->properties), - ])->json('result'); + ]; + } + + public function open() + { + $result = $this->client->post('dialog/open', $this->dataArray())->json('result'); - if (! in_array('multiSelections', $this->properties)) { + if (!in_array('multiSelections', $this->properties)) { return $result[0] ?? null; } @@ -141,13 +146,6 @@ public function open() public function save() { - return $this->client->post('dialog/save', [ - 'title' => $this->title, - 'windowReference' => $this->windowReference, - 'defaultPath' => $this->defaultPath, - 'filters' => $this->filters, - 'buttonLabel' => $this->buttonLabel, - 'properties' => array_unique($this->properties), - ])->json('result'); + return $this->client->post('dialog/save', $this->dataArray())->json('result'); } }