add cover to torrent

This commit is contained in:
xiaomlove
2022-05-03 23:58:27 +08:00
parent 71d10de4c2
commit 130051d648
9 changed files with 144 additions and 28 deletions
+1 -2
View File
@@ -126,8 +126,7 @@ class Test extends Command
// $r = $rep->getContinuousDays($attendance);
// $r = $rep->getContinuousPoints(11);
$today = Carbon::today();
$r = $today->endOfMonth();
$r = parse_url('https://img9.doubanio.com/view/photo/l_ratio_poster/public/p2867903173.jpg', PHP_URL_SCHEME);
dd($r);
}
+10 -2
View File
@@ -49,9 +49,17 @@ class TorrentResource extends JsonResource
'thanks' => ThankResource::collection($this->whenLoaded('thanks')),
'reward_logs' => RewardResource::collection($this->whenLoaded('reward_logs')),
];
$descriptionArr = format_description($this->descr);
$out['cover'] = get_image_from_description($descriptionArr, true);
if ($this->cover) {
$cover = $this->cover;
} else {
$descriptionArr = format_description($this->descr);
$cover = get_image_from_description($descriptionArr, true);
}
$out['cover'] = resize_image($cover, 100, 100);
if ($request->routeIs('torrents.show')) {
if (!isset($descriptionArr)) {
$descriptionArr = format_description($this->descr);
}
$baseInfo = [
['label' => nexus_trans('torrent.show.size'), 'value' => mksize($this->size)],
];
+2 -2
View File
@@ -13,7 +13,7 @@ class Torrent extends NexusModel
'category', 'source', 'medium', 'codec', 'standard', 'processing', 'team', 'audiocodec',
'size', 'added', 'type', 'numfiles', 'owner', 'nfo', 'sp_state', 'promotion_time_type',
'promotion_until', 'anonymous', 'url', 'pos_state', 'cache_stamp', 'picktype', 'picktime',
'last_reseed', 'pt_gen', 'technical_info', 'leechers', 'seeders',
'last_reseed', 'pt_gen', 'technical_info', 'leechers', 'seeders', 'cover',
];
private static $globalPromotionState;
@@ -31,7 +31,7 @@ class Torrent extends NexusModel
public static $commentFields = [
'id', 'name', 'added', 'visible', 'banned', 'owner', 'sp_state', 'pos_state', 'hr', 'picktype', 'picktime',
'last_action', 'leechers', 'seeders', 'times_completed', 'views', 'size'
'last_action', 'leechers', 'seeders', 'times_completed', 'views', 'size', 'cover'
];
public static $basicRelations = [