backend/controllers/MenusController.php
/**
     * Creates a new Menus model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Menus model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Menus model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $userId = Yii::$app->user->identity->id;
        $restaurant = Restaurant::findBySql("SELECT * FROM restaurant WHERE restaurantId = (SELECT restaurantId FROM staff WHERE userId = $userId)")->all();
        $restaurant = $restaurant[0];
        $menu = new Menus();
        $menu->restaurantId = $restaurant->restaurantId;
        $menu->date = date("Y-m-d");
        if($menu->validate()){
            $menu->save();
            return $this->redirect(['view', 'id' => $menu->menuId]);
        }
        else{
            return $this->redirect(['index']);
        }
    }
public function actionCreate ( ) { $ userId = Yii :: $ app -> user -> identity -> id ; $ restaurant = Restaurant :: findBySql ( " SELECT * FROM restaurant WHERE restaurantId = (SELECT restaurantId FROM staff WHERE userId =  $ userId ) " ) -> all ( ) ; $ restaurant = $ restaurant [ 0 ] ; $ menu = new Menus ( ) ; $ menu -> restaurantId = $ restaurant -> restaurantId ; $ menu -> date = date ( " Y-m-d " ) ; if ( $ menu -> validate ( ) ) { $ menu -> save ( ) ; return $ this -> redirect ( [ 'view' , 'id' => $ menu -> menuId ] ) ; } else { return $ this -> redirect ( [ 'index' ] ) ; } }
Creates a new Menus model.
Creates a new Menus model .