ProcessStatistic.php 1.1 KB

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