123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace app\common\model;
- class Io extends Base
- {
- protected $schema = [
- 'id' => 'int',
- 'repo_id' => 'int',
- 'create_time' => 'datetime',
- 'update_time' => 'datetime',
- 'delete_time' => 'datetime',
- 'date' => 'date',
- 'type' => 'tinyint',
- 'remark' => 'varchar',
- 'sn' => 'varchar',
- 'admin_id' => 'int',
- 'change_type' => 'tinyint',
- 'source' => 'varchar',
- 'revert_id' => 'int'
- ];
-
- const TYPE_IN = 1;
-
- const TYPE_OUT = 2;
-
-
- const CHANGE_TYPE_IO = 1;
-
- const CHANGE_TYPE_ALLOCATION = 2;
-
- const CHANGE_TYPE_CHECK = 3;
- const CHANGE_TYPE_MAP = [
- self::CHANGE_TYPE_IO => ['text' => '出入库'],
- self::CHANGE_TYPE_ALLOCATION => ['text' => '调拨'],
- self::CHANGE_TYPE_CHECK => ['text' => '盘点']
- ];
- public function getChangeTypeTextAttr($value, $data)
- {
- $index = $data['change_type'];
- return isset(self::CHANGE_TYPE_MAP[$index]) ? self::CHANGE_TYPE_MAP[$index]['text'] : '未知';
- }
- public function details()
- {
- return $this->hasMany(IoDetail::class);
- }
- public function repo()
- {
- return $this->belongsTo(Repo::class);
- }
- public function revert()
- {
- return $this->belongsTo(Io::class, 'revert_id', 'id');
- }
- }
|