8000 Merge pull request #110 from JaberWiki/main · mehulgarg201/laravel@bd03a50 · GitHub
[go: up one dir, main page]

Skip to content

Commit bd03a50

Browse files
authored
Merge pull request NativePHP#110 from JaberWiki/main
import VerifyCsrfToken and refactor
2 parents cee8899 + aff2080 commit bd03a50

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

routes/api.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?php
22

33
use Illuminate\Support\Facades\Route;
4-
use Native\Laravel\Http\Controllers\CreateSecurityCookieController;
5-
use Native\Laravel\Http\Controllers\DispatchEventFromAppController;
4+
use App\Http\Middleware\VerifyCsrfToken;
65
use Native\Laravel\Http\Controllers\NativeAppBootedController;
76
use Native\Laravel\Http\Middleware\PreventRegularBrowserAccess;
7+
use Native\Laravel\Http\Controllers\CreateSecurityCookieController;
8+
use Native\Laravel\Http\Controllers\DispatchEventFromAppController;
89

910
Route::group(['middleware' => PreventRegularBrowserAccess::class], function () {
1011
Route::post('_native/api/booted', NativeAppBootedController::class);
1112
Route::post('_native/api/events', DispatchEventFromAppController::class);
12-
})->withoutMiddleware(\App\Http\Middleware\VerifyCsrfToken::class);
13+
})->withoutMiddleware(VerifyCsrfToken::class);
1314

1415
Route::get('_native/api/cookie', CreateSecurityCookieController::class);

src/Dialog.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,23 @@ public function asSheet(string $windowId = null): self
121121
return $this;
122122
}
123123

124-
public function open()
124+
public function dataArray(): array
125125
{
126-
$result = $this->client->post('dialog/open', [
126+
return [
127127
'< 8000 span class=pl-s>title' => $this->title,
128128
'windowReference' => $this->windowReference,
129129
'defaultPath' => $this->defaultPath,
130130
'filters' => $this->filters,
131131
'buttonLabel' => $this->buttonLabel,
132132
'properties' => array_unique($this->properties),
133-
])->json('result');
133+
];
134+
}
135+
136+
public function open()
137+
{
138+
$result = $this->client->post('dialog/open', $this->dataArray())->json('result');
134139

135-
if (! in_array('multiSelections', $this->properties)) {
140+
if (!in_array('multiSelections', $this->properties)) {
136141
return $result[0] ?? null;
137142
}
138143

@@ -141,13 +146,6 @@ public function open()
141146

142147
public function save()
143148
{
144-
return $this->client->post('dialog/save', [
145-
'title' => $this->title,
146-
'windowReference' => $this->windowReference,
147-
'defaultPath' => $this->defaultPath,
148-
'filters' => $this->filters,
149-
'buttonLabel' => $this->buttonLabel,
150-
'properties' => array_unique($this->properties),
151-
])->json('result');
149+
return $this->client->post('dialog/save', $this->dataArray())->json('result');
152150
}
153151
}

0 commit comments

Comments
 (0)
0