35 lines
899 B
PHP
35 lines
899 B
PHP
<?php
|
|
|
|
namespace App\View\Components;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\View\Component;
|
|
|
|
class LastFMCurrent extends Component {
|
|
public $track;
|
|
public $artUrl;
|
|
/**
|
|
* Create a new component instance.
|
|
*/
|
|
public function __construct($track) {
|
|
$this->track = $track;
|
|
if (isLegacy()) {
|
|
$path = parse_url($track["image"], PHP_URL_PATH);
|
|
if ($track["image"] === "") {
|
|
$this->artUrl = null;
|
|
} else {
|
|
$this->artUrl = "//" . request()->getHttpHost() . "/proxy/lastfm/" . basename($path);
|
|
}
|
|
} else {
|
|
$this->artUrl = $track["image"];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the view / contents that represent the component.
|
|
*/
|
|
public function render(): View|Closure|string {
|
|
return view('components.lastfm-current');
|
|
}
|
|
}
|