controllers/ChoferController.php
/**
     * Creates a new Chofer model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Chofer model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Chofer model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new Chofer();
        $modelEmpresachofer = new Empresachofer();
        if ($model->load(Yii::$app->request->post()) && $modelEmpresachofer->load(Yii::$app->request->post())) {
            $model->file = UploadedFile::getInstance($model, 'file');
            $model->file2 = UploadedFile::getInstance($model, 'file2');
            $model->file3 = UploadedFile::getInstance($model, 'file3');
            if(!empty($model->file)) {
            $model->file->saveAs('certificados/' .$model->CEDULA . '.' . $model->file->extension);
            $model->IMG_CERTIFICADO = 'certificados/' .$model->CEDULA . '.' . $model->file->extension;
            }
           if(!empty($model->file2)) {
            $model->file2->saveAs('cedulas/' .$model->CEDULA. '.' . $model->file2->extension);
            $model->IMG_CEDULA = 'cedulas/' .$model->CEDULA . '.' . $model->file2->extension;
            }
            if(!empty($model->file3)) {
            $model->file3->saveAs('licencias/' .$model->CEDULA . '.' . $model->file3->extension);
            $model->IMG_LICENCIA = 'licencias/' .$model->CEDULA . '.' . $model->file3->extension;
            }
                $model->save(false);
                l->ID);die;
                $modelEmpresachofer->CHOFER_ID = $model->ID;
                lEmpresachofer->EMPRESA_ID);die;
                $modelEmpresachofer->EMPRESA_ID = $modelEmpresachofer->EMPRESA_ID;
                $modelEmpresachofer->save();
            return $this->redirect(['view', 'id' => $model->ID]);
        } else {
            return $this->render('create', [
                'model' => $model,
                'modelEmpresachofer' => $modelEmpresachofer,
            ]);
        }
    }
public function actionCreate ( ) { $ model = new Chofer ( ) ; $ modelEmpresachofer = new Empresachofer ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ modelEmpresachofer -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ model -> file = UploadedFile :: getInstance ( $ model , 'file' ) ; $ model -> file2 = UploadedFile :: getInstance ( $ model , 'file2' ) ; $ model -> file3 = UploadedFile :: getInstance ( $ model , 'file3' ) ; if ( ! empty ( $ model -> file ) ) { $ model -> file -> saveAs ( 'certificados/' . $ model -> CEDULA . '.' . $ model -> file -> extension ) ; $ model -> IMG_CERTIFICADO = 'certificados/' . $ model -> CEDULA . '.' . $ model -> file -> extension ; } if ( ! empty ( $ model -> file2 ) ) { $ model -> file2 -> saveAs ( 'cedulas/' . $ model -> CEDULA . '.' . $ model -> file2 -> extension ) ; $ model -> IMG_CEDULA = 'cedulas/' . $ model -> CEDULA . '.' . $ model -> file2 -> extension ; } if ( ! empty ( $ model -> file3 ) ) { $ model -> file3 -> saveAs ( 'licencias/' . $ model -> CEDULA . '.' . $ model -> file3 -> extension ) ; $ model -> IMG_LICENCIA = 'licencias/' . $ model -> CEDULA . '.' . $ model -> file3 -> extension ; } $ model -> save ( false ) ; $ modelEmpresachofer -> CHOFER_ID = $ model -> ID ; $ modelEmpresachofer -> EMPRESA_ID = $ modelEmpresachofer -> EMPRESA_ID ; $ modelEmpresachofer -> save ( ) ; return $ this -> redirect ( [ 'view' , 'id' => $ model -> ID ] ) ; } else { return $ this -> render ( 'create' , [ 'model' => $ model , 'modelEmpresachofer' => $ modelEmpresachofer , ] ) ; } }
Creates a new Chofer model.
Creates a new Chofer model .
/*$model = new Chofer();

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->ID]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }*/ //$file = $model->file; //var_dump($mode //l);die; //if($model->save()){ //var_dump($model->ID);die; //var_dump($modelEmpresachofer->EMPRESA_ID);die; //  /*Yii::$app->getSession()->setFlash('success', [
                'type' => Growl::TYPE_SUCCESS,
                'icon' => 'fa fa-users',
                'message' => Html::encode('La Lista ha sido creada exitósamente'),
                'title' => Html::encode('Resultado'),
                'showSeparator' => true,
                    
            ]);*/ //}