exam support valid multiple

This commit is contained in:
xiaomlove
2022-04-17 16:38:44 +08:00
parent bacfdd0df1
commit e0a515b66c
59 changed files with 950 additions and 79 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class HitAndRunResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
$out = [
'id' => $this->id,
'uid' => $this->uid,
'user' => new UserResource($this->whenLoaded('user')),
'torrent_id' => $this->torrent_id,
'torrent' => new TorrentResource($this->whenLoaded('torrent')),
'snatched_id' => $this->snatched_id,
'snatch' => new SnatchResource($this->whenLoaded('snatch')),
'status' => $this->status,
'status_text' => $this->status_text,
'comment' => $this->comment,
'created_at' => format_datetime($this->created_at),
'updated_at' => format_datetime($this->updated_at),
'seed_time_required' => $this->seedTimeRequired,
'inspect_time_left' => $this->inspectTimeLeft,
];
if (nexus()->isPlatformAdmin()) {
$out['comment'] = nl2br(trim($out['comment']));
}
return $out;
}
}

View File

@@ -4,7 +4,7 @@ namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class SnatchResource extends PeerResource
class SnatchResource extends JsonResource
{
/**
* Transform the resource into an array.
@@ -20,10 +20,10 @@ class SnatchResource extends PeerResource
'upload_text' => $this->upload_text,
'download_text' => $this->download_text,
'share_ratio' => $this->share_ratio,
'seed_time' => $this->seed_time,
'leech_time' => $this->leech_time,
'completed_at_human' => $this->completed_at_human,
'last_action_human' => $this->last_action_human,
'seed_time' => mkprettytime($this->seedtime),
'leech_time' => mkprettytime($this->leechtime),
'completed_at_human' => $this->completedat ? $this->completedat->diffForHumans() : '',
'last_action_human' => $this->last_action ? $this->last_action->diffForHumans() : '',
'user' => new UserResource($this->whenLoaded('user')),
];
}

View File

@@ -6,6 +6,7 @@ use App\Models\Attachment;
use App\Models\Torrent;
use Carbon\CarbonInterface;
use Illuminate\Http\Resources\Json\JsonResource;
use Nexus\Nexus;
class TorrentResource extends JsonResource
{
@@ -69,6 +70,10 @@ class TorrentResource extends JsonResource
$out['peers_count'] = $this->peers_count;
$out['reward_logs_count'] = $this->reward_logs_count;
}
if (nexus()->isPlatformAdmin()) {
$out['details_url'] = sprintf('%s/details.php?id=%s', getSchemeAndHttpHost(), $this->id);
}
// $out['upload_peers_count'] = $this->upload_peers_count;
// $out['download_peers_count'] = $this->download_peers_count;
// $out['finish_peers_count'] = $this->finish_peers_count;