1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace app\data\model;
- use app\data\model\helpers\PurchaseOrderId;
- use think\admin\Model;
- class ShopProductionOffer extends Model
- {
- use PurchaseOrderId;
- protected $type=[
- 'images'=>'array',
- ];
- public static function onBeforeWrite(self $model)
- {
- if(empty($model['amount'])||$model['amount']==0){
- $model['amount']=null;
- }
- }
- public static function onAfterDelete(self $model): void
- {
- $model->amounts()->delete();
- }
- public function amounts(){
- return $this->hasMany(ShopProductionOfferAmount::class,'offer_id');
- }
- public function user(){
- return $this->belongsTo(DataUser::class,'user_id');
- }
- public function production(){
- return $this->belongsTo(ShopProduction::class,'production_id');
- }
- }
|