generated from liutk/owl-admin-base
站内消息
parent
3d7646ef6a
commit
2ae9362179
|
|
@ -86,27 +86,22 @@ class ExaminationService extends BaseService
|
|||
$employees = Employee::whereIn('id', $ids)->get();
|
||||
// 为员工生成考卷
|
||||
foreach ($employees as $employee) {
|
||||
$examination->papers()->create([
|
||||
$paper = $examination->papers()->create([
|
||||
'employee_id' => $employee->id,
|
||||
'content' => $questions,
|
||||
]);
|
||||
|
||||
(new MessageService())->create(
|
||||
MessageType::Exam,
|
||||
'考试通知',
|
||||
'您有一张待完成试卷,请尽快完成考试。',
|
||||
[$employee],
|
||||
['paper' => ['id' => $paper->id]],
|
||||
);
|
||||
}
|
||||
|
||||
$examination->update(['exam_status' => ExamStatus::Published, 'published_at' => now()]);
|
||||
|
||||
(new MessageService())->create(
|
||||
MessageType::Exam,
|
||||
'考试通知',
|
||||
'您有一张待完成试卷,请尽快完成考试。',
|
||||
$employees->all(),
|
||||
[
|
||||
'examination' => [
|
||||
'id' => $examination->id,
|
||||
'name' => $examination->name,
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ namespace App\Listeners;
|
|||
|
||||
use App\Enums\MessageType;
|
||||
use App\Events\WorkflowCheckFailed;
|
||||
use App\Models\EmployeePromotion;
|
||||
use App\Models\EmployeeSignRepair;
|
||||
use App\Models\HolidayApply;
|
||||
use App\Models\OfficalBusiness;
|
||||
use App\Models\OvertimeApply;
|
||||
use App\Models\Reimbursement;
|
||||
use App\Services\MessageService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
|
@ -29,7 +35,11 @@ class CreateWorkflowCheckFailedMessage implements ShouldQueue
|
|||
return;
|
||||
}
|
||||
|
||||
if (is_null($event->workflowCheck->employee)) {
|
||||
if (is_null($employee = $event->workflowCheck->employee)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_null($subject = $event->workflowCheck->subject)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -37,8 +47,11 @@ class CreateWorkflowCheckFailedMessage implements ShouldQueue
|
|||
MessageType::Approval,
|
||||
'审批提醒',
|
||||
"您有一条【{$subjectTypeText}】未通过审核。",
|
||||
[$event->workflowCheck->employee],
|
||||
['workflow_check' => $event->workflowCheck],
|
||||
[$employee],
|
||||
[
|
||||
'subject_type' => $subject->subject_type,
|
||||
'subject' => $subject,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class CreateWorkflowCheckNextMessage implements ShouldQueue
|
|||
'审批提醒',
|
||||
"您有一条【{$subjectTypeText}】待审批。",
|
||||
$employees->all(),
|
||||
['workflow_log' => $event->workflowLog],
|
||||
['workflow_log' => $event->workflowLog->withoutRelations()],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,12 +33,19 @@ class CreateWorkflowCheckSuccessMessage implements ShouldQueue
|
|||
return;
|
||||
}
|
||||
|
||||
if (is_null($subject = $event->workflowCheck->subject)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->messageService->create(
|
||||
MessageType::Approval,
|
||||
'审批提醒',
|
||||
"您有一条【{$subjectTypeText}】已通过审核。",
|
||||
[$event->workflowCheck->employee],
|
||||
['workflow_check' => $event->workflowCheck],
|
||||
[
|
||||
'subject_type' => $subject->getMorphClass(),
|
||||
'subject' => $subject,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
namespace App\Traits;
|
||||
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
|
||||
trait UploadTrait
|
||||
{
|
||||
|
|
@ -61,7 +62,7 @@ trait UploadTrait
|
|||
return $this->response()->fail(__('admin.upload_file_error'));
|
||||
}
|
||||
|
||||
$path = $file->store(Admin::config('admin.upload.tem_directory.'.$type).'/'.date('Y-m-d'), Admin::config('admin.upload.disk'));
|
||||
$path = $file->storeAs(Admin::config('admin.upload.tem_directory.'.$type).'/'.date('Ymd'), $this->hashFilename($file), Admin::config('admin.upload.disk'));
|
||||
if (request()->has('full-url')) {
|
||||
$path = Storage::disk(Admin::config('admin.upload.disk'))->url($path);
|
||||
}
|
||||
|
|
@ -80,7 +81,7 @@ trait UploadTrait
|
|||
public function saveFile($field = 'file', $path)
|
||||
{
|
||||
$file = request()->file($field);
|
||||
|
||||
|
||||
if (!$file) {
|
||||
$file = request()->get($field);
|
||||
}
|
||||
|
|
@ -220,4 +221,19 @@ trait UploadTrait
|
|||
return $this->response()->fail(__('admin.upload_file_error'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function hashFilename(UploadedFile $file): string
|
||||
{
|
||||
$hash = Str::random(40);
|
||||
|
||||
$extension = '';
|
||||
|
||||
if ($originalExtension = $file->getClientOriginalExtension()) {
|
||||
$extension = '.'.$originalExtension;
|
||||
} elseif ($guessExtension = $this->guessExtension()) {
|
||||
$extension = '.'.$guessExtension;
|
||||
}
|
||||
|
||||
return $hash.$extension;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue