@blazert

Как вывести картинку из url?

Всем добрый вечер, не могу получить картинку из URL
Так я получаю просто appid и название игры
@foreach($account->OwnedGames as $game)
<option  value="{{$game->appId}}">{{$game->name}} </option>
@endforeach

62acc95ad68b0446272814.png

Когда вызываю так {{$game->icon}} то получаю URL, но не саму картинку
@foreach($account->OwnedGames as $game)
<option  value="{{$game->appId}}">{{$game->name}}{{$game->icon}}</option>
@endforeach

62acc944ab517391460604.png
class Game
<?php

namespace Syntax\SteamApi\Containers;

class Game extends BaseContainer
{
    public $appId;
    public $name;
    public $playtimeTwoWeeks;
    public $playtimeTwoWeeksReadable;
    public $playtimeForever;
    public $playtimeForeverReadable;
    public $icon;
    public $logo;
    public $header;
    public $hasCommunityVisibleStats;
    public function __construct($app)
    {
        $this->appId                    = $app->appid;
        $this->name                     = $this->checkIssetField($app, 'name');
        $this->playtimeTwoWeeks         = $this->checkIssetField($app, 'playtime_2weeks', 0);
        $this->playtimeTwoWeeksReadable = $this->convertFromMinutes($this->playtimeTwoWeeks);
        $this->playtimeForever          = $this->checkIssetField($app, 'playtime_forever', 0);
        $this->playtimeForeverReadable  = $this->convertFromMinutes($this->playtimeForever);
        $this->icon                     = $this->checkIssetImage($app, 'img_icon_url');
        $this->logo                     = $this->checkIssetImage($app, 'img_logo_url');
        $this->header                   = 'http://cdn.akamai.steamstatic.com/steam/apps/' . $this->appId . '/header.jpg';
        $this->hasCommunityVisibleStats = $this->checkIssetField($app, 'has_community_visible_stats', 0);
    }

    protected function checkIssetImage($app, $field, $value = null)
    {
        return isset($app->$field) ? $this->getImageForGame($app->appid, $app->$field) : $value;
    }

    protected function getImageForGame($appId, $hash)
    {
        if ($hash != null) {
            return 'http://media.steampowered.com/steamcommunity/public/images/apps/' . $appId . '/' . $hash . '.jpg';
        }

        return null;
    }
}

Использую laravel9 + adminlte

require: "syntax/steam-api": "dev-laravel9"
  • Вопрос задан
  • 95 просмотров
Решения вопроса 1
@lil_koi
лучший из худших
@foreach($account->OwnedGames as $game)
<img src="{{$game->icon}}">
@endforeach

а как вставить картинку в select нужно погуглить
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы