質問編集履歴
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
LaravelでPATCH機能を使用したとき、URLにいい加減
|
1
|
+
LaravelでPATCH機能を使用したとき、URLにいい加減な値を設定すると、
|
2
2
|
404ではなく、The GET method is not supported for route bundle/1. Supported methods: PATCH.をいエラー画面が表示さます。
|
3
3
|
|
4
4
|
具体的には以下のようなルーティングで、
|
1
追記1コントローラー
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,3 +19,64 @@
|
|
19
19
|
|
20
20
|
どのような解決策がありますか?
|
21
21
|
|
22
|
+
追記1)
|
23
|
+
```BundleController
|
24
|
+
<?php
|
25
|
+
|
26
|
+
namespace App\Http\Controllers;
|
27
|
+
|
28
|
+
use Illuminate\Http\Request;
|
29
|
+
use App\Models\Bundle;
|
30
|
+
|
31
|
+
class BundleController extends Controller
|
32
|
+
{
|
33
|
+
public function show()
|
34
|
+
{
|
35
|
+
$bundle = Bundle::find(1);
|
36
|
+
|
37
|
+
return view('bundle.show')
|
38
|
+
->with(['bundle' => $bundle]);
|
39
|
+
|
40
|
+
}
|
41
|
+
|
42
|
+
public function update(Request $request, Bundle $bundle)
|
43
|
+
{
|
44
|
+
if ($request->save == "save") {
|
45
|
+
$request->validate([
|
46
|
+
'f2a4' => 'required|numeric|min:0|max:999',
|
47
|
+
'f2a3' => 'required|numeric|min:0|max:999',
|
48
|
+
'f2b5' => 'required|numeric|min:0|max:999',
|
49
|
+
'f2b4' => 'required|numeric|min:0|max:999',
|
50
|
+
'f2a4' => 'required|numeric|min:0|max:999',
|
51
|
+
'f3a4' => 'required|numeric|min:0|max:999',
|
52
|
+
'f3a3' => 'required|numeric|min:0|max:999',
|
53
|
+
'f3b5' => 'required|numeric|min:0|max:999',
|
54
|
+
'f3b4' => 'required|numeric|min:0|max:999',
|
55
|
+
]);
|
56
|
+
|
57
|
+
$bundle->f2a4 = $request->f2a4;
|
58
|
+
$bundle->f2a3 = $request->f2a3;
|
59
|
+
$bundle->f2b5 = $request->f2b5;
|
60
|
+
$bundle->f2b4 = $request->f2b4;
|
61
|
+
$bundle->f3a4 = $request->f3a4;
|
62
|
+
$bundle->f3a3 = $request->f3a3;
|
63
|
+
$bundle->f3b5 = $request->f3b5;
|
64
|
+
$bundle->f3b4 = $request->f3b4;
|
65
|
+
} else {
|
66
|
+
$bundle->f2a4 = 0;
|
67
|
+
$bundle->f2a3 = 0;
|
68
|
+
$bundle->f2b5 = 0;
|
69
|
+
$bundle->f2b4 = 0;
|
70
|
+
$bundle->f3a4 = 0;
|
71
|
+
$bundle->f3a3 = 0;
|
72
|
+
$bundle->f3b5 = 0;
|
73
|
+
$bundle->f3b4 = 0;
|
74
|
+
}
|
75
|
+
|
76
|
+
$bundle->save();
|
77
|
+
|
78
|
+
return redirect()
|
79
|
+
->route('bundle.show');
|
80
|
+
}
|
81
|
+
}
|
82
|
+
```
|