API: torrents upload/list

This commit is contained in:
xiaomlove
2025-04-17 01:39:40 +07:00
parent 0d3a46231d
commit 2b029eba10
72 changed files with 2332 additions and 507 deletions

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
abstract class BaseResource extends JsonResource
{
protected abstract function getResourceName(): string;
protected function whenIncludeField($field): bool
{
return $this->whenInclude($field, "include_fields");
}
private function whenInclude($field, $prefix): bool
{
$fields = request()->input("$prefix." . $this->getResourceName());
if (!$fields) {
return false;
}
$fieldsArr = explode(',', $fields);
return in_array($field, $fieldsArr);
}
}