teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

情報の追加のため

2020/08/01 01:36

投稿

kuwabaraakinori
kuwabaraakinori

スコア10

title CHANGED
File without changes
body CHANGED
@@ -2,8 +2,11 @@
2
2
 
3
3
  laravel6.0で旅行投稿サイトを制作しています。
4
4
 
5
- 今発生している問題は下記のcontact.blade.phpからsend.blade.phpにpost送信してもpostで送信されないことです。
5
+ 今発生している問題は下記のconfirm.blade.phpからsend.blade.phpにpost送信してもpostで送信されないことです。
6
6
 
7
+ dd($request->('name'));などで確認してみましたが、nullでそのためvalidationのredirectでget methodを取っているのでこのエラーが発生していると仮定しました。
8
+ 下記に試したことを載せてあります。
9
+
7
10
  ご教授いただけますと幸いです。
8
11
 
9
12
 
@@ -55,34 +58,26 @@
55
58
  @endsection
56
59
  ```
57
60
  ```ContactController
58
- public function send(ContentRequest $request)
61
+ public function send(ContactRequest $request)
59
62
  {
60
- /*
63
+
61
- $request->validate([
62
- 'content' => 'required|string',
63
- 'email' => 'required|string',
64
- 'name'=> 'required|string'
65
- ]);
66
- */
67
- if($request->validated()){
64
+ if($request->validated()){
65
+
66
+ $to= 'kaai06221733@gmail.com';
67
+
68
+ Mail::to($to)->send(new Contactsendmail ([
69
+ 'name'=>$request->name,
70
+ 'from_email' => $request->email,
71
+ 'data' => $request->content,
72
+ ], 'mail.blade.php'));
73
+
68
74
 
69
- \Mail::send(new ContactSendmail([
70
- 'to_name' => $request->name,
75
+ $request->session()->regenerateToken();
71
- 'name'=> 'Tufs-Tours',
76
+
72
- 'from_email' => 'kaai06221733@gmail.com',
73
- 'to' => $request->email,
74
- 'data' => $request->content,
75
- 'subject' => '自動送信メール'
76
- ], 'mail.blade.php'));
77
+ return view('contact.send');
77
-
78
+ }
79
+
78
80
 
79
- $request->session()->regenerateToken();
80
-
81
- return view('contact.send');
82
-
83
- }
84
-
85
-
86
81
  }
87
82
  ```
88
83
 
@@ -114,11 +109,7 @@
114
109
 
115
110
  }
116
111
 
117
- /**
112
+
118
- * Build the message.
119
- *
120
- * @return $this
121
- */
122
113
  public function build()
123
114
  {
124
115
  return $this->from($this->data['from_email'], $this->data['name'])
@@ -127,50 +118,16 @@
127
118
  ->view('contact.mail' . $this->view)
128
119
  ->with(['data'=> $this->data]);
129
120
  }
130
- }
131
121
  ```
132
122
 
133
- ```ContentRequest
134
- public function authorize()
135
- {
136
- return true;
137
-
138
- }
139
-
140
- /**
141
- *
142
- * Get the validation rules that apply to the request.
143
- *
144
- * @return array
145
- */
146
- public function rules()
147
- {
148
- return [
149
- 'user_id'=>'required',
150
- 'title' => 'required|string|max:255',
151
- 'name' => 'required|string',
152
- 'email' => 'required|string',
153
- 'continent' => 'required|string',
154
- 'picture'=> 'mimes:jpeg,jpg,png,gif|required|max:1000',
155
- 'country' => 'required|string',
156
- 'costs'=>'required|numeric',
157
- 'span'=>'required|numeric',
158
- 'content'=>'required|string|max:250',
159
- ];
160
-
161
-
162
-
163
- }
164
- ```
165
-
166
123
  ### 試したこと
167
124
  下記が試したことです。
168
125
 
169
126
  ・route::match(['get' 'post'] ,~)を使用したが同じエラー
170
127
  ・enctype="multipart/form-data"の挿入
171
- ・sendメソッドでContentRequestを使用する
128
+ ・sendメソッドでContactRequestを使用する
172
129
  ・routeのキャッシュをクリアにする
173
- ・自作のRequest(ContentRequest)のauthorizeをtrueにする
130
+ ・自作のRequest(ContactRequest)のauthorizeをtrueにする
174
131
 
175
132
 
176
133
  ### 補足情報(FW/ツールのバージョンなど)