<?php

namespace App\Http\Resources;

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

class ManagementSubmissionResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'user' => [
                'name' => $this->user->name,
                'role' => [
                    'name' => $this->user->role->name,
                    'type_role' => $this->user->role->type_role,
                ]
            ],
            'status' => $this->status,
            'visit_dealer' => $this->visit_dealer,
            'visit_retailer' => $this->visit_retailer,
            'visit_farmer' => $this->visit_farmer,
            'by' => [
                'name' => $this->user->name,
                'role' => [
                    'name' => $this->user->role->name,
                    'type_role' => $this->user->role->type_role,
                ]
            ],
            'by_at_time' => $this->by_at_time,
            'by_at_date' => $this->by_at_date,
            'note_by' => $this->note_by,
            'created_at_date' => $this->created_at_date,
            'created_at_time' => $this->created_at_time,
        ];
    }


}

