CostaRico / yii2-images

Yii2-images - behavior-based module for resizing, storing, caching and attaching images.
160 stars 98 forks source link

Error for save the model where in tables primary key not ID #62

Closed AlienMans closed 7 years ago

AlienMans commented 7 years ago

Для таблиц в базе данных для которых модели созданы с первичным ключом отличным от ID метод getModelSubDir не может вернуть правильное значение.

Решение проблемы в файле Module,php строка 82

$modelDir = \yii\helpers\Inflector::pluralize($modelName).'/'. $modelName . $model->getTableSchema()->primaryKey;

AlienMans commented 7 years ago

Точнее проблема решена так: $tbl_primaryKey = $model->getTableSchema()->primaryKey[0]; $modelDir = \yii\helpers\Inflector::pluralize($modelName).'/'. $modelName . $model->$tbl_primaryKey;

CostaRico commented 7 years ago

Добрый день, если сделаете пулл реквест – проакцептю.

mailamir commented 6 years ago

Достаточно добавить

public function getId() { return $this::findOne(['user_id' => $this->user_id])->user_id; }