CreateBatch.php 853 Bytes
<?php

namespace domain\device;

use Yii;
use domain\device\models\CreateBatch as CreateBatchModel;

class CreateBatch
{
    /**
     * @param $item
     * @return null|object
     * @throws \yii\base\InvalidConfigException
     */
    static function create($item)
    {
        $createBatch = Yii::createObject([
            'class'             => CreateBatchModel::className(),
            'batch_no'          => $item['batch_no'],
            'manufacture_id'    => $item['manufacture_id'],
            'project_id'        => $item['project_id'],
            'model_id'          => $item['model_id'],
            'num'               => $item['num'],
            'production_id'     => $item['production_id'],
        ]);
        if ($createBatch->save()) {
            return $createBatch;
        } else {
            return null;
        }
    }
}