[admin] set torrent pos_state_until

This commit is contained in:
xiaomlove
2022-09-18 03:33:13 +08:00
parent 29fc44e555
commit 464880f1fb
3 changed files with 34 additions and 9 deletions

View File

@@ -598,11 +598,22 @@ class TorrentRepository extends BaseRepository
}
public function setPosState($id, $posState): int
public function setPosState($id, $posState, $posStateUntil = null): int
{
user_can('torrentsticky', true);
if ($posState == Torrent::POS_STATE_STICKY_NONE) {
$posStateUntil = null;
}
if ($posStateUntil && Carbon::parse($posStateUntil)->lte(now())) {
$posState = Torrent::POS_STATE_STICKY_NONE;
$posStateUntil = null;
}
$update = [
'pos_state' => $posState,
'pos_state_until' => $posStateUntil,
];
$idArr = Arr::wrap($id);
return Torrent::query()->whereIn('id', $idArr)->update(['pos_state' => $posState]);
return Torrent::query()->whereIn('id', $idArr)->update($update);
}
public function buildUploadFieldInput($name, $value, $noteText, $btnText): string