api add page_title

This commit is contained in:
xiaomlove
2021-05-18 02:37:39 +08:00
parent e5a9dc3273
commit 0c136b7743
19 changed files with 964 additions and 43 deletions

View File

@@ -19,6 +19,9 @@ class CommentController extends Controller
$with = ['create_user', 'update_user'];
$comments = Comment::query()->with($with)->where('torrent', $torrentId)->paginate();
$resource = CommentResource::collection($comments);
$resource->additional([
'page_title' => nexus_trans('comment.index.page_title'),
]);
return $this->success($resource);
}

View File

@@ -32,6 +32,7 @@ class PeerController extends Controller
'seeder_list' => [],
'leecher_list' => [],
'card_titles' => Peer::$cardTitles,
'page_title' => nexus_trans('peer.index.page_title'),
];
$result = $this->repository->listPeers($request->torrent_id);
if ($result['seeder_list']->isNotEmpty()) {

View File

@@ -28,7 +28,10 @@ class SnatchController extends Controller
]);
$snatches = $this->repository->listSnatches($request->torrent_id);
$resource = SnatchResource::collection($snatches);
$resource->additional(['card_titles' => Snatch::$cardTitles]);
$resource->additional([
'card_titles' => Snatch::$cardTitles,
'page_title' => nexus_trans('snatch.index.page_title'),
]);
return $this->success($resource);
}

View File

@@ -22,6 +22,9 @@ class TorrentController extends Controller
$params['visible'] = Torrent::VISIBLE_YES;
$result = $this->repository->getList($params);
$resource = TorrentResource::collection($result);
$resource->additional([
'page_title' => nexus_trans('torrent.index.page_title'),
]);
return $this->success($resource);
}
@@ -45,13 +48,15 @@ class TorrentController extends Controller
*/
public function show($id)
{
$with = ['user', 'basic_audiocodec', 'basic_category', 'basic_codec', 'basic_media', 'basic_source', 'basic_standard', 'basic_team'];
$with = ['user', 'basic_audio_codec', 'basic_category', 'basic_codec', 'basic_media', 'basic_source', 'basic_standard', 'basic_team'];
$result = Torrent::query()->with($with)->withCount(['peers', 'thank_users'])->visible()->findOrFail($id);
// dd($result);
$resource = new TorrentResource($result);
$resource->additional([
'page_title' => nexus_trans('torrent.show.page_title'),
'field_labels' => Torrent::getFieldLabels(),
]);
return $this->success($resource);
}