ProcessStatistic.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelTimeFormat;
  5. class ProcessStatistic extends Model
  6. {
  7. use ModelTimeFormat;
  8. //重新约定主键且不允许自增
  9. protected $primaryKey='process_id';
  10. public $incrementing=false;
  11. public $timestamps=false;
  12. protected $fillable=[
  13. 'process_id','started_at','ended_at','revenue','duration_days',
  14. 'duration_man_hours','top_capacity','bottom_capacity','average_capacity','total_cost','gross_profit','gross_profit_rate'
  15. ];
  16. public function process(){
  17. return $this->belongsTo('App\Process','process_id','id')->whereNull('deleted_at');
  18. }
  19. public function operatorLog(){
  20. return $this->hasOne('App\OperatorLog','operator_logable_id','process_id')
  21. ->where('operator_logable_type','processes');
  22. }
  23. /*public function operatorLogSubmit(){
  24. return $this->hasOne('App\OperatorLog','operator_logable_id','process_id')
  25. ->where('operator_logable_type','processes')->where('operation','质量验收');
  26. }*/
  27. }