Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into #145-production-deplo…
Browse files Browse the repository at this point in the history
…yment
  • Loading branch information
Blusia committed Oct 10, 2024
2 parents eaa3182 + fd43639 commit 16d8af8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
14 changes: 10 additions & 4 deletions app/Http/Controllers/Dashboard/GroupStudentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,22 @@ public function index(Request $request, CourseSemester $course, Group $group): R
$students = $group->students()
->paginate()
->withQueryString();
$availableStudents = $searchText
? Student::query()

$availableStudents = match(true) {
$searchText === null => [],
preg_match("/^(\d+\s?)+$/", $searchText) === 1 => Student::query()
->whereNotIn("id", $group->students->pluck("id"))
->whereIn("index_number", explode(" ", $searchText))
->get(),
default => Student::query()
->whereNotIn("id", $group->students->pluck("id"))
->where(
fn(Builder $query): Builder => $query
->where("first_name", "ILIKE", "%$searchText%")
->orWhere("surname", "ILIKE", "%$searchText%")
->orWhere("index_number", "LIKE", "%$searchText%"),
)->get()
: [];
)->get(),
};

return inertia("Dashboard/CourseSemester/Student/Index", [
"course" => CourseSemesterData::fromModel($course),
Expand Down
4 changes: 4 additions & 0 deletions app/Models/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Keating\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -20,6 +21,9 @@
* @property StudyForm $form
* @property Carbon $created_at
* @property Carbon $updated_at
* @property-read CourseSemester $course
* @property-read Collection<Student> $students
* @property-read Collection<GradeColumn> $gradeColumns
*/
class Group extends Model
{
Expand Down
13 changes: 8 additions & 5 deletions resources/js/Pages/Dashboard/CourseSemester/Student/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ watch(form, debounce(() => {
</template>
</ManagementHeader>
<div v-if="studentsFormOpen" class="border-2 border-dotted p-4 sm:rounded-lg">
<TextInput id="search" v-model="form.search" placeholder="Szukaj studentów do dodania" type="search" class="mb-5 max-w-lg" />
<div class="items flex gap-4">
<TextInput id="search" v-model="form.search" placeholder="Szukaj studentów do dodania" type="search" class="mb-5 max-w-lg" />
<span class="mt-2 text-sm text-gray-500">podaj imiona, nazwiska, numery indeksu lub zestawy numerów indeksów oddzielone spacjami</span>
</div>
<div v-if="availableStudents.length" class="grid max-h-64 grid-cols-3 gap-4 overflow-y-auto">
<div v-for="student in availableStudents" :key="student.id" class="flex h-max cursor-pointer items-center justify-between overflow-x-auto bg-white p-4 text-left sm:rounded-lg">
<div>
Expand All @@ -93,10 +96,10 @@ watch(form, debounce(() => {
<div v-if="students.data.length" class="flex flex-col gap-8">
<TableWrapper>
<template #header>
<TableHeader class="w-1/6">
<TableHeader class="w-1 text-nowrap">
ID
</TableHeader>
<TableHeader class="w-1/6">
<TableHeader class="w-1 text-nowrap">
Numer indeksu
</TableHeader>
<TableHeader class="w-1/5">
Expand All @@ -109,10 +112,10 @@ watch(form, debounce(() => {
</template>
<template #body>
<TableRow v-for="student in students.data" :key="student.id">
<TableCell class="pr-12 opacity-75">
<TableCell class="text-nowrap pr-12 opacity-75">
{{ student.id }}
</TableCell>
<TableCell>
<TableCell class="">
{{ student.index_number }}
</TableCell>
<TableCell>
Expand Down
6 changes: 3 additions & 3 deletions resources/js/Pages/Dashboard/Student/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ watch(form, debounce(() => {
<div v-if="students.data.length" class="flex flex-col gap-8">
<TableWrapper>
<template #header>
<TableHeader class="w-1/6">
<TableHeader class="w-1 text-nowrap">
ID
</TableHeader>
<TableHeader class="w-1/6">
<TableHeader class="w-1 text-nowrap">
Numer indeksu
</TableHeader>
<TableHeader class="w-1/5">
Expand All @@ -86,7 +86,7 @@ watch(form, debounce(() => {
</template>
<template #body>
<TableRow v-for="student in students.data" :key="student.id">
<TableCell class="pr-12 opacity-75">
<TableCell class="text-nowrap pr-12 opacity-75">
{{ student.id }}
</TableCell>
<TableCell>
Expand Down

0 comments on commit 16d8af8

Please sign in to comment.