TicketProject.php 1.3 KB
<?php

namespace App\Models\WorkOrder;

use App\Models\Base;
use App\Models\Manage\Manage;
use App\Models\Project\Project;
use App\Models\ProjectAssociation\ProjectAssociation;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class TicketProject extends Base
{
    use HasFactory;

    protected $table = 'gl_ticket_projects';

    public function projectV6()
    {
        return $this->hasOne(Project::class, 'id', 'table_id')
            ->where('version', 6);
    }

    //售后服务经理
    public function assm()
    {
        return $this->hasOne(Manage::class, 'id', 'assm_id')
            ->select(['id', 'name']);
    }

    // 优化师
    public function seom()
    {
        return $this->hasOne(Manage::class, 'id', 'seom_id')
            ->select(['id', 'name']);
    }

    /**
     * 第一负责人
     */
    public function first_engineer()
    {
        return $this->hasOne(Manage::class, 'id', 'engineer_id')
            ->select(['id', 'name']);
    }

    /**
     * 绑定的企微群
     */
    public function association()
    {
        return $this->hasOne(ProjectAssociation::class, 'project_id', 'table_id')
            ->where('status', 1)
            ->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)
            ->select(['id', 'project_id', 'friend_id', 'binding_app']);
    }
}