<?php

namespace App;

use App\Traits\ModelTimeFormat;
use Illuminate\Database\Eloquent\Model;

use App\Traits\ModelLogChanging;

class OwnerContract extends Model
{
    use ModelLogChanging;

    use ModelTimeFormat;

    protected $fillable=[
        "contract_number",  //合同号
        "salesman",         //销售名称
        "remark",           //备注
        "owner_id",         //外键货主
    ];

    public function files()
    {   //合同文件
        return $this->hasMany(UploadFile::class,"table_id","id")
            ->where("table_name","contracts");
    }
    public function owner()
    {   //货主
        return $this->belongsTo(Owner::class,"owner_id","id");
    }
}
