Skip to content

A self-hosted media server and file management system

592 B
Raw Blame
<?php

namespace App\Http\Resources;

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

class VideoTagResource extends JsonResource {
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array {
        if (! $this->relationLoaded('tag')) {
            $this->loadMissing('tag');
        }

        $tag = $this->tag;

        return [
            'video_tag_id' => $this->id,
            'name' => $tag->name,
            'id' => $this->tag_id,
        ];
    }
}