title: Foreach loop display data in main
body: <p>I am working with a foreach loop and I want to make some banners in </p>
  
  <blockquote>
    <p>frontend/layouts/main</p>
  </blockquote>
  
  <p>I created a model where I have these static functions:</p>
  
  <pre><code>public static function getUrl() {
      return Banner::find()-&gt;where(['Rel_User' =&gt; Yii::$app-&gt;user-&gt;identity-&gt;Id])-&gt;all();
  }
  
  public static function getImage() {
      return Yii::$app-&gt;basePath . '/web/' . $this-&gt;Image;
  }
  </code></pre>
  
  <p>And I want to display this URL in my main:</p>
  
  <pre><code>&lt;?php foreach (Banner::getUrl() as $key): ?&gt;
  
      &lt;div class="banner"&gt;
          &lt;a href="&lt;?= $key['Url'] ?&gt;" title=""&gt;
              &lt;img src="&lt;?=Url::base(true)?&gt;/img/banner.jpg" alt=""&gt;&lt;/a&gt;
      &lt;/div&gt;
  &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>The problem is that I have 3 banners assigned to the logged user and this loop displays only one banner. What did I do wrong? My second question is, what should I do to display only the URL from my database, because now the URL looks like: </p>
  
  <pre><code>http://my-page.frontend.localhost/www.google.com
  </code></pre>
  
  <p>but in my database it is: </p>
  
  <pre><code>url= www.google.com
  </code></pre>