This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
site-base/spark/src/InteractsWithSparkApi.php
2017-11-03 16:26:07 +11:00

34 lines
783 B
PHP

<?php
namespace Laravel\Spark;
use Illuminate\Support\Str;
use GuzzleHttp\Client as HttpClient;
trait InteractsWithSparkApi
{
/**
* Get the latest Spark release version.
*
* @param string|null $major
* @return string
*/
protected function latestSparkRelease($major = null)
{
$response = json_decode((string) (new HttpClient)->get(
$this->sparkUrl.'/api/releases/all-versions'
)->getBody());
return collect($response)->filter(function ($version) use ($major) {
return ! $major || Str::startsWith($version, $major);
})->sort('version_compare')->last();
}
/**
* The Spark base URL.
*
* @var string
*/
protected $sparkUrl = 'https://spark.laravel.com';
}