Exception
Serialization of 'Closure' is not allowed
Код: Выделить всё
public function afterSave($insert, $changedAttributes)
{
$lastPost = self::find()->with(['parent'])->where(['status' => self::STATUS_ACTIVE, 'main' => 1])- >orderBy('id DESC')->limit(5)->all();
if (!empty($lastPost)) {
Yii::$app->cache->set('lastPost', $lastPost, 0);
} else {
Yii::$app->cache->delete('lastPost');
}
parent::afterSave($insert, $changedAttributes);
}