123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\common\model;
- use think\Model;
- class GoodsInstall extends Model
- {
- protected $type=[
- 'fee'=>'json',
- ];
- protected $autoWriteTimestamp=true;
- public function link(){
- return $this->hasMany(GoodsInstallLink::class);
- }
- public function getFee($num){
- foreach ($this['fee'] as $fee){
- if($num>=$fee['num_min'] && $num<$fee['num_max']){
- return $fee['amount'];
- }
- }
- return 0;
- }
- public static function init()
- {
- self::afterDelete(function (self $goodsInstall){
- $goodsInstall->link()->delete();
- });
- }
- }
|