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
3 changes: 2 additions & 1 deletion app/Http/Requests/Subject/StoreSubjectRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ protected function prepareForValidation(): void

$this->merge([
'slug' => $slug,
'group' => $this->filled('group') ? $this->group : 'science',
]);
}

Expand All @@ -41,7 +42,7 @@ public function rules(): array
'icon' => ['required', 'string', 'max:50'],
'sort_order' => ['required', 'integer'],
'course' => ['required', 'string', 'in:ssc,hsc'],
'group' => ['required', 'string', 'in:science,humanities,commerce,common'],
'group' => ['sometimes', 'string', 'in:science,humanities,commerce,common'],
'is_trackable' => ['sometimes', 'boolean'],
];
}
Expand Down
12 changes: 12 additions & 0 deletions tests/Feature/SubjectManagementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$response = $this->actingAs($admin)->post('/admin/subjects', [
'name' => 'Platform Testing',
'course' => 'hsc',
'group' => 'science',
'tailwind_format' => 'bg-slate-500',
'icon' => 'book-open',
'sort_order' => 1,
Expand All @@ -19,6 +20,7 @@
$this->assertDatabaseHas('subjects', [
'name' => 'Platform Testing',
'course' => 'hsc',
'group' => 'science',
'tailwind_format' => 'bg-slate-500',
'icon' => 'book-open',
'sort_order' => 1,
Expand All @@ -32,6 +34,7 @@
'name' => 'Platform Testing',
'slug' => 'platform-testing',
'course' => 'hsc',
'group' => 'science',
'tailwind_format' => 'bg-slate-500',
'icon' => 'book-open',
'sort_order' => 1,
Expand All @@ -40,6 +43,7 @@
$response = $this->actingAs($admin)->patch("/admin/subjects/edit/{$subject->id}", [
'name' => 'Platform Testing Updated',
'course' => 'ssc',
'group' => 'commerce',
'tailwind_format' => 'bg-slate-600',
'icon' => 'book-open',
'sort_order' => 2,
Expand All @@ -52,6 +56,7 @@
'id' => $subject->id,
'name' => 'Platform Testing Updated',
'course' => 'ssc',
'group' => 'commerce',
'sort_order' => 2,
]);
});
Expand All @@ -63,6 +68,7 @@
'name' => 'Platform Testing',
'slug' => 'platform-testing',
'course' => 'hsc',
'group' => 'science',
'tailwind_format' => 'bg-slate-500',
'icon' => 'book-open',
'sort_order' => 1,
Expand All @@ -85,6 +91,7 @@
'name' => 'Custom Slug Subject',
'slug' => 'my-special-custom-slug',
'course' => 'hsc',
'group' => 'science',
'tailwind_format' => 'bg-slate-500',
'icon' => 'book-open',
'sort_order' => 1,
Expand All @@ -96,6 +103,7 @@
$this->assertDatabaseHas('subjects', [
'name' => 'Custom Slug Subject',
'slug' => 'my-special-custom-slug',
'group' => 'science',
]);
});

Expand All @@ -106,6 +114,7 @@
'name' => 'Existing Subject',
'slug' => 'existing-subject-slug',
'course' => 'hsc',
'group' => 'science',
'tailwind_format' => 'bg-slate-500',
'icon' => 'book-open',
'sort_order' => 1,
Expand Down Expand Up @@ -154,6 +163,7 @@
'name' => 'Physics',
'slug' => 'hsc-physics',
'course' => 'hsc',
'group' => 'science',
'tailwind_format' => 'bg-slate-500',
'icon' => 'book-open',
'sort_order' => 1,
Expand All @@ -162,6 +172,7 @@
$response = $this->actingAs($admin)->post('/admin/subjects', [
'name' => 'Physics',
'course' => 'ssc',
'group' => 'science',
'tailwind_format' => 'bg-slate-500',
'icon' => 'book-open',
'sort_order' => 1,
Expand All @@ -174,5 +185,6 @@
'name' => 'Physics',
'course' => 'ssc',
'slug' => 'ssc-physics',
'group' => 'science',
]);
});
Loading