<?php

namespace App;

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

use App\Traits\ModelLogChanging;

class ProcessStatistic extends Model
{
    use ModelLogChanging;

    use ModelTimeFormat;
    //重新约定主键且不允许自增
    protected $primaryKey='process_id';
    public $incrementing=false;
    public $timestamps=false;

    protected $fillable=[
        'process_id','started_at','ended_at','revenue','duration_days',
        'duration_man_hours','top_capacity','bottom_capacity','average_capacity','total_cost','gross_profit','gross_profit_rate'
    ];

    public function process(){
        return $this->belongsTo('App\Process','process_id','id')->whereNull('deleted_at');
    }

    public function operatorLog(){
        return $this->hasOne('App\OperatorLog','operator_logable_id','process_id')
            ->where('operator_logable_type','processes')->where("operation",'接单');
    }
}
