質問編集履歴

4

//ここにいれたいとbefore

2019/08/19 08:51

投稿

Junya42
Junya42

スコア5

test CHANGED
File without changes
test CHANGED
@@ -36,7 +36,7 @@
36
36
 
37
37
  ```laravel
38
38
 
39
- return redirect()->to('todofuken/tokyo');
39
+ return redirect()->to('tyuubou');
40
40
 
41
41
  ```
42
42
 
@@ -212,6 +212,8 @@
212
212
 
213
213
  //ここにいれたい 
214
214
 
215
+ return redirect()->to('tyuubou');と書いていました。
216
+
215
217
 
216
218
 
217
219
 

3

移動後と移動前のbladeを明記しました

2019/08/19 08:50

投稿

Junya42
Junya42

スコア5

test CHANGED
File without changes
test CHANGED
@@ -48,6 +48,8 @@
48
48
 
49
49
  なにが必要かよくわからなのでいろいろのせますね
50
50
 
51
+ 移動前blade
52
+
51
53
  ```laravel
52
54
 
53
55
  <?php
@@ -373,3 +375,153 @@
373
375
 
374
376
 
375
377
  ```
378
+
379
+ 移動先blade
380
+
381
+ ```laravel
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+ <html lang="ja" dir="ltr">
392
+
393
+ <head>
394
+
395
+ <meta charset="utf-8">
396
+
397
+ <meta name="viewport" content="width=device-width">
398
+
399
+ <link rel="stylesheet" href="css/style2.css">
400
+
401
+ <title></title>
402
+
403
+ </head>
404
+
405
+ <body>
406
+
407
+ <article class="">
408
+
409
+ <header>
410
+
411
+ <h1>オーダー</h1>
412
+
413
+ </header>
414
+
415
+
416
+
417
+
418
+
419
+ <?php session_start();
420
+
421
+
422
+
423
+ foreach ($_SESSION as $ordertable => $orders) :?>
424
+
425
+ <?php foreach ($orders as $menu => $num): ?>
426
+
427
+
428
+
429
+ <?php if(!0==($num)){
430
+
431
+ if ($menu !== 'table'&& $menu !=='hito'&& $menu !== '_token') { ?>
432
+
433
+   <section class="">
434
+
435
+
436
+
437
+
438
+
439
+ <div class="商品名">
440
+
441
+ <?php echo $menu; ?>
442
+
443
+ </div>
444
+
445
+
446
+
447
+ <form class="" action="{{route('uriage')}}" method="post">
448
+
449
+ {{csrf_field()}}
450
+
451
+ <a class="個数">個数
452
+
453
+ <select class="select" >
454
+
455
+ <option> <?php echo $num; ?></option>
456
+
457
+ </select>
458
+
459
+ </a>
460
+
461
+ <input type="hidden" name="num" value="<?php echo $num; ?>">
462
+
463
+ <input type="hidden" name="menu" value="<?php echo $menu; ?>">
464
+
465
+ <input type="hidden" name="table" value="<?php echo $orders["table"] ?>">
466
+
467
+ <input type="hidden" name="hito" value="<?php echo $orders["hito"] ?>">
468
+
469
+ <input type="submit" value="完了">
470
+
471
+ </form>
472
+
473
+
474
+
475
+
476
+
477
+ <a class="右">テーブル番号
478
+
479
+ <select class="select" >
480
+
481
+      <option><?php echo $orders["table"] ?></option>
482
+
483
+ </select>
484
+
485
+ </a>
486
+
487
+
488
+
489
+
490
+
491
+ <a class="人">人数
492
+
493
+ <select class="select" name="hito" >?>
494
+
495
+ <option><?php echo $orders["hito"] ?></option>
496
+
497
+ </select>
498
+
499
+ </a>
500
+
501
+
502
+
503
+
504
+
505
+ </section>
506
+
507
+ <?php } }?>
508
+
509
+ <?php endforeach;?>
510
+
511
+ <?php endforeach;?>
512
+
513
+
514
+
515
+ <br>
516
+
517
+ <br><br>
518
+
519
+
520
+
521
+ </body>
522
+
523
+ </html>
524
+
525
+
526
+
527
+ ```

2

3つ補足にたしました

2019/08/19 08:41

投稿

Junya42
Junya42

スコア5

test CHANGED
File without changes
test CHANGED
@@ -45,3 +45,331 @@
45
45
 
46
46
 
47
47
  ### 補足情報(FW/ツールのバージョンなど)
48
+
49
+ なにが必要かよくわからなのでいろいろのせますね
50
+
51
+ ```laravel
52
+
53
+ <?php
54
+
55
+ use Illuminate\Support\Facades\DB;
56
+
57
+ use Illuminate\Support\Facades\Redirect;
58
+
59
+ use Illuminate\Http\Request;
60
+
61
+ session_start();
62
+
63
+
64
+
65
+ //unset($_SESSION[ordertable]);
66
+
67
+ //print_r($_SESSION);
68
+
69
+
70
+
71
+ switch ($_POST['menu']) {
72
+
73
+ case 'もりそば':
74
+
75
+ $id = 1;
76
+
77
+ break;
78
+
79
+ case 'ざるそば':
80
+
81
+ $id = 2;
82
+
83
+ break;
84
+
85
+ case 'たぬきそば':
86
+
87
+ $id = 3;
88
+
89
+ break;
90
+
91
+ case 'きつねそば':
92
+
93
+ $id = 4;
94
+
95
+ break;
96
+
97
+ case 'かもせいろ':
98
+
99
+ $id = 5;
100
+
101
+ break;
102
+
103
+ case '天ぷらそば':
104
+
105
+ $id = 6;
106
+
107
+ break;
108
+
109
+ }
110
+
111
+
112
+
113
+ $ordertablen = "ordertable" .$_POST['table'];
114
+
115
+
116
+
117
+ array_splice($_SESSION[$ordertablen],$id,1,0);
118
+
119
+ $i = 0;
120
+
121
+ foreach ($_SESSION[$ordertablen] as $menu => $value) {
122
+
123
+
124
+
125
+ if ($value == 0) {
126
+
127
+ $i += 1;
128
+
129
+
130
+
131
+ if ($i==6) {
132
+
133
+ unset($_SESSION[$ordertablen]);
134
+
135
+ }
136
+
137
+ }
138
+
139
+ }
140
+
141
+
142
+
143
+ $name = $_POST['menu'];
144
+
145
+ switch ($name) {
146
+
147
+ case 'もりそば':
148
+
149
+ $price = 600;
150
+
151
+ break;
152
+
153
+ case 'ざるそば':
154
+
155
+ $price = 700;
156
+
157
+ break;
158
+
159
+ case 'たぬきそば':
160
+
161
+ $price = 750;
162
+
163
+ break;
164
+
165
+ case 'きつねそば':
166
+
167
+ $price = 800;
168
+
169
+ break;
170
+
171
+ case 'かもせいろ':
172
+
173
+ $price = 900;
174
+
175
+ break;
176
+
177
+ case '天ぷらそば':
178
+
179
+ $price = 1300;
180
+
181
+ break;
182
+
183
+ }
184
+
185
+
186
+
187
+
188
+
189
+ if (ctype_digit($_POST['table'])) {
190
+
191
+
192
+
193
+ try {
194
+
195
+
196
+
197
+ DB::table('uriage')->insert([
198
+
199
+ 'name' => $name,
200
+
201
+ 'num' => $_POST['num'],
202
+
203
+ 'price' => $price,
204
+
205
+
206
+
207
+ ]);
208
+
209
+
210
+
211
+ //ここにいれたい 
212
+
213
+
214
+
215
+
216
+
217
+ } catch (\Exception $e) {
218
+
219
+ exit('ログイン失敗 データが該当しません。'.$e->getMessage());
220
+
221
+ }
222
+
223
+
224
+
225
+ }else {
226
+
227
+ try {
228
+
229
+ $pdo = $dbcon->dbconnect();
230
+
231
+ $stmt = $pdo->prepare('insert into uriage (name,num,price,cname,demae)value(:name,:num,:price,:cname,1)');
232
+
233
+ $stmt -> bindParam(':name',$name);
234
+
235
+ $stmt -> bindParam(':num',$_POST['num']);
236
+
237
+ $stmt -> bindParam(':price',$price);
238
+
239
+ $stmt -> bindParam(':cname',$_POST["table"]);
240
+
241
+ $stmt->execute();
242
+
243
+
244
+
245
+ echo "完了";
246
+
247
+
248
+
249
+
250
+
251
+ } catch (\Exception $e) {
252
+
253
+ exit('ログイン失敗 データが該当しません。'.$e->getMessage());
254
+
255
+ }
256
+
257
+ }
258
+
259
+
260
+
261
+
262
+
263
+ ?>
264
+
265
+
266
+
267
+ ```
268
+
269
+ ```laravel
270
+
271
+ Route::get('/', 'PagesController@getHome')->name("index");
272
+
273
+ Route::post('/thanks', 'PagesController@check')->name("thanks");
274
+
275
+ Route::get('/tyuubou', 'PagesController@tyuubou')->name("tyuubou");
276
+
277
+ Route::post('/uriage', 'PagesController@addsale')->name("uriage");
278
+
279
+ Route::get('/d', 'PagesController@getD')->name("dindex");
280
+
281
+ Route::post('/dmenu', 'PagesController@go')->name("dmenu");
282
+
283
+ Route::get('/dt', 'PagesController@getDt')->name("dindex");
284
+
285
+
286
+
287
+ ```
288
+
289
+ ```laravel
290
+
291
+
292
+
293
+ <?php
294
+
295
+
296
+
297
+ namespace App\Http\Controllers;
298
+
299
+
300
+
301
+ use Illuminate\Http\Request;
302
+
303
+ use Illuminate\Support\Facades\DB;
304
+
305
+ use App\menus;
306
+
307
+
308
+
309
+ class PagesController extends Controller
310
+
311
+ {
312
+
313
+ // Homeを表示
314
+
315
+ public function getHome(){
316
+
317
+ $menus = DB::table('menus')->get();
318
+
319
+ return view('home',['menus' => $menus]);
320
+
321
+ }
322
+
323
+
324
+
325
+
326
+
327
+ public function getD(){
328
+
329
+ return view('dindex');
330
+
331
+ }
332
+
333
+ public function getDt(){
334
+
335
+ return view('dt');
336
+
337
+ }
338
+
339
+
340
+
341
+ public function tyuubou(){
342
+
343
+ return view('tyuubou');
344
+
345
+ }
346
+
347
+ public function check(){
348
+
349
+ $request = request()->all();
350
+
351
+ return view('thanks',['request'=>$request]);
352
+
353
+ }
354
+
355
+
356
+
357
+ public function addsale(){
358
+
359
+ return view('uriage');
360
+
361
+ }
362
+
363
+
364
+
365
+ public function go (){
366
+
367
+ return view('dmenu');
368
+
369
+ }
370
+
371
+ }
372
+
373
+
374
+
375
+ ```

1

headerのように自動的に移動するようにしたいです。

2019/08/19 08:31

投稿

Junya42
Junya42

スコア5

test CHANGED
File without changes
test CHANGED
@@ -7,6 +7,10 @@
7
7
  直前のファンクションは動作しているのですが、このリダイレクトは
8
8
 
9
9
  反応しないです。
10
+
11
+
12
+
13
+ headerのように自動的に移動するようにしたいです。
10
14
 
11
15
 
12
16