Answer the question
In order to leave comments, you need to log in
How to get rid of Invalid argument supplied for foreach error in yii2?
I welcome everyone.
I don’t know where to write anymore, no one knows ;(
The third day I’m struggling with the error:
I use this extension https://github.com/creocoder/yii2-nested-sets
There were no problems for Yii1. I
did everything strictly according to the manual, but it crashes error
full screenshot size: https://yadi.sk/d/HtM4ECmRjewsY
Moreover, this error occurs on any access to the Categories table , if I remove the behavior, then the object comes in.
i.e. I do $roots = Categories::find()- >roots()->all() ;
Error.Categories
model
<?php
namespace backend\models;
use creocoder\nestedsets\NestedSetsBehavior;
use yii\db\ActiveRecord;
class Categories extends ActiveRecord
{
public function behaviors() {
return [
'tree' => [
'class' => NestedSetsBehavior::className(),
'treeAttribute' => 'tree',
],
];
}
public function transactions()
{
return [
self::SCENARIO_DEFAULT => self::OP_ALL,
];
}
public static function find()
{
return new CategoryQuery(get_called_class());
}
}
<?php
namespace backend\models;
use creocoder\nestedsets\NestedSetsQueryBehavior;
use yii\db\ActiveRecord;
class CategoryQuery extends ActiveRecord
{
public function behaviors() {
return [
NestedSetsQueryBehavior::className(),
];
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question