owner; return $owner->hasOne($this->model, $this->links); } /** * All images query * * @return \yii\db\ActiveQuery */ public function getImages() { /** * @var ActiveRecord $owner */ $owner = $this->owner; return $owner->hasMany($this->model, $this->links); } /** * Get images config array for FileInput * * @return array */ public function getImagesConfig() { $op = []; $images = $this->getImages()->all(); $config = $this->config; if(!isset( $config[ 'id' ] )) { return $op; } foreach($images as $image) { $op[] = [ 'caption' => ( isset( $config[ 'caption' ] ) ) ? $image->{$config[ 'caption' ]} : '', 'url' => ( isset( $config[ 'delete_action' ] ) ) ? Url::to([ $config[ 'delete_action' ], 'id' => $image->{$config[ 'id' ]}, ]) : '', 'key' => $image->{$config[ 'id' ]}, 'extra' => [ 'id' => $image->{$config[ 'id' ]}, ], ]; } return $op; } /** * Get images HTML * * @param string $preset * * @return array */ public function getImagesHTML($preset = 'admin_thumb') { $op = []; $images = $this->getImages()->all(); foreach($images as $image) { $op[] = ArtboxImageHelper::getImage($image->imageUrl, $preset); } return $op; } }