/**
  * Creates a new JackpotDetails model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     die("dsfsad");
     $country = '';
     //Yii::$app->customFun->prx("JackpotDetails");
     $data = Yii::$app->request->post("JackpotDetails");
     if (isset($data)) {
         //Yii::$app->customFun->prx($data);
         $country = \app\models\Country::find()->innerJoinWith('continents', false)->filterWhere(['name' => null, 'continents.id' => $data["continent"]])->all();
     }
     $model = new JackpotDetails();
     $continent = \app\models\Continents::find()->innerJoinWith('country', false)->all();
     //Yii::$app->customFun->prx($continent);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'continents' => $continent, 'country' => $country]);
     }
 }
Example #2
0
 public function getContinents()
 {
     return $this->hasOne(Continents::className(), ['code' => 'continent']);
 }
Example #3
0
use app\models\Continents;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model app\models\Country */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="country-form">

    <?php 
$form = ActiveForm::begin();
?>
    
    <?php 
//use app\models\Country;
$continents = Continents::find()->all();
// Yii::$app->customFun->prx($continents);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
$continentData = ArrayHelper::map($continents, 'id', 'name');
?>
    <?php 
echo $form->field($model, 'continents_id')->dropDownList($continentData, ['prompt' => 'Select...']);
?>

    <div class="form-group">
 /**
  * Updates an existing JackpotDetails model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $uploadDir = Yii::getAlias('@upload_DIR');
     $continent = \app\models\Continents::find()->innerJoinWith('countryList', false)->all();
     /**/
     $country = \app\models\Countries::find()->innerJoinWith('continentCode', false)->filterWhere(['name' => null, 'continents.code' => $model->continent])->asArray()->all();
     //  Yii::$app->customFun->prx($country);
     if (Yii::$app->request->isPost) {
         $jackpot_section_image = time() . '_' . $_FILES['JackpotDetails']['name']['jackpot_section_image'];
         $file = UploadedFile::getInstance($model, 'jackpot_section_image');
         if (is_object($file) && $file->size !== 0) {
             $file->name = time() . '_' . $file->name;
         }
         if (is_object($file) && $file->size !== 0) {
             $extensionFile = substr(strstr($file->name, "."), 1);
             if (!in_array($extensionFile, $this->extensions)) {
                 Yii::$app->getSession()->setFlash('error', 'Only jpg, jpeg and png files are allowed to upload.');
                 return $this->redirect(array('/jackpot-section/update', 'id' => $id));
             }
             $model->UpdateJackpotSection($file, $uploadDir, $jackpot_section_image, $model);
             $model->UpdateJackpotImage($jackpot_section_image, $model);
         } else {
             $jackpot_section_image = $model::findone($id)->jackpot_section_image;
             // $model->UpdateJackpotImage($file,$model);
         }
         // $model->jackpot_section_image = $file;
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         // if (!is_object($file)){
         $model->UpdateJackpotImage($jackpot_section_image, $model);
         // }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'continents' => $continent, 'country' => $country]);
     }
 }
 /**
  * Finds the Continents model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Continents the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Continents::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }