質問編集履歴

4

解決

2021/11/21 17:53

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -104,7 +104,7 @@
104
104
 
105
105
 
106
106
 
107
- Route::get('hello', [HelloController::class,'index'])->middleware(HelloMiddleware::class);
107
+ Route::get('hello', 'HelloController@index')->middleware(HelloMiddleware::class);
108
108
 
109
109
  ```
110
110
 
@@ -155,3 +155,15 @@
155
155
  ※[参考記事](https://qiita.com/tamakiiii/items/e71040173fa0a1fcad83)
156
156
 
157
157
  2. artisan コマンドで route, config, view, cache のキャッシュをクリアしましたが結果は変わりませんでした。
158
+
159
+
160
+
161
+ ### 自己解決
162
+
163
+ web.php を下記のように訂正
164
+
165
+ ```
166
+
167
+ Route::get('hello', [HelloController::class, 'index'])->middleware(HelloMiddleware::class);
168
+
169
+ ```

3

修正

2021/11/21 17:53

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -52,11 +52,11 @@
52
52
 
53
53
  $data = [
54
54
 
55
- ['name' => 'taro', 'email' => 'taro@yamada'],
55
+ ['name' => 'taro', 'mail' => 'taro@yamada'],
56
56
 
57
- ['name' => 'hanako', 'email' => 'hanako@flower'],
57
+ ['name' => 'hanako', 'mail' => 'hanako@flower'],
58
58
 
59
- ['name' => 'sachiko', 'email' => 'sachiko@happy'],
59
+ ['name' => 'sachiko', 'mail' => 'sachiko@happy'],
60
60
 
61
61
  ];
62
62
 

2

修正

2021/11/21 17:37

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -31,6 +31,48 @@
31
31
 
32
32
 
33
33
  ### 該当のソースコード
34
+
35
+ ```php
36
+
37
+ // Http/Middleware/HelloMiddleware.php
38
+
39
+ namespace App\Http\Middleware;
40
+
41
+ use Closure;
42
+
43
+ use Illuminate\Http\Request;
44
+
45
+ use Illuminate\Support\Facades\Log;
46
+
47
+
48
+
49
+ public function handle(Request $request, Closure $next): mixed
50
+
51
+ {
52
+
53
+ $data = [
54
+
55
+ ['name' => 'taro', 'email' => 'taro@yamada'],
56
+
57
+ ['name' => 'hanako', 'email' => 'hanako@flower'],
58
+
59
+ ['name' => 'sachiko', 'email' => 'sachiko@happy'],
60
+
61
+ ];
62
+
63
+
64
+
65
+ $request->merge(['data' => $data]);
66
+
67
+
68
+
69
+ return $next($request);
70
+
71
+ }
72
+
73
+ ```
74
+
75
+
34
76
 
35
77
  ```php
36
78
 

1

修正

2021/11/21 17:24

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -62,7 +62,7 @@
62
62
 
63
63
 
64
64
 
65
- Route::get('hello', [HelloController::class,'index'])->middleware(HelloMiddleware::class, 'handle');
65
+ Route::get('hello', [HelloController::class,'index'])->middleware(HelloMiddleware::class);
66
66
 
67
67
  ```
68
68