<?php

namespace App\Http\Resources;

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

class ActivityLogResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'user' => $this->user->name,
            'ip' => config('app.demo_mode') ? 'x.x.x.x' : $this->ip,
            'activity' => $this->activity,
            'device' => config('app.demo_mode') ? '... xxxx ... (Device & IP information hidden due to privacy protection while in demo mode)' : $this->device,
            'link' => $this->link,
            'created_at' => $this->created_at->format(config('app.app_date_format')),
            'updated_at' => $this->updated_at->format(config('app.app_date_format')),
        ];
    }
}
