-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -710,19 +710,28 @@ protected function fillFeedBaseData(Request $request, FeedModel $feed): FeedMode | |
/** | ||
* 新版删除动态接口,如有置顶申请讲退还相应积分. | ||
* | ||
* @param Request $request | ||
* @param ResponseContract $response | ||
* @param FeedModel $feed | ||
* @return mixed | ||
* @author BS <[email protected]> | ||
*/ | ||
public function newDestroy( | ||
Request $request, | ||
ResponseContract $response, | ||
FeedModel $feed | ||
) { | ||
$user = $request->user(); | ||
if ($user->id !== $feed->user_id && ! $user->ability('[feed] Delete Feed')) { | ||
$user = $feed->user; | ||
if (! $user) { | ||
// 删除话题关联 | ||
$feed->topics->each(function ($topic) { | ||
$topic->feeds_count -= 1; | ||
$topic->save(); | ||
}); | ||
$feed->topics()->sync([]); | ||
|
||
$feed->delete(); | ||
|
||
return $response->json(null, 204); | ||
} elseif ($user->id !== $feed->user_id && ! $user->ability('[feed] Delete Feed')) { | ||
return $response->json(['message' => '你没有权限删除动态'])->setStatusCode(403); | ||
} | ||
|
||
|