質問編集履歴
2
回答を基に試した結果を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -269,3 +269,87 @@
|
|
269
269
|
|
270
270
|
|
271
271
|
初歩的な質問なのかもしれませんが、有識者の方、何卒お力添えをよろしくお願いいたします。
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
### 補足情報
|
276
|
+
|
277
|
+
下記のバリデーションを設定した場合、エラーが発生しました。
|
278
|
+
|
279
|
+
```php
|
280
|
+
|
281
|
+
<?php
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
namespace App\Http\Requests;
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
use Illuminate\Foundation\Http\FormRequest;
|
290
|
+
|
291
|
+
use Illuminate\Validation\Rule;
|
292
|
+
|
293
|
+
use App\Http\Requests\TaskRequest;
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
class TaskRequest extends FormRequest
|
298
|
+
|
299
|
+
{
|
300
|
+
|
301
|
+
/**
|
302
|
+
|
303
|
+
* Determine if the user is authorized to make this request.
|
304
|
+
|
305
|
+
*
|
306
|
+
|
307
|
+
* @return bool
|
308
|
+
|
309
|
+
*/
|
310
|
+
|
311
|
+
public function authorize()
|
312
|
+
|
313
|
+
{
|
314
|
+
|
315
|
+
return true;
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
public function rules()
|
322
|
+
|
323
|
+
{
|
324
|
+
|
325
|
+
return [
|
326
|
+
|
327
|
+
Validator::make($data, [
|
328
|
+
|
329
|
+
'task_name' =>[
|
330
|
+
|
331
|
+
Rule::unique('tasks')->where(function ($query){
|
332
|
+
|
333
|
+
return $query->where('task_list_id', $data['task_list_id']);
|
334
|
+
|
335
|
+
})
|
336
|
+
|
337
|
+
],
|
338
|
+
|
339
|
+
]->validate();
|
340
|
+
|
341
|
+
];
|
342
|
+
|
343
|
+
}
|
344
|
+
|
345
|
+
```
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
```
|
350
|
+
|
351
|
+
ReflectionException
|
352
|
+
|
353
|
+
Class App\Http\Requests\TaskRequest does not exist
|
354
|
+
|
355
|
+
```
|
1
Viewのコードを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -128,6 +128,32 @@
|
|
128
128
|
|
129
129
|
|
130
130
|
|
131
|
+
viewのタスク追加フォーム
|
132
|
+
|
133
|
+
```php
|
134
|
+
|
135
|
+
<form method="post" action="{{ action('TaskController@store', $list) }}" >
|
136
|
+
|
137
|
+
{{ csrf_field() }}
|
138
|
+
|
139
|
+
<div class="form-group">
|
140
|
+
|
141
|
+
<label for="nameInput">タスク名</label>
|
142
|
+
|
143
|
+
<input type="text" class="form-control" id="nameInput" name="task_name">
|
144
|
+
|
145
|
+
<input type="date" class="form-control" id="limitInput" name="limit">
|
146
|
+
|
147
|
+
</div>
|
148
|
+
|
149
|
+
<button type="submit" class="btn btn-primary">新規追加</button>
|
150
|
+
|
151
|
+
</form>
|
152
|
+
|
153
|
+
```
|
154
|
+
|
155
|
+
|
156
|
+
|
131
157
|
**実現したいこと**
|
132
158
|
|
133
159
|
|