hasMany(ExpositionsObjects::class, ['object_id' => 'id']); } public function isInExposition($exposition_id) { if ($exposition_id) { $exists = $this->hasMany(ExpositionsObjects::class, ['object_id' => 'id'])->where(['exposition_id' => $exposition_id])->exists(); return $exists; } return false; } public function getRegisterObjectFields() { return $this->hasMany(RegisterObjectFields::class, ['object_id' => 'id']); } public function getRegisterObjectFiles() { return $this->hasMany(RegisterObjectFiles::class, ['object_id' => 'id']); } public function getMainImgFile() { if ($this->object_thumbnail_url) return $this->object_thumbnail_url; /** @var \app\models\RegisterObjectFiles $file */ $file = $this->hasMany(RegisterObjectFiles::class, ['object_id' => 'id']) ->where(['is_thumbnail' => 1]) ->orWhere(['extension' => 'jpg']) ->orWhere(['extension' => 'jpeg']) ->orWhere(['extension' => 'png']) ->one(); if ($file) return $file->file_url; } public function getPartner() { return $this->hasOne(RegisterPartner::class, ['id' => 'partner_id']); } public function getCity() { return $this->hasOne(CityList::class, ['id' => 'city_id']); } public function getCollectionsObject() { return $this->hasMany(CollectionsObjects::class, ['object_id' => 'ref_num']); } public function getCollectionsListStr() { $collections = []; /** @var CollectionsObjects $collectionObject */ foreach ($this->collectionsObject as $collectionObject) { if ($collectionObject->collection) $collections[] = $collectionObject->collection->name; } return implode(',', $collections); } public function getUrl() { return '/admin-global/web-portal/objects-register/?o=w&id=' . $this->id; } public function isAddedToExposition($id) { if ($this->isInExposition($id)) return '