Files
fdesk/app/ticket/model/Ticket.php
T
2025-08-20 15:24:36 +08:00

96 lines
1.9 KiB
PHP

<?php
namespace app\ticket\model;
use app\common\model\Resource;
use app\common\model\Role;
use app\common\model\Systems;
use support\Model;
/**
* users 用户表
* @property integer $id 用户ID(主键)
* @property string $code 工单编号
* @property string $categorie_id 分类id
* @property string $content 内容
* @property string $sort 排序
* @property integer $status 状态
* @property string $user_id 创建人id
* @property string $created_at
* @property string $updated_at
*/
class Ticket extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'tkt_ticket';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
protected $dateFormat = 'U';
/**
* 在保存时手动设置时间戳
*/
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->created_at = time();
$model->updated_at = time();
});
static::updating(function ($model) {
$model->updated_at = time();
});
}
/**
* 指定哪些字段自动转换为 Carbon 实例
*/
public function getDates()
{
return [];
}
protected $fillable = [
'code',
'categorie_id',
'content',
'sort',
'status',
'user_id'
];
public function attachments(){
return $this->hasMany(Attachment::class, 'ticket_id', 'id');
}
public function categorie(){
return $this->belongsTo(Categorie::class, 'categorie_id', 'id');
}
}