<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Claim extends Model
{

    protected $table = 'claim';

    public function lines(){
        return $this->hasMany(ClaimLine::class, 'claim_id', 'id');
    }

    public function client(){
        return $this->hasOne(Client::class, 'id', 'client_id');
    }

    public function edi(){
        return $this->hasOne(ClaimEDI::class, 'id', 'claim_edi_id');
    }

    public function currentVersion(){
        return $this->hasOne(ClaimVersion::class, 'id', 'current_version_id');
    }

    public function mbClaims(){
        return $this->hasMany(MBClaim::class, 'claim_id', 'id')->orderBy('created_at', 'DESC');
    }

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

    public function companyPro(){
        return $this->hasOne(CompanyPro::class, 'id', 'company_pro_id');
    }

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

    public function companyLocation(){
        return $this->hasOne(CompanyLocation::class, 'id', 'company_location_id');
    }

    public function primaryPayer(){
        return $this->hasOne(Payer::class, 'id', 'primary_payer_id');
    }

}
