controllers/PostController.php
/**
     * Creates a new Post model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Post model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Post model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $modelPost = new Post;
        $modelPostInQueue = new PostInQueue;
        $modelsForm = Post::getForms();  
        $form_status = 0;
        if ($modelPost->load(Yii::$app->request->post()) && $modelPost->save()){                                    
            $modelPostInQueue->post_id = $modelPost->id;            
            $modelsForm[$modelPost->type]->post_id = $modelPost->id;                          
            if ($modelPostInQueue->load(Yii::$app->request->post()) && $modelPostInQueue->save()){
                $result['piq'] = 1;
            }
            else{
                $result['piq'] = 0;
            }                        
            if ($modelsForm[$modelPost->type]->load(Yii::$app->request->post()) && $modelsForm[$modelPost->type]->save()){                    
                $result['form'] = 1;
            }            
            else{
                $result['form'] = 0;
            }
            if (count($result) == array_sum($result)){
                $modelPostInQueue->sendPost();
                $modelPost = new Post;
                $modelPostInQueue = new PostInQueue;
                $modelsForm = Post::getForms();  
                $form_status = 1;                
            }            
        }                  
        return $this->render('create', [
            'modelPost' => $modelPost,
            'PostInQueue' => $modelPostInQueue,
            'modelsForm' => $modelsForm,
            'forms' => $this->getForms($modelsForm),
            'attr_exceptions' => $this->getAttributeExceptions(),
            'form_status' => $form_status,
        ]);
    }
public function actionCreate ( ) { $ modelPost = new Post ; $ modelPostInQueue = new PostInQueue ; $ modelsForm = Post :: getForms ( ) ; $ form_status = 0 ; if ( $ modelPost -> load ( Yii :: $ app -> request -> post ( ) ) && $ modelPost -> save ( ) ) { $ modelPostInQueue -> post_id = $ modelPost -> id ; $ modelsForm [ $ modelPost -> type ] -> post_id = $ modelPost -> id ; if ( $ modelPostInQueue -> load ( Yii :: $ app -> request -> post ( ) ) && $ modelPostInQueue -> save ( ) ) { $ result [ 'piq' ] = 1 ; } else { $ result [ 'piq' ] = 0 ; } if ( $ modelsForm [ $ modelPost -> type ] -> load ( Yii :: $ app -> request -> post ( ) ) && $ modelsForm [ $ modelPost -> type ] -> save ( ) ) { $ result [ 'form' ] = 1 ; } else { $ result [ 'form' ] = 0 ; } if ( count ( $ result ) == array_sum ( $ result ) ) { $ modelPostInQueue -> sendPost ( ) ; $ modelPost = new Post ; $ modelPostInQueue = new PostInQueue ; $ modelsForm = Post :: getForms ( ) ; $ form_status = 1 ; } } return $ this -> render ( 'create' , [ 'modelPost' => $ modelPost , 'PostInQueue' => $ modelPostInQueue , 'modelsForm' => $ modelsForm , 'forms' => $ this -> getForms ( $ modelsForm ) , 'attr_exceptions' => $ this -> getAttributeExceptions ( ) , 'form_status' => $ form_status , ] ) ; }
Creates a new Post model.
Creates a new Post model .