Merge branch '1.9' into php8

This commit is contained in:
xiaomlove
2026-01-07 01:31:11 +07:00
15 changed files with 91 additions and 42 deletions

View File

@@ -25,17 +25,8 @@ class CommentController extends Controller
*/
public function index(Request $request)
{
$torrentId = $request->torrent_id;
$with = ['create_user', 'update_user'];
$comments = Comment::query()
->with($with)
->where('torrent', $torrentId)
->paginate();
$comments = $this->repository->getList($request, Auth::user());
$resource = CommentResource::collection($comments);
// $resource->additional([
// 'page_title' => nexus_trans('comment.index.page_title'),
// ]);
return $this->success($resource);
}

View File

@@ -15,15 +15,13 @@ class CommentResource extends JsonResource
*/
public function toArray($request)
{
$descriptionArr = format_description($this->text);
return [
'id' => $this->id,
'description' => $descriptionArr,
'images' => get_image_from_description($descriptionArr),
'updated_at_human' => format_datetime($this->editdate),
'created_at_human' => $this->added->format('Y-m-d H:i'),
'text' => $this->text,
'updated_at' => format_datetime($this->editdate),
'created_at' => format_datetime($this->added),
'create_user' => new UserResource($this->whenLoaded('create_user')),
'update_user' => new UserResource($this->whenLoaded('update_user')),
'update_user' => $this->when($this->editedby > 0, new UserResource($this->whenLoaded('update_user'))),
];
}
}