Esempio n. 1
0
 public static function find()
 {
     return parent::find()->where([Sale::tableName() . '.isdel' => 0])->andWhere(Order::tableName() . ".isdel = 0");
 }
 /**
  * Finds the Sale model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Sale the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Sale::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 3
0
 public function deleteSales()
 {
     $res = true;
     $sales = Sale::findAll(['order_id' => $this->id]);
     foreach ($sales as $sale) {
         $sale->isdel = 1;
         if (!$sale->save()) {
             $res = false;
         }
     }
     return $res;
     //return $sale = Sale::deleteAll(['order_id'=>$this->id]);
 }
Esempio n. 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSales()
 {
     return $this->hasMany(Sale::className(), ['product_id' => 'id'])->where("isdel=0");
 }