There are two tables:

serial=>id, name_serial, created_at; films=>id, name_films, created_at,id_serial; 

Tables are related to each other in models, and serial is also associated with the model image

Serial:

 public function getFilms(){ return $this->hasMany(Films::className(),['id_serial'=>'id']); } public function getImages(){ return $this->hasMany(Image::className(), [ 'id_serial'=>'id' ]); } 

Films:

 public function getSerial() { return $this->hasOne(Serial::className(), ['id'=>'id_serial']); } 

I need to output the data from both tables by the date ( created_at ) so that I could then use the links for example so that when I output the Film I can then get an Image from the Serial like so $films->serial->images and s erial->image serial->films

    1 answer 1

     $films = Films::find()->orderBy(['created_at' => SORT_DESC])->all(); 

    similar to TV shows