| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use Yii;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- /**
- * This is the model class for table "{{%erp_purchase}}".
- *
- * @property integer $id
- */
- class ErpPurchase extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%erp_purchase}}';
- }
-
- public static function saveList($order_id, $purchase) {
- foreach($purchase as $item){
- $model = new ErpPurchase();
- $model->inventory_id = $item['id'];
- $model->num = $item['num'];
- $model->purchase_order_id = $order_id;
- if (!$model->save()) {
- \Yii::error([__METHOD__, $model->attributes]);
- throw new \Exception(array_shift($model->getFirstErrors()));
- }
- }
- }
- }
|