<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CompanyPro extends Model
{

    protected $table = 'company_pro';

    public function company()
    {
        return $this->hasOne(Company::class, 'id', 'company_id');
    }

    public function pro()
    {
        return $this->hasOne(Pro::class, 'id', 'pro_id');
    }

    public function companyProPayers()
    {
        return $this->hasMany(CompanyProPayer::class, 'company_pro_id', 'id');
    }

    public function documents()
    {
        return $this->hasMany(CompanyProDocument::class, 'company_pro_id', 'id')->orderBy('id');
    }

    public function displayName()
    {
        return $this->company->name . ' / ' . $this->pro->displayName();
    }
    public function supervisingPhysicianCompanyPro()
    {
        return $this->hasOne(CompanyPro::class, 'id', 'supervising_physician_company_pro_id');
    }

}
