Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

use EscolaLms\Consultations\Models\ConsultationUserPivot;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up()
{
Schema::table('consultations', function (Blueprint $table) {
$table->boolean('analyze_enabled')->default(false);
});
}

public function down()
{
Schema::table('consultations', function (Blueprint $table) {
$table->dropColumn('analyze_enabled');
});
}
};
28 changes: 17 additions & 11 deletions src/Dto/ConsultationDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand Down Expand Up @@ -99,4 +100,9 @@ protected function setTeachers(array $teachers): void
{
$this->relations['teachers'] = $teachers;
}

public function setAnalyzeEnabled(bool $analyzeEnabled): void
{
$this->analyzeEnabled = $analyzeEnabled;
}
}
4 changes: 2 additions & 2 deletions src/Dto/Traits/DtoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ 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
{
$result = [];
foreach ($fillables as $fill) {
$value = $this->getterByAttribute($fill);
if ($value === false) {
if ($value === null) {
continue;
}
$result[$fill] = $value;
Expand Down
1 change: 1 addition & 0 deletions src/Http/Requests/StoreConsultationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
1 change: 1 addition & 0 deletions src/Http/Requests/UpdateConsultationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
1 change: 1 addition & 0 deletions src/Http/Resources/ConsultationSimpleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/Models/Consultation.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@
* description="max_session_students",
* type="integer",
* ),
* @OA\Property(
* property="analyze_enabled",
* description="analyze_enabled",
* type="bool",
* ),
* )
*
* @property int $author_id
Expand All @@ -185,6 +190,7 @@ class Consultation extends Model
'active_from',
'active_to',
'max_session_students',
'analyze_enabled',
];

public function author(): BelongsTo
Expand Down
Loading