Files
fdesk/app/common/model/InvRequisition.php
T

81 lines
1.9 KiB
PHP

<?php
namespace app\common\model;
use support\Model;
class InvRequisition extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'inv_requisition';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'order_no', 'applicant_company_id', 'dept_id', 'applicant_id', 'applicant_name', 'leader_id', 'manager_id', 'borrow_reason', 'use_start_date', 'use_end_date', 'status', 'claim_type', 'qr_claim_time', 'proxy_claim_user_id', 'proxy_claim_user_name', 'is_returned', 'remark', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
// 领取方式常量
const CLAIM_TYPE_NORMAL = 1; // 正常申请
const CLAIM_TYPE_QR = 2; // 扫码领取
const CLAIM_TYPE_PROXY = 3; // 管理员代领
/**
* 领取方式文本
*/
public static function getClaimTypeText($type)
{
return [
self::CLAIM_TYPE_NORMAL => '正常申请',
self::CLAIM_TYPE_QR => '扫码领取',
self::CLAIM_TYPE_PROXY => '管理员代领',
][$type] ?? '未知';
}
public function approval()
{
return $this->hasMany('app\common\model\InvRequisitionApprove',
'requisition_id', 'id');
}
/**
* 领用明细关联
*/
public function items()
{
return $this->hasMany('app\common\model\InvRequisitionItem',
'requisition_id', 'id');
}
}