質問編集履歴
2
Userモデルのコードを記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -216,6 +216,118 @@
|
|
216
216
|
|
217
217
|
```
|
218
218
|
|
219
|
+
app\User.php
|
220
|
+
|
221
|
+
```ここに言語を入力
|
222
|
+
|
223
|
+
<?php
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
namespace App;
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
232
|
+
|
233
|
+
use Illuminate\Foundation\Auth\User as Authenticatable;
|
234
|
+
|
235
|
+
use Illuminate\Notifications\Notifiable;
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
class User extends Authenticatable
|
240
|
+
|
241
|
+
{
|
242
|
+
|
243
|
+
use Notifiable;
|
244
|
+
|
245
|
+
/**
|
246
|
+
|
247
|
+
* The attributes that are mass assignable.
|
248
|
+
|
249
|
+
*
|
250
|
+
|
251
|
+
* @var array
|
252
|
+
|
253
|
+
*/
|
254
|
+
|
255
|
+
protected $fillable = [
|
256
|
+
|
257
|
+
'name', 'email', 'password',
|
258
|
+
|
259
|
+
];
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
/**
|
264
|
+
|
265
|
+
* The attributes that should be hidden for arrays.
|
266
|
+
|
267
|
+
*
|
268
|
+
|
269
|
+
* @var array
|
270
|
+
|
271
|
+
*/
|
272
|
+
|
273
|
+
protected $hidden = [
|
274
|
+
|
275
|
+
'password', 'remember_token',
|
276
|
+
|
277
|
+
];
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
/**
|
282
|
+
|
283
|
+
* The attributes that should be cast to native types.
|
284
|
+
|
285
|
+
*
|
286
|
+
|
287
|
+
* @var array
|
288
|
+
|
289
|
+
*/
|
290
|
+
|
291
|
+
protected $casts = [
|
292
|
+
|
293
|
+
'email_verified_at' => 'datetime',
|
294
|
+
|
295
|
+
];
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
public function responses(){
|
300
|
+
|
301
|
+
return $this->belongsToMany('App\Response', 'response_user', 'user_id', 'response_id');
|
302
|
+
|
303
|
+
}
|
304
|
+
|
305
|
+
public function questionnaireUsers(){
|
306
|
+
|
307
|
+
return $this->hasMany('App\QuestionnaireUser');
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
public function questionnaires(){
|
312
|
+
|
313
|
+
return $this->hasManyThrough('App\Questionnaire', 'App\QuestionnaireUser', 'user_id', 'id', 'id', 'questionnaire_id' );
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
public function answers(){
|
318
|
+
|
319
|
+
return $this->hasManyThrough('App\Answer', 'App\Response', 'answer_id', 'id', 'id', 'answer_id');
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
```
|
330
|
+
|
219
331
|
|
220
332
|
|
221
333
|
### 試したこと
|
1
Unicodeエスケープを無効化するためのmiddlewareのコードを記載しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,6 +56,10 @@
|
|
56
56
|
|
57
57
|
$this->middleware('auth');
|
58
58
|
|
59
|
+
$this->middleware('UnescapeJsonResponse');
|
60
|
+
|
61
|
+
|
62
|
+
|
59
63
|
}
|
60
64
|
|
61
65
|
|
@@ -142,6 +146,76 @@
|
|
142
146
|
|
143
147
|
```
|
144
148
|
|
149
|
+
Http\Middleware\UnescapeJsonResponse.php
|
150
|
+
|
151
|
+
```ここに言語を入力
|
152
|
+
|
153
|
+
<?php
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
namespace App\Http\Middleware;
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
use Closure;
|
162
|
+
|
163
|
+
use Symfony\Component\HttpFoundation\JsonResponse;
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
class UnescapeJsonResponse
|
168
|
+
|
169
|
+
{
|
170
|
+
|
171
|
+
/**
|
172
|
+
|
173
|
+
* Handle an incoming request.
|
174
|
+
|
175
|
+
*
|
176
|
+
|
177
|
+
* @param \Illuminate\Http\Request $request
|
178
|
+
|
179
|
+
* @param \Closure $next
|
180
|
+
|
181
|
+
* @return mixed
|
182
|
+
|
183
|
+
*/
|
184
|
+
|
185
|
+
public function handle($request, Closure $next)
|
186
|
+
|
187
|
+
{
|
188
|
+
|
189
|
+
$response = $next($request);
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
//JSONでない場合はそのまま
|
194
|
+
|
195
|
+
if (!$response instanceof JsonResponse) {
|
196
|
+
|
197
|
+
return $response;
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
// Unicodeエスケープさせないようにオプションを追加
|
204
|
+
|
205
|
+
$response->setEncodingOptions($response->getEncodingOptions() | JSON_UNESCAPED_UNICODE);
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
return $response;
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
```
|
218
|
+
|
145
219
|
|
146
220
|
|
147
221
|
### 試したこと
|
@@ -152,6 +226,14 @@
|
|
152
226
|
|
153
227
|
|
154
228
|
|
229
|
+
※追加
|
230
|
+
|
231
|
+
[Unicodeエスケープを無効化](https://nextat.co.jp/staff/archives/203)
|
232
|
+
|
233
|
+
こちらの記事を参考にUnicodeエスケープを無効化を試みたのですが、うまくいかない状況にあります。
|
234
|
+
|
235
|
+
|
236
|
+
|
155
237
|
### 補足情報(FW/ツールのバージョンなど)
|
156
238
|
|
157
239
|
|