質問編集履歴

2

修正後のrequestの内容の説明を追加しました

2022/04/11 12:01

投稿

ttpk
ttpk

スコア338

test CHANGED
File without changes
test CHANGED
@@ -104,3 +104,4 @@
104
104
  何か記述や設定が足りていないのでしょうか?
105
105
 
106
106
  ※2件の回答をいただいたのでそれに基づいてhome.blade.phpを修正しました
107
+ requestの内容は修正後も変わっていません

1

home.blade.phpのnameで配列を使うように修正しました

2022/04/11 12:00

投稿

ttpk
ttpk

スコア338

test CHANGED
File without changes
test CHANGED
@@ -8,34 +8,48 @@
8
8
  検索条件にはチェックボックスでないものもあり、入力があったもののみ
9
9
  検索条件として使用する想定です
10
10
  ```html
11
- <form action="{{url('/search')}}" method="post">
11
+ <form method="post" action="{{url('/search')}}">
12
12
  @csrf
13
13
  {{method_field('get')}}
14
14
  <div class="form-group">
15
15
  <label>目的で検索</label>
16
16
  <div class="custom-control custom-checkbox">
17
+ <label>
17
- <input type="checkbox" class="custom-control-input" name="party" value="party">宴会
18
+ <input type="checkbox" class="custom-control-input" name="use[]" value="party">宴会
19
+ </label>
18
20
  </div>
19
21
  <div class="custom-control custom-checkbox">
22
+ <label>
20
- <input type="checkbox" class="custom-control-input" name="small" value="small">少人数
23
+ <input type="checkbox" class="custom-control-input" name="use[]" value="small">少人数
24
+ </label>
21
25
  </div>
22
26
  <div class="custom-control custom-checkbox">
27
+ <label>
23
- <input type="checkbox" class="custom-control-input" name="girls" value="girls">女子会
28
+ <input type="checkbox" class="custom-control-input" name="use[]" value="girls">女子会
29
+ </label>
24
30
  </div>
25
31
  </div>
26
32
  <div class="form-group">
27
33
  <label>食べたいもので検索</label>
28
34
  <div class="custom-control custom-checkbox">
35
+ <label>
29
- <input type="checkbox" class="custom-control-input" name="seafood" value="1">海鮮
36
+ <input type="checkbox" class="custom-control-input" name="food[]" value="seafood">海鮮
37
+ </label>
30
38
  </div>
31
39
  <div class="custom-control custom-checkbox">
40
+ <label>
32
- <input type="checkbox" class="custom-control-input" name="brandcow" value="1">銘柄牛
41
+ <input type="checkbox" class="custom-control-input" name="food[]" value="brandcow">銘柄牛
42
+ </label>
33
43
  </div>
34
44
  <div class="custom-control custom-checkbox">
45
+ <label>
35
- <input type="checkbox" class="custom-control-input" name="localsake" value="1">地酒
46
+ <input type="checkbox" class="custom-control-input" name="food[]" value="localsake">地酒
47
+ </label>
36
48
  </div>
37
49
  <div class="custom-control custom-checkbox">
50
+ <label>
38
- <input type="checkbox" class="custom-control-input" name="craftbeer" value="1">クラフトビール
51
+ <input type="checkbox" class="custom-control-input" name="food[]" value="craftbeer">クラフトビール
52
+ </label>
39
53
  </div>
40
54
  </div>
41
55
 
@@ -44,6 +58,7 @@
44
58
  </div>
45
59
 
46
60
  </form>
61
+
47
62
  ```
48
63
 
49
64
  Controllerの検索メソッド
@@ -87,3 +102,5 @@
87
102
  ```
88
103
 
89
104
  何か記述や設定が足りていないのでしょうか?
105
+
106
+ ※2件の回答をいただいたのでそれに基づいてhome.blade.phpを修正しました