first commit

This commit is contained in:
f4ilji
2024-09-19 16:06:49 +05:00
commit b686638a39
1664 changed files with 428174 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
<?php
namespace App\Jobs;
use App\Enums\LevelEducational;
use App\Models\DirectionStudy;
use App\Services\Vicon\DirectionStudy\DirectionStudyService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Str;
class CreateDirectionStudy implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private $directionStudyService;
/**
* Create a new job instance.
*/
public function __construct()
{
$this->directionStudyService = new DirectionStudyService();
}
/**
* Execute the job.
*/
public function handle(): void
{
$naprs = [];
$naprsUuid = $this->directionStudyService->getAllNaprsUuid();
foreach ($naprsUuid as $uuid) {
array_push($naprs, $this->directionStudyService->getNapr($uuid));
}
foreach ($naprs as $napr) {
$slug = $this->generateUniqueSlug($napr->name_napr, DirectionStudy::class, LevelEducational::from($napr->lvl_edu));
DirectionStudy::updateOrCreate(
['uuid' => $napr->uuid],
[
'name' => $napr->name_napr,
'slug' => $slug,
'code' => $napr->kod_napr,
'lvl_edu' => $napr->lvl_edu,
]
);
};
}
private function generateUniqueSlug($name, $model, $levelEducational) {
$slug = Str::slug($name);
$originalSlug = $slug;
$slug = $originalSlug . '-' . Str::lower($levelEducational->name);
$count = 1;
while ($model::where('slug', $slug)->exists()) {
$slug = $originalSlug . '-' . $count;
$count++;
}
return $slug;
}
}
+82
View File
@@ -0,0 +1,82 @@
<?php
namespace App\Jobs;
use App\Enums\LevelEducational;
use App\Models\DirectionStudy;
use App\Models\EducationalProgram;
use App\Services\Vicon\EducationalProgram\EducationalProgramService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
class CreateEducationalProgram implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private $educatinalProgramService;
/**
* Create a new job instance.
*/
public function __construct()
{
$this->educatinalProgramService = new EducationalProgramService();
}
/**
* Execute the job.
*/
public function handle(): void
{
$programs = [];
$programsUuid = $this->educatinalProgramService->getAllProgramsUuid();
foreach ($programsUuid as $uuid) {
$program = $this->educatinalProgramService->getProgram($uuid);
if ($program !== null) {
array_push($programs, $program);
} else {
Log::error("Не удалось получить данные о программе с UUID: $uuid");
}
}
foreach ($programs as $program) {
$direction = DirectionStudy::where('uuid', $program->napr_uuid)->first();
if ($direction !== null) {
$slug = $this->generateUniqueSlug($program->name_op, EducationalProgram::class, LevelEducational::from($program->lvl_edu));
EducationalProgram::updateOrCreate(
['uuid' => $program->uuid],
[
'name' => $program->name_op,
'slug' => $slug, // Добавляем slug
'inner_code' => $program->inner_code,
'lvl_edu' => $program->lvl_edu,
'status' => $program->status,
'learning_forms' => $program->learning_forms,
'direction_study_id' => $direction->id,
]
);
} else {
Log::error("Не удалось найти направление обучения с UUID: {$program->napr_uuid}");
}
}
}
private function generateUniqueSlug($name, $model, $levelEducational) {
$slug = Str::slug($name);
$originalSlug = $slug;
$slug = $originalSlug . '-' . Str::lower($levelEducational->name);
$count = 1;
while ($model::where('slug', $slug)->exists()) {
$slug = $originalSlug . '-' . $count;
$count++;
}
return $slug;
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
namespace App\Jobs;
use App\Mail\CustomFormResponseMail;
use App\Models\CustomFormResponse;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;
class SendFormResponseMail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private CustomFormResponse $customFormResponse;
/**
* Create a new job instance.
*/
public function __construct(CustomFormResponse $customFormResponse)
{
$this->customFormResponse = $customFormResponse;
}
/**
* Execute the job.
*/
public function handle(): void
{
$mail_settings = $this->customFormResponse->form->mail_settings;
foreach ($mail_settings as $setting) {
Mail::to($setting['target'])
->send(new CustomFormResponseMail($setting, $this->customFormResponse->answers, $this->customFormResponse->form->columns));
}
}
}