[api] message order by id desc

This commit is contained in:
xiaomlove
2022-02-21 21:49:38 +08:00
parent ab7b2d506b
commit 4df7479d72
2 changed files with 8 additions and 5 deletions

View File

@@ -18,7 +18,11 @@ class MessageController extends Controller
public function index(Request $request)
{
$user = Auth::user();
$messages = Message::query()->where('receiver', $user->id)->with(['send_user'])->paginate();
$messages = Message::query()
->where('receiver', $user->id)
->with(['send_user'])
->orderBy('id', 'desc')
->paginate();
$resource = MessageResource::collection($messages);
return $this->success($resource);

View File

@@ -36,7 +36,8 @@ class TorrentResource extends JsonResource
'user' => new UserResource($this->whenLoaded('user')),
'basic_category' => new CategoryResource($this->whenLoaded('basic_category')),
];
$descriptionArr = format_description($this->descr);
$out['cover'] = get_image_from_description($descriptionArr, true);
if ($request->routeIs('torrents.show')) {
$baseInfo = [
['label' => nexus_trans('torrent.show.size'), 'value' => mksize($this->size)],
@@ -47,7 +48,7 @@ class TorrentResource extends JsonResource
}
}
$out['base_info'] = $baseInfo;
$descriptionArr = format_description($this->descr);
$out['description'] = $descriptionArr;
$out['images'] = get_image_from_description($descriptionArr);
@@ -55,8 +56,6 @@ class TorrentResource extends JsonResource
$out['thank_users_count'] = $this->thank_users_count;
$out['peers_count'] = $this->peers_count;
}
$out['cover'] = get_image_from_description(format_description($this->descr), true);
// $out['upload_peers_count'] = $this->upload_peers_count;
// $out['download_peers_count'] = $this->download_peers_count;
// $out['finish_peers_count'] = $this->finish_peers_count;