mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-02-14 15:39:37 -06:00
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.
50 lines
1.3 KiB
PHP
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);
|
|
}
|
|
}
|