Files
UNIT3D-Community-Edition/app/Http/Resources/TorrentsResource.php
Roardom 0000838d8b refactor: cruddy torrents
Separate torrents into cruddy route names. Route model binding isn't possible due to the global scope on unapproved torrents. Use form requests. Simplify the controller flow where possible.
2023-07-07 03:18:13 +00:00

50 lines
1.3 KiB
PHP

<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class TorrentsResource extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*/
public function toArray($request): array
{
return [
'data' => TorrentResource::collection($this->collection),
];
}
/**
* Get additional data that should be returned with the resource array.
*/
public function with($request): array
{
return [
'links' => [
'self' => route('api.torrents.index'),
],
];
}
/**
* Customize the outgoing response for the resource.
*/
public function withResponse($request, $response): void
{
$response->setEncodingOptions(JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
}
}