|
|
@@ -47,18 +47,8 @@ class LaborReport extends Model
|
|
|
public function laborReportStatus(){
|
|
|
return $this->hasMany('App\LaborReportStatus','labor_report_id','id');
|
|
|
}
|
|
|
- public function 未审核(){
|
|
|
- return $this->hasOne('App\LaborReportStatus','labor_report_id','id')
|
|
|
- ->where('status','未审核');
|
|
|
- }
|
|
|
- public function 已退场(){
|
|
|
- return $this->hasOne('App\LaborReportStatus','labor_report_id','id')
|
|
|
- ->where('status','已退场');
|
|
|
- }
|
|
|
-// public function remarks(){
|
|
|
-// return $this->hasOne('App\Sign','signable_id','id')
|
|
|
-// ->where('field','remark')->where('signable_type','labor_reports');
|
|
|
-// }
|
|
|
+
|
|
|
+
|
|
|
public function getRoundCheckInAtAttribute(){
|
|
|
if (!$this['check_in_at'])return null;
|
|
|
$round_check_in_at=Carbon::parse($this['check_in_at'])->format('i');
|
|
|
@@ -212,10 +202,11 @@ class LaborReport extends Model
|
|
|
//进场时间
|
|
|
public function getEnterAtAttribute()
|
|
|
{
|
|
|
+ if ($this['userDutyCheck']&&$this['userDutyCheck']['type']=='登入')
|
|
|
+ return $this['userDutyCheck']?$this['userDutyCheck']['checked_at']:null;
|
|
|
// $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','未审核')->orderBy('id','desc')->first();
|
|
|
// if (empty($laborReportStatus))return null;
|
|
|
// return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
|
|
|
- return $this['未审核']?Carbon::parse($this['未审核']['created_at'])->format('Y-m-d H:i:s'):null;
|
|
|
}
|
|
|
|
|
|
public function getEnteringRecordAttribute()
|
|
|
@@ -230,10 +221,11 @@ class LaborReport extends Model
|
|
|
|
|
|
public function getExitAtAttribute()
|
|
|
{
|
|
|
- //$laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','已退场')->orderBy('id','desc')->first();
|
|
|
- //if (empty($laborReportStatus))return null;
|
|
|
- //return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
|
|
|
- return $this['已退场']?Carbon::parse($this['已退场']['created_at'])->format('Y-m-d H:i:s'):null;
|
|
|
+ if ($this['userDutyCheck']&&$this['userDutyCheck']['type']=='登出')
|
|
|
+ return $this['userDutyCheck']?$this['userDutyCheck']['checked_at']:null;
|
|
|
+// $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','已退场')->orderBy('id','desc')->first();
|
|
|
+// if (empty($laborReportStatus))return null;
|
|
|
+// return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
|
|
|
}
|
|
|
|
|
|
//创建或获取进场编号
|
|
|
@@ -247,9 +239,8 @@ class LaborReport extends Model
|
|
|
}
|
|
|
|
|
|
public function getIsExportAttribute(){
|
|
|
-// $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->orderBy('id','desc')->first();
|
|
|
-// return $laborReportStatus['status']=='已退场'?true:false;
|
|
|
- return $this['已退场']?true:false;
|
|
|
+ $laborReportStatus=$this->laborReportStatus()->where('labor_report_id',$this['id'])->orderBy('id','desc')->first();
|
|
|
+ return $laborReportStatus['status']=='已退场'?true:false;
|
|
|
}
|
|
|
//出场更新临时工报表信息
|
|
|
static function exitAndChangeLaborReport($laborReport,$userDutyCheck){
|