<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CompanyClient extends Model
{

    protected $table = 'company_client';


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

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

    public function documents()
    {
        return $this->hasMany(CompanyClientDocument::class, 'company_client_id', 'id')
            ->orderBy('created_at', 'desc');
    }

    public function allowedDocuments()
    {
        return $this->hasMany(CompanyClientDocument::class, 'company_client_id', 'id')->where('is_removed', false)
            ->orderBy('created_at', 'desc');
    }
}
