I've 2 tables (sliders, images) related with junction (sliders_images) table, the relation work fine but I nedd to get related data with specific order, the attribute that define the right order is in the junction table, the relation is defined as:
public function getImages(){
return $this->hasMany(Images::className(), ['id' => 'image_id'])
->viaTable('sliders_images', ['slider_id' => 'id'], function($query){
$query->orderBy('sliders_images.display_order ASC');
});
}
when i call $model->images
I receive the correct images but the wrong order, using foreach the images was ordered by id, how i can get the images ordered by other attribute?