File tree 2 files changed +59
-4
lines changed 2 files changed +59
-4
lines changed Original file line number Diff line number Diff line change @@ -79,9 +79,9 @@ public function signup(Request $request)
79
79
80
80
User::unguard ();
81
81
$ user = User::create ([
82
- 'name ' => $ userData ['name ' ],
83
- 'email ' => $ userData ['email ' ],
84
- 'password ' => bcrypt ($ userData ['password ' ]),
82
+ 'name ' => $ userData ['name ' ],
83
+ 'email ' => $ userData ['email ' ],
84
+ 'password ' => bcrypt ($ userData ['password ' ]),
85
85
]);
86
86
User::reguard ();
87
87
@@ -92,7 +92,7 @@ public function signup(Request $request)
92
92
if ($ hasToReleaseToken ) {
93
93
return $ this ->login ($ request );
94
94
}
95
-
95
+
96
96
return $ this ->response ->created ();
97
97
}
98
98
Original file line number Diff line number Diff line change @@ -43,6 +43,61 @@ public function store(Request $request) {
43
43
44
44
45
45
46
+
47
+ public function show ($ id )
48
+ {
49
+ $ currentUser = JWTAuth::parseToken ()->authenticate ();
50
+
51
+ $ book = $ currentUser ->books ()->find ($ id );
52
+
53
+ if (!$ book )
54
+ throw new NotFoundHttpException ;
55
+
56
+ return $ book ;
57
+ }
58
+
59
+
60
+
61
+
62
+
63
+
64
+ public function update (Request $ request , $ id )
65
+ {
66
+ $ currentUser = JWTAuth::parseToken ()->authenticate ();
67
+
68
+ $ book = $ currentUser ->books ()->find ($ id );
69
+ if (!$ book )
70
+ throw new NotFoundHttpException ;
71
+
72
+ $ book ->fill ($ request ->all ());
73
+
74
+ if ($ book ->save ())
75
+ return $ this ->response ->noContent ();
76
+ else
77
+ return $ this ->response ->error ('could_not_update_book ' , 500 );
78
+ }
79
+
80
+
81
+
82
+
83
+
84
+
85
+ public function destroy ($ id )
86
+ {
87
+ $ currentUser = JWTAuth::parseToken ()->authenticate ();
88
+
89
+ $ book = $ currentUser ->books ()->find ($ id );
90
+
91
+ if (!$ book )
92
+ throw new NotFoundHttpException ;
93
+
94
+ if ($ book ->delete ())
95
+ return $ this ->response ->noContent ();
96
+ else
97
+ return $ this ->response ->error ('could_not_delete_book ' , 500 );
98
+ }
99
+
100
+
46
101
}
47
102
48
103
You can’t perform that action at this time.
0 commit comments