/** * Deletes all menu items assigned to the App * * * @param integer $appId * @throws \Exception */ public function deleteAppMenuItems($appId) { /** @var MenuItem[] $menusList */ // 1 - we get all the menus connected to the App $menusList = MenuItem::find()->joinWith('appConnections', FALSE)->where(['app_id' => $appId])->all(); foreach ($menusList as $menuItem) { $menuItem->delete(); } AppConnections::deleteAll(['app_id' => $appId, 'type' => MenuItem::className()]); }
private function tableName() { return '{{%' . MenuItem::tableName() . '}}'; }
public function show_menu_item($name) { MenuItem::updateAll(['visible' => 1], ['name' => $name]); }
/** * Retrieves all the Configs assigned to the filtered Apps using AppConnections * as junction table. * * @return \yii\db\ActiveQuery */ public function getApp() { return $this->hasOne(App::className(), ['id' => 'app_id'])->via('appConnections', function ($query) { $query->where(['type' => \cyneek\yii2\menu\models\MenuItem::className()]); }); }