@@ -31,16 +31,6 @@ public function index()
31
31
return response ()->json ($ result );
32
32
}
33
33
34
- /**
35
- * Show the form for creating a new resource.
36
- *
37
- * @return \Illuminate\Http\JsonResponse
38
- */
39
- public function create ()
40
- {
41
-
42
- }
43
-
44
34
/**
45
35
* Store a newly created resource in storage.
46
36
*
@@ -63,43 +53,21 @@ public function store(Request $request)
63
53
return response ()->json ($ post ->load ('user ' ));
64
54
}
65
55
66
- /**
67
- * Display the specified resource.
68
- *
69
- * @param int $id
70
- * @return \Illuminate\Http\Response
71
- */
72
- public function show ($ id )
73
- {
74
- //
75
- }
76
-
77
- /**
78
- * Show the form for editing the specified resource.
79
- *
80
- * @param int $id
81
- * @return \Illuminate\Http\Response
82
- */
83
- public function edit ($ id )
84
- {
85
- //
86
- }
87
-
88
56
/**
89
57
* Update the specified resource in storage.
90
58
*
91
59
* @param \Illuminate\Http\Request $request
92
- * @param int $id
60
+ * @param Post $post
93
61
* @return \Illuminate\Http\Response
94
62
*/
95
- public function update (Request $ request , $ id )
63
+ public function update (Request $ request , Post $ post )
96
64
{
97
65
$ this ->validate ($ request , [
98
66
'user_id ' => 'required ' ,
99
67
'title ' => 'required|max:255 ' ,
100
68
'description ' => 'required '
101
69
]);
102
- $ post = Post:: find ( $ id ) ->update ([
70
+ $ post ->update ([
103
71
'user_id ' => $ request ->user_id ,
104
72
'title ' => $ request ->title ,
105
73
'description ' => $ request ->description
@@ -111,12 +79,12 @@ public function update(Request $request, $id)
111
79
/**
112
80
* Remove the specified resource from storage.
113
81
*
114
- * @param int $id
82
+ * @param Post $post
115
83
* @return \Illuminate\Http\Response
116
84
*/
117
- public function destroy ($ id )
85
+ public function destroy (Post $ post )
118
86
{
119
- Post:: find ( $ id ) ->delete ();
87
+ $ post ->delete ();
120
88
121
89
return response ()->json ();
122
90
}
0 commit comments