diff --git a/app/Http/Controllers/Dashboard/SettingController.php b/app/Http/Controllers/Dashboard/SettingController.php
index 8d894f1..cd3f2f2 100644
--- a/app/Http/Controllers/Dashboard/SettingController.php
+++ b/app/Http/Controllers/Dashboard/SettingController.php
@@ -28,6 +28,7 @@ public function update(SettingRequest $request, FilesystemManager $filesystem):
if ($settings->logo) {
$filesystem->disk("public")->delete($settings->logo);
}
+
$file = $request->file("logo");
$fileName = $file->getClientOriginalName();
$path = "/logo";
diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php
index a3640bf..b925f4c 100644
--- a/app/Http/Middleware/HandleInertiaRequests.php
+++ b/app/Http/Middleware/HandleInertiaRequests.php
@@ -5,8 +5,10 @@
namespace Keating\Http\Middleware;
use Closure;
+use Illuminate\Cache\CacheManager;
use Illuminate\Http\Request;
use Inertia\Middleware;
+use Keating\Models\Setting;
class HandleInertiaRequests extends Middleware
{
@@ -15,6 +17,7 @@ public function share(Request $request): array
return array_merge(parent::share($request), [
"auth" => $this->getAuthData($request),
"flash" => $this->getFlashData($request),
+ "settings" => $this->getSettingsData($request),
]);
}
@@ -33,4 +36,19 @@ protected function getFlashData(Request $request): Closure
"info" => $request->session()->get("info"),
];
}
+
+ protected function getSettingsData(Request $request): Closure
+ {
+ /** @var CacheManager $cache */
+ $cache = app("cache");
+
+ return fn(): array => [
+ "scheduleLink" => $cache->get("scheduleLink", function () use ($cache): ?string {
+ $link = Setting::query()->first()?->schedule_link;
+ $cache->put("scheduleLink", $link);
+
+ return $link;
+ }),
+ ];
+ }
}
diff --git a/app/Http/Requests/SettingRequest.php b/app/Http/Requests/SettingRequest.php
index 0eabf75..f01bee9 100644
--- a/app/Http/Requests/SettingRequest.php
+++ b/app/Http/Requests/SettingRequest.php
@@ -16,6 +16,7 @@ public function rules(): array
"teacher_titles" => ["required", "max:255"],
"university_name" => ["required", "max:255"],
"department_name" => ["required", "max:255"],
+ "schedule_link" => ["nullable", "url"],
"primary_color" => ["required", "regex:/^#([A-Fa-f0-9]{6})$/"],
"secondary_color" => ["required", "regex:/^#([A-Fa-f0-9]{6})$/"],
"logo" => ["nullable", "image", "max:1024"],
@@ -30,6 +31,7 @@ public function getData(): array
"teacher_titles" => $this->input("teacher_titles"),
"university_name" => $this->input("university_name"),
"department_name" => $this->input("department_name"),
+ "schedule_link" => $this->input("schedule_link"),
"primary_color" => $this->input("primary_color"),
"secondary_color" => $this->input("secondary_color"),
];
diff --git a/app/Models/Setting.php b/app/Models/Setting.php
index 7095fbd..ea867d4 100644
--- a/app/Models/Setting.php
+++ b/app/Models/Setting.php
@@ -18,6 +18,10 @@
* @property string $teacher_titles
* @property string $university_name
* @property string $department_name
+ * @property string $schedule_link
+ * @property string $primary_color
+ * @property string $secondary_color
+ * @property string $logo
* @property Carbon $created_at
* @property Carbon $updated_at
*/
@@ -33,6 +37,7 @@ class Setting extends Model
"teacher_titles",
"university_name",
"department_name",
+ "schedule_link",
"primary_color",
"secondary_color",
"logo",
diff --git a/app/Observers/SettingObserver.php b/app/Observers/SettingObserver.php
index dc909c2..80da068 100644
--- a/app/Observers/SettingObserver.php
+++ b/app/Observers/SettingObserver.php
@@ -15,5 +15,6 @@ public function __construct(
public function saved(): void
{
$this->cache->forget("pageTitle");
+ $this->cache->forget("scheduleLink");
}
}
diff --git a/database/factories/SettingFactory.php b/database/factories/SettingFactory.php
index 89664ef..2177eed 100644
--- a/database/factories/SettingFactory.php
+++ b/database/factories/SettingFactory.php
@@ -16,6 +16,7 @@ public function definition(): array
"teacher_email" => fake()->email,
"department_name" => "Zakład Informatyki, Wydział Nauk Technicznych i Ekonomicznych",
"university_name" => "Collegium Witelona Uczelnia Państwowa",
+ "schedule_link" => fake()->url(),
"primary_color" => "#000000",
"secondary_color" => "#ffffff",
];
diff --git a/database/migrations/2024_09_16_135335_add_schedule_link_to_settings_table.php b/database/migrations/2024_09_16_135335_add_schedule_link_to_settings_table.php
new file mode 100644
index 0000000..dab1680
--- /dev/null
+++ b/database/migrations/2024_09_16_135335_add_schedule_link_to_settings_table.php
@@ -0,0 +1,23 @@
+string("schedule_link")->nullable()->default(null);
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table("settings", function (Blueprint $table): void {
+ $table->dropColumn("schedule_link");
+ });
+ }
+};
diff --git a/lang/pl/validation.php b/lang/pl/validation.php
index 68e2ce7..7a44dd0 100644
--- a/lang/pl/validation.php
+++ b/lang/pl/validation.php
@@ -128,6 +128,7 @@
"teacher_titles" => "tytuły/stopnie naukowe nauczyciela",
"university_name" => "nazwa uczelni",
"department_name" => "nazwa wydziału",
+ "schedule_link" => "link do planu zajęć",
"title" => "tytuł",
"content" => "treść",
"value" => "opis",
diff --git a/resources/js/Layouts/PublicLayout.vue b/resources/js/Layouts/PublicLayout.vue
index 06cdabf..4a1539b 100644
--- a/resources/js/Layouts/PublicLayout.vue
+++ b/resources/js/Layouts/PublicLayout.vue
@@ -2,7 +2,7 @@
import { ref } from 'vue'
import { Link } from '@inertiajs/inertia-vue3'
import { Dialog, DialogPanel } from '@headlessui/vue'
-import { Bars3Icon, EllipsisHorizontalIcon, XMarkIcon } from '@heroicons/vue/24/outline'
+import { Bars3Icon, EllipsisHorizontalIcon, XMarkIcon, ArrowTopRightOnSquareIcon } from '@heroicons/vue/24/outline'
const navigation = [
{ name: 'Strona główna', href: '/' },
@@ -30,6 +30,10 @@ const mobileMenuOpen = ref(false)
{{ item.name }}
+
+ Plan zajęć
+
+
@@ -57,6 +61,10 @@ const mobileMenuOpen = ref(false)
{{ item.name }}
+
+ Plan zajęć
+
+
diff --git a/resources/js/Pages/Dashboard/Setting/Edit.vue b/resources/js/Pages/Dashboard/Setting/Edit.vue
index 0666a81..67f9f42 100644
--- a/resources/js/Pages/Dashboard/Setting/Edit.vue
+++ b/resources/js/Pages/Dashboard/Setting/Edit.vue
@@ -23,6 +23,7 @@ const form = useForm({
teacher_titles: props.settings.teacher_titles,
university_name: props.settings.university_name,
department_name: props.settings.department_name,
+ schedule_link: props.settings.schedule_link,
primary_color: props.settings.primary_color,
secondary_color: props.settings.secondary_color,
logo: null,
@@ -100,6 +101,13 @@ function onFileSelected(event) {
+
+
+ Link do planu zajęć
+
+
+
+
Kolor główny
diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php
index 27d9602..efeacce 100644
--- a/tests/CreatesApplication.php
+++ b/tests/CreatesApplication.php
@@ -9,9 +9,6 @@
trait CreatesApplication
{
- /**
- * Creates the application.
- */
public function createApplication(): Application
{
$app = require __DIR__ . "/../bootstrap/app.php";
diff --git a/tests/Feature/SettingsScheduleLinkTest.php b/tests/Feature/SettingsScheduleLinkTest.php
new file mode 100644
index 0000000..a099a34
--- /dev/null
+++ b/tests/Feature/SettingsScheduleLinkTest.php
@@ -0,0 +1,60 @@
+user = User::factory()->create();
+ $this->actingAs($this->user);
+ }
+
+ public function testMainPageWhenNoScheduleLinkInSetting(): void
+ {
+ Setting::factory()->create([
+ "teacher_name" => "Ty Doe",
+ "teacher_email" => "ty.doe@exmple.com",
+ "teacher_titles" => "dr inż.",
+ "university_name" => "CWUP",
+ "department_name" => "IT department",
+ "schedule_link" => null,
+ "primary_color" => "#000000",
+ "secondary_color" => "#ffffff",
+ ]);
+
+ $this->get("/")->assertInertia(function (AssertableInertia $page): void {
+ $page->has("settings")->where("settings.scheduleLink", null);
+ });
+ }
+
+ public function testMainPageWhenScheduleLinkInSetting(): void
+ {
+ Setting::factory()->create([
+ "teacher_name" => "Ty Doe",
+ "teacher_email" => "ty.doe@exmple.com",
+ "teacher_titles" => "dr inż.",
+ "university_name" => "CWUP",
+ "department_name" => "IT department",
+ "schedule_link" => "https://google.com/",
+ "primary_color" => "#000000",
+ "secondary_color" => "#ffffff",
+ ]);
+
+ $this->get("/")->assertInertia(function (AssertableInertia $page): void {
+ $page->has("settings")->where("settings.scheduleLink", "https://google.com/");
+ });
+ }
+}
diff --git a/tests/Feature/SettingsTest.php b/tests/Feature/SettingsTest.php
index 1bf9532..c6efbc9 100644
--- a/tests/Feature/SettingsTest.php
+++ b/tests/Feature/SettingsTest.php
@@ -27,6 +27,7 @@ protected function setUp(): void
"teacher_titles" => "dr inż.",
"university_name" => "CWUP",
"department_name" => "IT department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#000000",
"secondary_color" => "#ffffff",
]);
@@ -41,6 +42,7 @@ public function testSettingsCanBeUpdated(): void
"teacher_titles" => "dr inż.",
"university_name" => "CWUP",
"department_name" => "IT department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#000000",
"secondary_color" => "#ffffff",
"logo" => null,
@@ -52,6 +54,7 @@ public function testSettingsCanBeUpdated(): void
"teacher_titles" => "dr",
"university_name" => "SWPS",
"department_name" => "Psychology department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#11ffff",
"secondary_color" => "#110000",
])->assertSessionHasNoErrors();
@@ -62,6 +65,7 @@ public function testSettingsCanBeUpdated(): void
"teacher_titles" => "dr",
"university_name" => "SWPS",
"department_name" => "Psychology department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#11ffff",
"secondary_color" => "#110000",
"logo" => null,
@@ -76,6 +80,7 @@ public function testSettingsCannotBeUpdatedWithInvalidData(): void
"teacher_titles" => "dr inż.",
"university_name" => "CWUP",
"department_name" => "IT department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#000000",
"secondary_color" => "#ffffff",
"logo" => null,
@@ -87,6 +92,7 @@ public function testSettingsCannotBeUpdatedWithInvalidData(): void
"teacher_titles" => Str::random(256),
"university_name" => Str::random(256),
"department_name" => Str::random(256),
+ "schedule_link" => "test",
"primary_color" => "000000",
"secondary_color" => "ffffff",
])->assertSessionHasErrors()
@@ -96,6 +102,7 @@ public function testSettingsCannotBeUpdatedWithInvalidData(): void
"teacher_titles",
"university_name",
"department_name",
+ "schedule_link",
"primary_color",
"secondary_color",
]);
@@ -106,6 +113,7 @@ public function testSettingsCannotBeUpdatedWithInvalidData(): void
"teacher_titles" => "dr inż.",
"university_name" => "CWUP",
"department_name" => "IT department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#000000",
"secondary_color" => "#ffffff",
"logo" => null,
@@ -120,6 +128,7 @@ public function testSettingsCannotBeUpdatedWithEmptyData(): void
"teacher_titles" => "dr inż.",
"university_name" => "CWUP",
"department_name" => "IT department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#000000",
"secondary_color" => "#ffffff",
"logo" => null,
@@ -150,6 +159,7 @@ public function testSettingsCannotBeUpdatedWithEmptyData(): void
"teacher_titles" => "dr inż.",
"university_name" => "CWUP",
"department_name" => "IT department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#000000",
"secondary_color" => "#ffffff",
"logo" => null,
@@ -165,6 +175,7 @@ public function testLogoCanBeUploadedAndRemoved(): void
"teacher_titles" => "dr inż.",
"university_name" => "CWUP",
"department_name" => "IT department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#000000",
"secondary_color" => "#ffffff",
"logo" => null,
@@ -177,6 +188,7 @@ public function testLogoCanBeUploadedAndRemoved(): void
"teacher_titles" => "dr",
"university_name" => "SWPS",
"department_name" => "Psychology department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#11ffff",
"secondary_color" => "#110000",
"logo" => $logo,
@@ -188,6 +200,7 @@ public function testLogoCanBeUploadedAndRemoved(): void
"teacher_titles" => "dr",
"university_name" => "SWPS",
"department_name" => "Psychology department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#11ffff",
"secondary_color" => "#110000",
"logo" => "logo/logo.png",
@@ -203,6 +216,7 @@ public function testLogoCanBeUploadedAndRemoved(): void
"teacher_titles" => "dr",
"university_name" => "SWPS",
"department_name" => "Psychology department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#11ffff",
"secondary_color" => "#110000",
"logo" => null,
@@ -219,6 +233,7 @@ public function testSettingsCannotBeUpdatedWithTooBigLogoFile(): void
"teacher_titles" => "dr inż.",
"university_name" => "CWUP",
"department_name" => "IT department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#000000",
"secondary_color" => "#ffffff",
"logo" => null,
@@ -231,6 +246,7 @@ public function testSettingsCannotBeUpdatedWithTooBigLogoFile(): void
"teacher_titles" => "dr",
"university_name" => "SWPS",
"department_name" => "Psychology department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#11ffff",
"secondary_color" => "#110000",
"logo" => $logo,
@@ -245,6 +261,7 @@ public function testSettingsCannotBeUpdatedWithTooBigLogoFile(): void
"teacher_titles" => "dr inż.",
"university_name" => "CWUP",
"department_name" => "IT department",
+ "schedule_link" => "https://google.com/",
"primary_color" => "#000000",
"secondary_color" => "#ffffff",
"logo" => null,