store-manage/app/Models/EmployeeSignRepair.php

57 lines
1.4 KiB
PHP

<?php
namespace App\Models;
use App\Admin\Services\EmployeeSignService;
use App\Enums\SignTime;
use App\Enums\SignType;
use App\Traits\HasCheckable;
use App\Traits\HasDateTimeFormatter;
use EloquentFilter\Filterable;
use Illuminate\Database\Eloquent\Model;
/**
* 补卡申请
*/
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 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');
}
}