芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/xmintal-back/models/CustomerLicense.php
10], [['mac_address', 'license_key'], 'string', 'max' => 80], [['device_name'], 'string', 'max' => 150], [['customer_id'], 'exist', 'skipOnError' => true, 'targetClass' => Customer::class, 'targetAttribute' => ['customer_id' => 'id']], [['license_id'], 'exist', 'skipOnError' => true, 'targetClass' => License::class, 'targetAttribute' => ['license_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'license_id' => 'Tipo de licencia', 'customer_id' => 'Cliente', 'price' => 'Precio', 'month_duration' => 'Duración en meses', 'mac_address' => 'Dirección MAC', 'license_key' => 'License Key', 'device_name' => 'Device Name', ]; } /** * Gets query for [[Customer]]. * * @return \yii\db\ActiveQuery */ public function getCustomer() { return $this->hasOne(Customer::class, ['id' => 'customer_id']); } /** * Gets query for [[License]]. * * @return \yii\db\ActiveQuery */ public function getLicense() { return $this->hasOne(License::class, ['id' => 'license_id']); } public function getCurrentpayment(){ $now=date('Y-m-d'); $current=Payment::find() ->where(['customerlicense_id'=>$this->id]) ->andWhere(['<=', 'DATE_FORMAT(validity_start_date,"%Y-%m-%d")', $now]) ->andWhere(['>=', 'DATE_FORMAT(validity_end_date,"%Y-%m-%d")', $now]) ->one(); return $current; } public function getLastpayment(){ $last=Payment::find() ->where(['customerlicense_id'=>$this->id]) ->orderBy('id DESC') ->one(); return $last; } /** * Gets query for [[Payments]]. * * @return \yii\db\ActiveQuery */ public function getPayments() { return $this->hasMany(Payment::class, ['customerlicense_id' => 'id']); } }