From 8df4c46f0a14257b325999d5385fa0ef70753cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Mon, 13 Apr 2026 12:34:39 +0200 Subject: [PATCH] Added analyze enabled --- ...analyze_enabled_to_consultations_table.php | 23 +++++++++++++++ src/Dto/ConsultationDto.php | 28 +++++++++++-------- src/Dto/Traits/DtoHelper.php | 4 +-- .../Requests/StoreConsultationRequest.php | 1 + .../Requests/UpdateConsultationRequest.php | 1 + .../Resources/ConsultationSimpleResource.php | 1 + src/Models/Consultation.php | 6 ++++ 7 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 database/migrations/2026_04_13_110202_add_analyze_enabled_to_consultations_table.php diff --git a/database/migrations/2026_04_13_110202_add_analyze_enabled_to_consultations_table.php b/database/migrations/2026_04_13_110202_add_analyze_enabled_to_consultations_table.php new file mode 100644 index 0000000..b5bf16b --- /dev/null +++ b/database/migrations/2026_04_13_110202_add_analyze_enabled_to_consultations_table.php @@ -0,0 +1,23 @@ +boolean('analyze_enabled')->default(false); + }); + } + + public function down() + { + Schema::table('consultations', function (Blueprint $table) { + $table->dropColumn('analyze_enabled'); + }); + } +}; diff --git a/src/Dto/ConsultationDto.php b/src/Dto/ConsultationDto.php index b7c7bd7..4aafff8 100644 --- a/src/Dto/ConsultationDto.php +++ b/src/Dto/ConsultationDto.php @@ -15,13 +15,14 @@ class ConsultationDto extends BaseDto implements ModelDtoContract protected string $name; protected string $status; protected string $description; - protected ?string $shortDesc; - protected ?string $activeTo; - protected ?string $activeFrom; - protected ?string $duration; - protected ?int $authorId; - protected $imagePath = false; - protected $logotypePath = false; + protected ?string $shortDesc = null; + protected ?string $activeTo = null; + protected ?string $activeFrom = null; + protected ?string $duration = null; + protected ?int $authorId = null; + protected $imagePath = null; + protected $logotypePath = null; + protected ?bool $analyzeEnabled; public function model(): Consultation { @@ -37,22 +38,22 @@ public function toArray($filters = false): array public function getImagePath() { - if ($this->imagePath !== false) { + if ($this->imagePath !== null) { return $this->imagePath === null ? '' : Str::after($this->imagePath, Str::after(env('AWS_URL'), 'https://') . '/'); } - return false; + return null; } public function getLogotypePath() { - if ($this->logotypePath !== false) { + if ($this->logotypePath !== null) { if ($this->logotypePath) { $logotypePath = Str::after($this->logotypePath, Str::after(env('AWS_URL'), 'https://') . '/'); return Str::startsWith($logotypePath, ConstantEnum::DIRECTORY) ? $logotypePath : ConstantEnum::DIRECTORY . '/' .$logotypePath; } return ''; } - return false; + return null; } protected function setProposedTerms(array $proposedTerms): void @@ -99,4 +100,9 @@ protected function setTeachers(array $teachers): void { $this->relations['teachers'] = $teachers; } + + public function setAnalyzeEnabled(bool $analyzeEnabled): void + { + $this->analyzeEnabled = $analyzeEnabled; + } } diff --git a/src/Dto/Traits/DtoHelper.php b/src/Dto/Traits/DtoHelper.php index d197080..6339bd2 100644 --- a/src/Dto/Traits/DtoHelper.php +++ b/src/Dto/Traits/DtoHelper.php @@ -28,7 +28,7 @@ protected function getterByAttribute(string $attribute) if (method_exists($this, 'get' . $key)) { return $this->{'get' . $key}(); } - return $this->{lcfirst($key)} ?? false; + return $this->{lcfirst($key)} ?? null; } protected function fillInArray(array $fillables): array @@ -36,7 +36,7 @@ protected function fillInArray(array $fillables): array $result = []; foreach ($fillables as $fill) { $value = $this->getterByAttribute($fill); - if ($value === false) { + if ($value === null) { continue; } $result[$fill] = $value; diff --git a/src/Http/Requests/StoreConsultationRequest.php b/src/Http/Requests/StoreConsultationRequest.php index 99a8db5..ebda826 100644 --- a/src/Http/Requests/StoreConsultationRequest.php +++ b/src/Http/Requests/StoreConsultationRequest.php @@ -34,6 +34,7 @@ public function rules(): array 'max_session_students' => ['integer', 'min:1', 'max:99'], 'teachers' => ['array'], 'teachers.*' => ['integer', 'exists:users,id'], + 'analyze_enabled' => ['boolean', 'nullable'], ], ModelFields::getFieldsMetadataRules(Consultation::class)); } } diff --git a/src/Http/Requests/UpdateConsultationRequest.php b/src/Http/Requests/UpdateConsultationRequest.php index d3492bb..5d335fa 100644 --- a/src/Http/Requests/UpdateConsultationRequest.php +++ b/src/Http/Requests/UpdateConsultationRequest.php @@ -37,6 +37,7 @@ public function rules(): array 'max_session_students' => ['integer', 'min:1', 'max:99'], 'teachers' => ['array'], 'teachers.*' => ['integer', 'exists:users,id'], + 'analyze_enabled' => ['boolean', 'nullable'], ], ModelFields::getFieldsMetadataRules(Consultation::class)); } } diff --git a/src/Http/Resources/ConsultationSimpleResource.php b/src/Http/Resources/ConsultationSimpleResource.php index 8067f7e..329848c 100644 --- a/src/Http/Resources/ConsultationSimpleResource.php +++ b/src/Http/Resources/ConsultationSimpleResource.php @@ -37,6 +37,7 @@ public function toArray($request) 'categories' => $this->resource->categories, 'max_session_students' => $this->resource->max_session_students, 'teachers' => ConsultationAuthorResource::collection($this->resource->teachers), + 'analyze_enabled' => $this->resource->analyze_enabled, ...ModelFields::getExtraAttributesValues($this->resource, MetaFieldVisibilityEnum::PUBLIC) ]; return self::apply($fields, $this); diff --git a/src/Models/Consultation.php b/src/Models/Consultation.php index 3fdaeea..f657369 100644 --- a/src/Models/Consultation.php +++ b/src/Models/Consultation.php @@ -160,6 +160,11 @@ * description="max_session_students", * type="integer", * ), + * @OA\Property( + * property="analyze_enabled", + * description="analyze_enabled", + * type="bool", + * ), * ) * * @property int $author_id @@ -185,6 +190,7 @@ class Consultation extends Model 'active_from', 'active_to', 'max_session_students', + 'analyze_enabled', ]; public function author(): BelongsTo