title: How can show parents name on Yii2
body: <p>How can show parents name on Yii2.</p>
  
  <p>This is my work-</p>
  
  <p>I want to show state name which is situated state id like as 1, District is child table name, where is foreign key state_id, i want to replace state_name where is situated state_id.</p>
  
  <p>This is my sql- </p>
  
  <pre><code>CREATE TABLE district (
  district _id int(11) NOT NULL AUTO_INCREMENT,
  state_id int(11) NOT NULL COMMENT 'FK',
  district_name varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (district _id),
  FOREIGN KEY (state_id) REFERENCES state (state_id)
  );
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/t8Gd3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t8Gd3.png" alt="This is my work- i want to show state name which is situated state id like as 1 "></a></p>
  
  <p>My controller-</p>
  
  <pre><code>$district= District::find()-&gt;all();
  </code></pre>
  
  <p>View-</p>
  
  <pre><code>&lt;?php
  foreach($district as $districtt)
  {
  ?&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;?= $districtt-&gt;state_id ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?= $districtt-&gt;districtt_name ?&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;?php
  }
  ?&gt;
  </code></pre>