public function up() { foreach ($this->getRoles() as $role) { $this->insert(AuthItem::tableName(), ['name' => $role, 'type' => \yii\rbac\Item::TYPE_ROLE]); } return $this->insert(AuthItemChild::tableName(), ['parent' => AuthItem::ROLE_ROOT, 'child' => AuthItem::ROLE_GUEST]); }
public function up() { foreach ($this->getPermissions() as $role => $permissions) { foreach ($permissions as $permission) { try { $this->insert(AuthItem::tableName(), ['name' => $permission, 'type' => \yii\rbac\Item::TYPE_PERMISSION]); } catch (Exception $e) { } try { $this->insert(AuthItemChild::tableName(), ['parent' => $role, 'child' => $permission]); } catch (Exception $e) { } } } return true; }