generated from liutk/owl-admin-base
62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\{SignTime, SignType, CheckStatus};
|
|
use App\Traits\HasCheckable;
|
|
use App\Traits\HasDateTimeFormatter;
|
|
use EloquentFilter\Filterable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Models\EmployeeSignLog;
|
|
use App\Admin\Services\EmployeeSignService;
|
|
|
|
/**
|
|
* 补卡申请
|
|
*/
|
|
class EmployeeSignRepair extends Model
|
|
{
|
|
use Filterable, HasCheckable, HasDateTimeFormatter;
|
|
|
|
protected $table = 'employee_sign_repairs';
|
|
|
|
protected $fillable = ['date', 'store_id', 'employee_id', 'reason', 'sign_time', 'sign_type', 'outside_remarks'];
|
|
|
|
protected $casts = [
|
|
'date' => 'datetime',
|
|
'sign_time' => SignTime::class,
|
|
'sign_type' => SignType::class,
|
|
];
|
|
|
|
public function canUpdate(): bool
|
|
{
|
|
return in_array($this->workflow?->check_status, [CheckStatus::None, CheckStatus::Fail, CheckStatus::Cancel]);
|
|
}
|
|
|
|
public function checkSuccess()
|
|
{
|
|
EmployeeSignService::make()->signDay($this->employee, $this->sign_time, $this->date, [
|
|
'type' => $this->sign_type,
|
|
'remarks' => $this->reason,
|
|
'position' => ['address' => '无'],
|
|
'is_repair' => 1,
|
|
'outside_remarks' => $this->outside_remarks,
|
|
'repair_id' => $this->id,
|
|
]);
|
|
}
|
|
|
|
public function modelFilter()
|
|
{
|
|
return \App\Admin\Filters\EmployeeSignRepairFilter::class;
|
|
}
|
|
|
|
public function store()
|
|
{
|
|
return $this->belongsTo(Store::class, 'store_id');
|
|
}
|
|
|
|
public function employee()
|
|
{
|
|
return $this->belongsTo(Employee::class, 'employee_id');
|
|
}
|
|
}
|