<?php

namespace RadiusTheme\RadiusBooking\Resources;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
use RadiusTheme\RadiusBooking\Abstracts\BaseResource;
use RadiusTheme\RadiusBooking\Repositories\LocationRepository;

/**
 * Api/Resources/LocationResource.php
 * Location resource transformer
 *
 * @package RadiusTheme\RadiusBooking\Resources
 */
class LocationResource extends BaseResource {

	/**
	 * Transform a Location model into an API-friendly array.
	 *
	 * @param object $location The Location model instance.
	 *
	 * @return array Transformed data.
	 */
	public function transform( $location ): array {
		return array(
			'id'                => $location->id,
			'name'              => $location->name,
			'description'       => $location->description,
			'address'           => $location->address,
			'latitude'          => $location->latitude,
			'longitude'         => $location->longitude,
			'phone'             => $location->phone,
			'image_id'          => $location->image_id,
			'picture_full_path' => ( new LocationRepository() )->getImageUrl( $location->id ),
			'status'            => $location->status,
			'created_at'        => $location->created_at,
			'updated_at'        => $location->updated_at,
		);
	}
}
