2024-05-16 14:06:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Resources\Fo\Recipes;
|
|
|
|
|
|
|
|
|
|
use App\Models\Video;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
|
|
|
|
|
class VideoResource extends JsonResource
|
|
|
|
|
{
|
|
|
|
|
/** @var \App\Models\Video */
|
|
|
|
|
private $videoModel;
|
|
|
|
|
|
|
|
|
|
/** @var array */
|
|
|
|
|
private static $skeleton = [
|
2024-05-21 17:00:46 +02:00
|
|
|
'id' => '',
|
|
|
|
|
'title' => '',
|
|
|
|
|
'video_id' => '',
|
2024-05-16 14:06:45 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* VideoResource
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(Video $videoModel)
|
|
|
|
|
{
|
|
|
|
|
$this->videoModel = $videoModel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Transform the resource into an array.
|
|
|
|
|
*
|
|
|
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
|
|
|
|
*/
|
|
|
|
|
public function toArray(?Request $request = null): array
|
|
|
|
|
{
|
2026-09-25 16:25:31 +02:00
|
|
|
// phpcs:enable
|
2024-05-16 14:06:45 +02:00
|
|
|
return array_intersect_key(
|
|
|
|
|
[
|
2024-06-19 12:06:56 +02:00
|
|
|
'id' => $this->videoModel->getKey(),
|
2024-05-21 17:00:46 +02:00
|
|
|
'title' => $this->videoModel->title,
|
|
|
|
|
'video_id' => $this->videoModel->video_id,
|
2024-05-16 14:06:45 +02:00
|
|
|
],
|
|
|
|
|
$this->getSkeleton()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the resource skeletton.
|
|
|
|
|
*/
|
|
|
|
|
public static function getSkeleton(): array
|
|
|
|
|
{
|
|
|
|
|
return self::$skeleton;
|
|
|
|
|
}
|
|
|
|
|
}
|