質問編集履歴
1
本文の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -109,3 +109,161 @@
|
|
109
109
|
```
|
110
110
|
|
111
111
|
よろしくお願いいたします。
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
**質問を受けての追記**
|
118
|
+
|
119
|
+
---
|
120
|
+
|
121
|
+
mts10806さん、質問ありがとうございます。
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
**参考にしたurl**
|
126
|
+
|
127
|
+
https://blog.capilano-fw.com/?p=261(laravel,axios使用での一通りの流れを参考にした)
|
128
|
+
|
129
|
+
https://www.yoheim.net/blog.php?q=20170801(axiosの詳細はこちらで)
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
**試してみたこと**
|
134
|
+
|
135
|
+
上のサイトを参考にして、js側に引数に情報をいれた(こちらはこれで間違っていないと思われる)
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
methods:{
|
140
|
+
|
141
|
+
empty:function(rowIndex,colIndex){
|
142
|
+
|
143
|
+
this.rows[rowIndex].columns[colIndex].isActive = ! this.rows[rowIndex].columns[colIndex].isActive;
|
144
|
+
|
145
|
+
const data = { rowIndex : rowIndex, colIndex : colIndex };
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
//console.logで値が取れていることは確認済
|
150
|
+
|
151
|
+
console.log(data.colIndex);
|
152
|
+
|
153
|
+
console.log(data.rowIndex);
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
this.$http.post('/ajax/reservation_calender/from_teacher', data)
|
158
|
+
|
159
|
+
.then(function(response){
|
160
|
+
|
161
|
+
// 成功したとき
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
alert("成功!!!");//テストのため
|
166
|
+
|
167
|
+
}).catch(function(error){
|
168
|
+
|
169
|
+
// 失敗したとき
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
alert('送信が失敗しました。');//テストのため
|
174
|
+
|
175
|
+
});
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
```
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
server側にてとりあえず、引数関係なし+数値をそのまま入れてDBに挿入
|
186
|
+
|
187
|
+
→DBに値は入った
|
188
|
+
|
189
|
+
```
|
190
|
+
|
191
|
+
public function store()
|
192
|
+
|
193
|
+
{
|
194
|
+
|
195
|
+
$time_id = 1;
|
196
|
+
|
197
|
+
$date_id = 1;
|
198
|
+
|
199
|
+
$teacher_id = 1;
|
200
|
+
|
201
|
+
$user_id = 1;
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
$reservation_calender = new Reservation_calender();
|
206
|
+
|
207
|
+
$reservation_calender->time_id = $time_id;
|
208
|
+
|
209
|
+
$reservation_calender->teacher_id = $teacher_id;
|
210
|
+
|
211
|
+
$reservation_calender->user_id = $user_id;
|
212
|
+
|
213
|
+
$reservation_calender->save();
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
return response()->json([
|
218
|
+
|
219
|
+
'result' => true
|
220
|
+
|
221
|
+
]);
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
```
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
他のcontrollerの書き方を真似て引数を受け取り、DBに入れようとする
|
230
|
+
|
231
|
+
→ajax送信失敗
|
232
|
+
|
233
|
+
```
|
234
|
+
|
235
|
+
public function store(data $data)
|
236
|
+
|
237
|
+
{
|
238
|
+
|
239
|
+
$time_id = $data[rowIndex];
|
240
|
+
|
241
|
+
$date_id = $data[colIndex];
|
242
|
+
|
243
|
+
$teacher_id = 1;
|
244
|
+
|
245
|
+
$user_id = 1;
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
$reservation_calender = new Reservation_calender();
|
250
|
+
|
251
|
+
$reservation_calender->time_id = $time_id;
|
252
|
+
|
253
|
+
$reservation_calender->teacher_id = $teacher_id;
|
254
|
+
|
255
|
+
$reservation_calender->user_id = $user_id;
|
256
|
+
|
257
|
+
$reservation_calender->save();
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
return response()->json([
|
262
|
+
|
263
|
+
'result' => true
|
264
|
+
|
265
|
+
]);
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
```
|