mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-19 06:43:45 +02:00
Add nests & eggs
Cleanup middleware handling and parameters on controllers...
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Pterodactyl\Extensions\League\Fractal\Serializers;
|
||||
|
||||
use League\Fractal\Serializer\ArraySerializer;
|
||||
|
||||
class PterodactylSerializer extends ArraySerializer
|
||||
{
|
||||
/**
|
||||
* Serialize an item.
|
||||
*
|
||||
* @param string $resourceKey
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function item($resourceKey, array $data)
|
||||
{
|
||||
return [
|
||||
'object' => $resourceKey,
|
||||
'attributes' => $data,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a collection.
|
||||
*
|
||||
* @param string $resourceKey
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function collection($resourceKey, array $data)
|
||||
{
|
||||
$response = [];
|
||||
foreach ($data as $datum) {
|
||||
$response[] = $this->item($resourceKey, $datum);
|
||||
}
|
||||
|
||||
return [
|
||||
'object' => 'list',
|
||||
'data' => $response,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a null resource.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function null()
|
||||
{
|
||||
return [
|
||||
'object' => 'null_resource',
|
||||
'attributes' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the included resources with the parent resource being serialized.
|
||||
*
|
||||
* @param array $transformedData
|
||||
* @param array $includedData
|
||||
* @return array
|
||||
*/
|
||||
public function mergeIncludes($transformedData, $includedData)
|
||||
{
|
||||
foreach ($includedData as $key => $datum) {
|
||||
$transformedData['relationships'][$key] = $datum;
|
||||
}
|
||||
|
||||
return $transformedData;
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ namespace Pterodactyl\Extensions\Spatie\Fractalistic;
|
||||
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Spatie\Fractal\Fractal as SpatieFractal;
|
||||
use League\Fractal\Serializer\JsonApiSerializer;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use Pterodactyl\Extensions\League\Fractal\Serializers\PterodactylSerializer;
|
||||
|
||||
class Fractal extends SpatieFractal
|
||||
{
|
||||
@@ -22,7 +22,7 @@ class Fractal extends SpatieFractal
|
||||
{
|
||||
// Set the serializer by default.
|
||||
if (is_null($this->serializer)) {
|
||||
$this->serializer = new JsonApiSerializer;
|
||||
$this->serializer = new PterodactylSerializer;
|
||||
}
|
||||
|
||||
// Automatically set the paginator on the response object if the
|
||||
|
||||
Reference in New Issue
Block a user