@@ -84,7 +84,7 @@ public function index(Request $request, NewsPinned $newsPinnedModel)
84
84
* @param NewsPinned $pinned
85
85
* @return mixed
86
86
*/
87
- public function audit (Request $ request , NewsPinned $ pinned , Carbon $ datetime )
87
+ public function audit (Request $ request , UserProcess $ userProcess , NewsPinned $ pinned )
88
88
{
89
89
$ action = $ request ->input ('action ' , 'accept ' );
90
90
@@ -94,15 +94,17 @@ public function audit(Request $request, NewsPinned $pinned, Carbon $datetime)
94
94
95
95
if ($ pinned ->expires_at !== null ) {
96
96
return response ()->json (['message ' => ['该记录已被处理 ' ]], 403 );
97
+ } elseif ($ action === 'accept ' ) {
98
+ return $ this ->accept ($ pinned );
97
99
}
98
100
99
- return $ this ->{ $ action }( $ pinned , $ datetime );
101
+ return $ this ->reject ( $ userProcess , $ pinned );
100
102
}
101
103
102
- public function accept (NewsPinned $ pinned, Carbon $ datetime )
104
+ public function accept (NewsPinned $ pinned )
103
105
{
104
106
$ pinned ->state = 1 ;
105
- $ pinned ->expires_at = $ datetime ->addDay ($ pinned ->day );
107
+ $ pinned ->expires_at = ( new Carbon ) ->addDay ($ pinned ->day );
106
108
$ pinned ->save ();
107
109
108
110
// 审核通过后增加未读数
@@ -122,10 +124,10 @@ public function accept(NewsPinned $pinned, Carbon $datetime)
122
124
return response ()->json ([], 204 );
123
125
}
124
126
125
- public function reject (NewsPinned $ pinned , Carbon $ datetime , UserProcess $ userProcess )
127
+ public function reject (UserProcess $ userProcess , NewsPinned $ pinned )
126
128
{
127
129
$ pinned ->state = 2 ;
128
- $ pinned ->expires_at = $ datetime ;
130
+ $ pinned ->expires_at = new Carbon ;
129
131
$ userCount = UserCountModel::firstOrNew ([
130
132
'user_id ' => $ pinned ->user_id ,
131
133
'type ' => 'user-system ' ,
0 commit comments