Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into #126-problem-with-dep…
Browse files Browse the repository at this point in the history
…loyment

# Conflicts:
#	.github/workflows/deploy-to-beta-by-push.yml
  • Loading branch information
Blusia committed Aug 21, 2024
2 parents ab3a565 + 507d386 commit d455f23
Show file tree
Hide file tree
Showing 120 changed files with 501 additions and 495 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/deploy-to-beta-by-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ concurrency:

on:
workflow_dispatch:
push:
branches:
- main

jobs:

Expand Down
4 changes: 2 additions & 2 deletions app/Actions/ActivateSemesterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace App\Actions;
namespace Keating\Actions;

use App\Models\Semester;
use Exception;
use Illuminate\Database\ConnectionInterface;
use Keating\Models\Semester;

class ActivateSemesterAction
{
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/WuStudentsImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace App\Actions;
namespace Keating\Actions;

use App\Models\Student;
use Keating\Models\Student;

class WuStudentsImport
{
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/FlushCachedPageTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Console\Commands;
namespace Keating\Console\Commands;

use Illuminate\Cache\CacheManager;
use Illuminate\Console\Command;
Expand Down
32 changes: 32 additions & 0 deletions app/DTOs/CourseData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Keating\DTOs;

use Keating\Enums\ClassType;
use Keating\Models\Course;

readonly class CourseData
{
public function __construct(
public string $id,
public string $name,
public string $abbreviation,
public string $description,
public string $semester,
public string $type,
) {}

public static function fromModel(Course $course): self
{
return new self(
id: $course->id,
name: $course->name,
abbreviation: $course->abbreviation,
description: $course->description,
semester: $course->getRomanizedSemester(),
type: ClassType::labels()[$course->type],
);
}
}
46 changes: 46 additions & 0 deletions app/DTOs/CoursePublicData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace Keating\DTOs;

use Illuminate\Support\Collection;
use Keating\Enums\ClassType;
use Keating\Enums\SemesterName;
use Keating\Models\Course;

readonly class CoursePublicData
{
public function __construct(
public string $id,
public string $name,
public string $abbreviation,
public string $slug,
public string $description,
public string $semester,
public string $semesterName,
public string $type,
public string $typeAbbreviation,
public string $field,
public string $fieldAbbreviation,
public bool $active,
) {}

public static function fromModel(Course $course, ?Collection $activeSemesters = null): self
{
return new self(
id: $course->id,
name: $course->name,
abbreviation: $course->abbreviation,
slug: $course->slug,
description: $course->description,
semester: $course->getRomanizedSemester(),
semesterName: SemesterName::labels()[$course->semester_name],
type: ClassType::labels()[$course->type],
typeAbbreviation: ClassType::abbreviationLabels()[$course->type],
field: $course->field->name,
fieldAbbreviation: $course->field->abbreviation,
active: $activeSemesters && ($activeSemesters->contains($course->getRomanizedSemester()) || $activeSemesters->contains($course->semester)),
);
}
}
29 changes: 29 additions & 0 deletions app/DTOs/CourseSemesterData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Keating\DTOs;

use Keating\Models\CourseSemester;

readonly class CourseSemesterData
{
public function __construct(
public string $id,
public string $course,
public string $semester,
public string $semesterId,
public int $groupsCount,
) {}

public static function fromModel(CourseSemester $course): self
{
return new self(
id: $course->id,
course: $course->course->name,
semester: $course->semester->name,
semesterId: $course->semester->id,
groupsCount: $course->groups_count ?? $course->groups->count(),
);
}
}
25 changes: 25 additions & 0 deletions app/DTOs/FieldData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Keating\DTOs;

use Keating\Models\Field;

readonly class FieldData
{
public function __construct(
public string $id,
public string $name,
public string $abbreviation,
) {}

public static function fromModel(Field $field): self
{
return new self(
id: $field->id,
name: $field->name,
abbreviation: $field->abbreviation,
);
}
}
28 changes: 28 additions & 0 deletions app/DTOs/GroupData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Keating\DTOs;

use Keating\Enums\StudyForm;
use Keating\Models\Group;

readonly class GroupData
{
public function __construct(
public string $id,
public string $name,
public string $formAbbreviation,
public string $form,
) {}

public static function fromModel(Group $group): self
{
return new self(
id: $group->id,
name: $group->name,
formAbbreviation: StudyForm::abbreviationLabels()[$group->form->value],
form: $group->form->value,
);
}
}
8 changes: 4 additions & 4 deletions app/DTOs/StudentData.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace App\DTOs;
namespace Keating\DTOs;

use App\Models\Grade;
use App\Models\GradeColumn;
use App\Models\Student;
use Illuminate\Support\Collection;
use Keating\Models\Grade;
use Keating\Models\GradeColumn;
use Keating\Models\Student;

readonly class StudentData
{
Expand Down
2 changes: 1 addition & 1 deletion app/Enums/ClassType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Enums;
namespace Keating\Enums;

enum ClassType: string
{
Expand Down
2 changes: 1 addition & 1 deletion app/Enums/Icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Enums;
namespace Keating\Enums;

enum Icons: string
{
Expand Down
2 changes: 1 addition & 1 deletion app/Enums/SectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Enums;
namespace Keating\Enums;

enum SectionType: string
{
Expand Down
2 changes: 1 addition & 1 deletion app/Enums/SemesterName.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Enums;
namespace Keating\Enums;

enum SemesterName: string
{
Expand Down
2 changes: 1 addition & 1 deletion app/Enums/StudyForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Enums;
namespace Keating\Enums;

enum StudyForm: string
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Http\Controllers;
namespace Keating\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
Expand Down
11 changes: 5 additions & 6 deletions app/Http/Controllers/Dashboard/ContactInfoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

declare(strict_types=1);

namespace App\Http\Controllers\Dashboard;
namespace Keating\Http\Controllers\Dashboard;

use App\Enums\Icons;
use App\Http\Controllers\Controller;
use App\Http\Requests\ContactInfoRequest;
use App\Models\ContactInfo;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Response;
use Keating\Enums\Icons;
use Keating\Http\Requests\ContactInfoRequest;
use Keating\Models\ContactInfo;
use Spatie\LaravelOptions\Options;

class ContactInfoController extends Controller
class ContactInfoController
{
public function index(Request $request): Response
{
Expand Down
27 changes: 13 additions & 14 deletions app/Http/Controllers/Dashboard/CourseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

declare(strict_types=1);

namespace App\Http\Controllers\Dashboard;
namespace Keating\Http\Controllers\Dashboard;

use App\Enums\ClassType;
use App\Enums\SemesterName;
use App\Enums\StudyForm;
use App\Http\Controllers\Controller;
use App\Http\Requests\CourseRequest;
use App\Http\Resources\CourseResource;
use App\Http\Resources\FieldResource;
use App\Models\Course;
use App\Models\Field;
use Illuminate\Http\RedirectResponse;
use Inertia\Response;
use Keating\DTOs\CourseData;
use Keating\DTOs\FieldData;
use Keating\Enums\ClassType;
use Keating\Enums\SemesterName;
use Keating\Enums\StudyForm;
use Keating\Http\Requests\CourseRequest;
use Keating\Models\Course;
use Keating\Models\Field;
use Spatie\LaravelOptions\Options;

class CourseController extends Controller
class CourseController
{
public function index(): Response
{
Expand All @@ -26,7 +25,7 @@ public function index(): Response
->get();

return inertia("Dashboard/Course/Index", [
"courses" => CourseResource::collection($courses),
"courses" => $courses->map(fn(Course $course): CourseData => CourseData::fromModel($course)),
"total" => Course::query()->count(),
"lastUpdate" => Course::query()->orderByDesc("updated_at")->first()?->updated_at->diffForHumans(),
]);
Expand All @@ -42,7 +41,7 @@ public function create(): Response
"classTypes" => Options::forEnum(ClassType::class)->toArray(),
"studyForms" => Options::forEnum(StudyForm::class)->toArray(),
"semesterNames" => Options::forEnum(SemesterName::class)->toArray(),
"fields" => FieldResource::collection($fields)->resolve(),
"fields" => $fields->map(fn(Field $field) => FieldData::fromModel($field)),
]);
}

Expand All @@ -66,7 +65,7 @@ public function edit(Course $course): Response
"classTypes" => Options::forEnum(ClassType::class)->toArray(),
"studyForms" => Options::forEnum(StudyForm::class)->toArray(),
"semesterNames" => Options::forEnum(SemesterName::class)->toArray(),
"fields" => FieldResource::collection($fields)->resolve(),
"fields" => $fields->map(fn(Field $field) => FieldData::fromModel($field)),
]);
}

Expand Down
Loading

0 comments on commit d455f23

Please sign in to comment.