<?php
namespace App\Services\Generators;
use Illuminate\Support\Facades\Storage;
use App\Models\Quote;

class KmlGenerator {
	public static function generate(Quote $quote, array $data = [], string $kmlname = '', bool $force = false): array {
		$path = "quotes/{$quote->id}/kml.kml";
		if(!$force && Storage::exists($path)) return [0, Storage::get($path)];

		$pushpin = $data['center'];

		$x = view('mail.foreflight', [
			'sitename' => $kmlname,
			'lat' => $data['center']['lat'],
			'lon' => $data['center']['lon'],
			'bearing' => $data['bearing'],
			'distance' => $data['distance']
			])->render();
		Storage::put($path, $x);
		return [1, $x];
		}
	}
