models/Blog.php
/**
     * Before save event handler
     * @param bool $insert
     * @return bool
     */
Before save event handler
@param bool $insert
@return bool
Before save event handler @param bool $insert @return bool
public function beforeSave ($insert)
    {
        if (parent::beforeSave($insert))
        {
            $this->user_id = Yii::$app->user->id;
            if(empty($this->imageFile))
                unset($this->imageFile);
            return true;
        }
        return false;
    }
public function beforeSave ( $ insert ) { if ( parent :: beforeSave ( $ insert ) ) { $ this -> user_id = Yii :: $ app -> user -> id ; if ( empty ( $ this -> imageFile ) ) unset ( $ this -> imageFile ) ; return true ; } return false ; }
Before save event handler
 @param bool $insert
 @return bool
Before save event handler @param bool $insert @return bool