61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class MediaResource extends JsonResource
|
|
{
|
|
/** @var array */
|
|
private static $skeleton = [
|
|
'id' => 0,
|
|
'arcadia_id' => 0,
|
|
'libelle' => '',
|
|
'uid' => '',
|
|
'version' => '',
|
|
'created_at' => '',
|
|
'updated_at' => '',
|
|
];
|
|
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
* + id integer
|
|
* + arcadia_id integer
|
|
* + libelle string
|
|
* + uid string
|
|
* + version integer
|
|
* + created_at datetime
|
|
* + updated_at datetime
|
|
*/
|
|
//phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass, Squiz.Commenting.FunctionComment.Missing
|
|
public function toArray($request)
|
|
{
|
|
$data = array_intersect_key(
|
|
array_merge([
|
|
'id' => $this->id,
|
|
'arcadia_id' => $this->arcadia_id,
|
|
'libelle' => $this->libelle,
|
|
'uid' => $this->uid,
|
|
'version' => $this->version,
|
|
'created_at' => $this->created_at,
|
|
'updated_at' => $this->updated_at,
|
|
]),
|
|
$this->getSkeleton()
|
|
);
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Returns the resource skeletton
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function getSkeleton(): array
|
|
{
|
|
return self::$skeleton;
|
|
}
|
|
}
|