<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class LocationsWorkflowResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'location_name' => $this->locations->storage_location_name,
            'location_code' => $this->storage_location_code,
            'status' => $this->show_status($this->counting_status),
        ];
    }

    private function show_status($status)
    {
        if ($status == 'active') {
            return 'Counting in progress';
        } elseif ($status == 'repeat') {
            return 'Counting on repeat mode';
        } elseif ($status == 'inactive') {
            return 'Counting yet to start';
        } elseif ($status == 'closed') {
            return 'Counting closed';
        }
    }
}