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

質問編集履歴

4

//ここにいれたいとbefore

2019/08/19 08:51

投稿

Junya42
Junya42

スコア5

title CHANGED
File without changes
body CHANGED
@@ -17,7 +17,7 @@
17
17
  ### 試したこと
18
18
 
19
19
  ```laravel
20
- return redirect()->to('todofuken/tokyo');
20
+ return redirect()->to('tyuubou');
21
21
  ```
22
22
  これでできるとあったのですが、ダメでした。
23
23
 
@@ -105,6 +105,7 @@
105
105
  ]);
106
106
 
107
107
  //ここにいれたい 
108
+ return redirect()->to('tyuubou');と書いていました。
108
109
 
109
110
 
110
111
  } catch (\Exception $e) {

3

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

2019/08/19 08:50

投稿

Junya42
Junya42

スコア5

title CHANGED
File without changes
body CHANGED
@@ -23,6 +23,7 @@
23
23
 
24
24
  ### 補足情報(FW/ツールのバージョンなど)
25
25
  なにが必要かよくわからなのでいろいろのせますね
26
+ 移動前blade
26
27
  ```laravel
27
28
  <?php
28
29
  use Illuminate\Support\Facades\DB;
@@ -185,4 +186,79 @@
185
186
  }
186
187
  }
187
188
 
189
+ ```
190
+ 移動先blade
191
+ ```laravel
192
+
193
+
194
+
195
+
196
+ <html lang="ja" dir="ltr">
197
+ <head>
198
+ <meta charset="utf-8">
199
+ <meta name="viewport" content="width=device-width">
200
+ <link rel="stylesheet" href="css/style2.css">
201
+ <title></title>
202
+ </head>
203
+ <body>
204
+ <article class="">
205
+ <header>
206
+ <h1>オーダー</h1>
207
+ </header>
208
+
209
+
210
+ <?php session_start();
211
+
212
+ foreach ($_SESSION as $ordertable => $orders) :?>
213
+ <?php foreach ($orders as $menu => $num): ?>
214
+
215
+ <?php if(!0==($num)){
216
+ if ($menu !== 'table'&& $menu !=='hito'&& $menu !== '_token') { ?>
217
+   <section class="">
218
+
219
+
220
+ <div class="商品名">
221
+ <?php echo $menu; ?>
222
+ </div>
223
+
224
+ <form class="" action="{{route('uriage')}}" method="post">
225
+ {{csrf_field()}}
226
+ <a class="個数">個数
227
+ <select class="select" >
228
+ <option> <?php echo $num; ?></option>
229
+ </select>
230
+ </a>
231
+ <input type="hidden" name="num" value="<?php echo $num; ?>">
232
+ <input type="hidden" name="menu" value="<?php echo $menu; ?>">
233
+ <input type="hidden" name="table" value="<?php echo $orders["table"] ?>">
234
+ <input type="hidden" name="hito" value="<?php echo $orders["hito"] ?>">
235
+ <input type="submit" value="完了">
236
+ </form>
237
+
238
+
239
+ <a class="右">テーブル番号
240
+ <select class="select" >
241
+      <option><?php echo $orders["table"] ?></option>
242
+ </select>
243
+ </a>
244
+
245
+
246
+ <a class="人">人数
247
+ <select class="select" name="hito" >?>
248
+ <option><?php echo $orders["hito"] ?></option>
249
+ </select>
250
+ </a>
251
+
252
+
253
+ </section>
254
+ <?php } }?>
255
+ <?php endforeach;?>
256
+ <?php endforeach;?>
257
+
258
+ <br>
259
+ <br><br>
260
+
261
+ </body>
262
+ </html>
263
+
188
264
  ```

2

3つ補足にたしました

2019/08/19 08:41

投稿

Junya42
Junya42

スコア5

title CHANGED
File without changes
body CHANGED
@@ -21,4 +21,168 @@
21
21
  ```
22
22
  これでできるとあったのですが、ダメでした。
23
23
 
24
- ### 補足情報(FW/ツールのバージョンなど)
24
+ ### 補足情報(FW/ツールのバージョンなど)
25
+ なにが必要かよくわからなのでいろいろのせますね
26
+ ```laravel
27
+ <?php
28
+ use Illuminate\Support\Facades\DB;
29
+ use Illuminate\Support\Facades\Redirect;
30
+ use Illuminate\Http\Request;
31
+ session_start();
32
+
33
+ //unset($_SESSION[ordertable]);
34
+ //print_r($_SESSION);
35
+
36
+ switch ($_POST['menu']) {
37
+ case 'もりそば':
38
+ $id = 1;
39
+ break;
40
+ case 'ざるそば':
41
+ $id = 2;
42
+ break;
43
+ case 'たぬきそば':
44
+ $id = 3;
45
+ break;
46
+ case 'きつねそば':
47
+ $id = 4;
48
+ break;
49
+ case 'かもせいろ':
50
+ $id = 5;
51
+ break;
52
+ case '天ぷらそば':
53
+ $id = 6;
54
+ break;
55
+ }
56
+
57
+ $ordertablen = "ordertable" .$_POST['table'];
58
+
59
+ array_splice($_SESSION[$ordertablen],$id,1,0);
60
+ $i = 0;
61
+ foreach ($_SESSION[$ordertablen] as $menu => $value) {
62
+
63
+ if ($value == 0) {
64
+ $i += 1;
65
+
66
+ if ($i==6) {
67
+ unset($_SESSION[$ordertablen]);
68
+ }
69
+ }
70
+ }
71
+
72
+ $name = $_POST['menu'];
73
+ switch ($name) {
74
+ case 'もりそば':
75
+ $price = 600;
76
+ break;
77
+ case 'ざるそば':
78
+ $price = 700;
79
+ break;
80
+ case 'たぬきそば':
81
+ $price = 750;
82
+ break;
83
+ case 'きつねそば':
84
+ $price = 800;
85
+ break;
86
+ case 'かもせいろ':
87
+ $price = 900;
88
+ break;
89
+ case '天ぷらそば':
90
+ $price = 1300;
91
+ break;
92
+ }
93
+
94
+
95
+ if (ctype_digit($_POST['table'])) {
96
+
97
+ try {
98
+
99
+ DB::table('uriage')->insert([
100
+ 'name' => $name,
101
+ 'num' => $_POST['num'],
102
+ 'price' => $price,
103
+
104
+ ]);
105
+
106
+ //ここにいれたい 
107
+
108
+
109
+ } catch (\Exception $e) {
110
+ exit('ログイン失敗 データが該当しません。'.$e->getMessage());
111
+ }
112
+
113
+ }else {
114
+ try {
115
+ $pdo = $dbcon->dbconnect();
116
+ $stmt = $pdo->prepare('insert into uriage (name,num,price,cname,demae)value(:name,:num,:price,:cname,1)');
117
+ $stmt -> bindParam(':name',$name);
118
+ $stmt -> bindParam(':num',$_POST['num']);
119
+ $stmt -> bindParam(':price',$price);
120
+ $stmt -> bindParam(':cname',$_POST["table"]);
121
+ $stmt->execute();
122
+
123
+ echo "完了";
124
+
125
+
126
+ } catch (\Exception $e) {
127
+ exit('ログイン失敗 データが該当しません。'.$e->getMessage());
128
+ }
129
+ }
130
+
131
+
132
+ ?>
133
+
134
+ ```
135
+ ```laravel
136
+ Route::get('/', 'PagesController@getHome')->name("index");
137
+ Route::post('/thanks', 'PagesController@check')->name("thanks");
138
+ Route::get('/tyuubou', 'PagesController@tyuubou')->name("tyuubou");
139
+ Route::post('/uriage', 'PagesController@addsale')->name("uriage");
140
+ Route::get('/d', 'PagesController@getD')->name("dindex");
141
+ Route::post('/dmenu', 'PagesController@go')->name("dmenu");
142
+ Route::get('/dt', 'PagesController@getDt')->name("dindex");
143
+
144
+ ```
145
+ ```laravel
146
+
147
+ <?php
148
+
149
+ namespace App\Http\Controllers;
150
+
151
+ use Illuminate\Http\Request;
152
+ use Illuminate\Support\Facades\DB;
153
+ use App\menus;
154
+
155
+ class PagesController extends Controller
156
+ {
157
+ // Homeを表示
158
+ public function getHome(){
159
+ $menus = DB::table('menus')->get();
160
+ return view('home',['menus' => $menus]);
161
+ }
162
+
163
+
164
+ public function getD(){
165
+ return view('dindex');
166
+ }
167
+ public function getDt(){
168
+ return view('dt');
169
+ }
170
+
171
+ public function tyuubou(){
172
+ return view('tyuubou');
173
+ }
174
+ public function check(){
175
+ $request = request()->all();
176
+ return view('thanks',['request'=>$request]);
177
+ }
178
+
179
+ public function addsale(){
180
+ return view('uriage');
181
+ }
182
+
183
+ public function go (){
184
+ return view('dmenu');
185
+ }
186
+ }
187
+
188
+ ```

1

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

2019/08/19 08:31

投稿

Junya42
Junya42

スコア5

title CHANGED
File without changes
body CHANGED
@@ -4,6 +4,8 @@
4
4
  直前のファンクションは動作しているのですが、このリダイレクトは
5
5
  反応しないです。
6
6
 
7
+ headerのように自動的に移動するようにしたいです。
8
+
7
9
  useは下記のように書いてあります。
8
10
 
9
11
  ```