Skip to content

Commit

Permalink
[2.x] - Add resource DefaultResource
Browse files Browse the repository at this point in the history
  • Loading branch information
Nandovga committed Aug 28, 2024
1 parent 4dc1596 commit 16d4545
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Http/Resource/DefaultResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Orangesix\Http\Resource;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class DefaultResource extends JsonResource
{
/**
* Transforme os dados para ser utilizados
* @return array<int|string, mixed>
*/
public function toArray(Request $request): array
{
$data = [];
if (method_exists($this->resource, 'getAttributes')) {
$data = $this->resource->getAttributes();
}
return array_merge($data);
}
}

0 comments on commit 16d4545

Please sign in to comment.