Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function setMain() on null. #60

Open
Batisska opened this issue Mar 6, 2017 · 0 comments
Open

Call to a member function setMain() on null. #60

Batisska opened this issue Mar 6, 2017 · 0 comments

Comments

@Batisska
Copy link

Batisska commented Mar 6, 2017

Доброй ночи.

Пытаюсь сохранить картинку.

if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->img = UploadedFile::getInstance($model, 'img');
if ($model->img){
$path = Yii::getAlias('@webroot/uploads/boats/').$model->img->baseName.'.'.$model->img->extension;
$model->img->saveAs($path);
$model->attachImage($path,true);
}
return $this->redirect(['index','id'=> $model->id ]);
}

Выдает вот такую ошибку.

in D:\OpenServer\domains\kater\vendor\costa-rico\yii2-images\behaviors\ImageBehave.php at line 139
130131132133134135136137138139140141142143144145146147148
$images = $this->owner->getImages();
foreach ($images as $allImg) {

        if ($allImg->id == $img->id) {
            continue;
        } else {
            $counter++;
        }

        $allImg->setMain(false);
        $allImg->urlAlias = $this->getAliasString() . '-' . $counter;
        $allImg->save();
    }

    $this->owner->clearImagesCache();
}

/**
 * Clear all images cache (and resized copies)> 

При этом картинку сохраняет.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant