芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/xmintal-back/models/Customerpayment.php
20], [['amount'],'number','min'=>0], [['reference'], 'string', 'max' => 50] ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'customer_id' => 'Customer ID', 'contract_id' => 'Contract ID', 'amount' => 'Amount', 'payment_date' => 'Payment Date', 'validity_start_date' => 'Validity Start Date', 'validity_end_date' => 'Validity End Date', 'payment_method' => 'Payment Method', 'reference' => 'Reference', ]; } public function beforeValidate() { if (parent::beforeValidate()) { if($this->isNewRecord){ if(!$this->payment_date){ $this->payment_date=date('Y-m-d H:i:s'); $this->validity_start_date=date('Y-m-d H:i:s',strtotime($this->validity_start_date)); $this->validity_end_date=date('Y-m-d',strtotime('+1 month',strtotime($this->validity_start_date))); } } return true; } return false; } /** * Gets query for [[Customer]]. * * @return \yii\db\ActiveQuery */ public function getCustomer() { return $this->hasOne(Customer::class, ['id' => 'customer_id']); } public function getPaymentservices() { return $this->hasMany(PaymentService::class,['payment_id'=>'id']); } public function getContract(){ return $this->hasOne(Contract::class,['id'=>'contract_id']); } }