<?php

namespace App\Http\Resources\Staking;

use Illuminate\Http\Resources\Json\JsonResource;

class Staking extends JsonResource
{
    public static $wrap = null;
    public $preserveKeys = true;

    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $ranges = array_combine(explode(',', $this->allowed_days), explode(',', $this->rewards_percentage));

        return [
            'id' => $this->id,
            'currency' => $this->currency->name,
            'currency_symbol' => $this->currency->symbol,
            'currency_logo' => url($this->currency->file->path),
            'allowed_days' => $this->allowed_days,
            'rewards_percentage' => $this->rewards_percentage,
            'min_amount' => $this->min_amount,
            'max_amount' => $this->max_amount,
            'ranges' => $ranges,
            'status' => $this->status,
            'created_at' => $this->created_at->format('d-m-Y H:i'),
        ];
    }
}
