Skip to content

Commit 9d5be5f

Browse files
committed
fix(资讯): 修复资讯拒绝置顶申请服务器报 500 错误
#438
1 parent f2a91eb commit 9d5be5f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/slimkit-plus-news/src/AdminControllers/NewsPinnedController.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function index(Request $request, NewsPinned $newsPinnedModel)
8484
* @param NewsPinned $pinned
8585
* @return mixed
8686
*/
87-
public function audit(Request $request, NewsPinned $pinned, Carbon $datetime)
87+
public function audit(Request $request, UserProcess $userProcess, NewsPinned $pinned)
8888
{
8989
$action = $request->input('action', 'accept');
9090

@@ -94,15 +94,17 @@ public function audit(Request $request, NewsPinned $pinned, Carbon $datetime)
9494

9595
if ($pinned->expires_at !== null) {
9696
return response()->json(['message' => ['该记录已被处理']], 403);
97+
} elseif ($action === 'accept') {
98+
return $this->accept($pinned);
9799
}
98100

99-
return $this->{$action}($pinned, $datetime);
101+
return $this->reject($userProcess, $pinned);
100102
}
101103

102-
public function accept(NewsPinned $pinned, Carbon $datetime)
104+
public function accept(NewsPinned $pinned)
103105
{
104106
$pinned->state = 1;
105-
$pinned->expires_at = $datetime->addDay($pinned->day);
107+
$pinned->expires_at = (new Carbon)->addDay($pinned->day);
106108
$pinned->save();
107109

108110
// 审核通过后增加未读数
@@ -122,10 +124,10 @@ public function accept(NewsPinned $pinned, Carbon $datetime)
122124
return response()->json([], 204);
123125
}
124126

125-
public function reject(NewsPinned $pinned, Carbon $datetime, UserProcess $userProcess)
127+
public function reject(UserProcess $userProcess, NewsPinned $pinned)
126128
{
127129
$pinned->state = 2;
128-
$pinned->expires_at = $datetime;
130+
$pinned->expires_at = new Carbon;
129131
$userCount = UserCountModel::firstOrNew([
130132
'user_id' => $pinned->user_id,
131133
'type' => 'user-system',

0 commit comments

Comments
 (0)