Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
farahamaliaa committed Jul 16, 2024
2 parents a3d97fd + e3220cb commit d8e71d6
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 50 deletions.
1 change: 1 addition & 0 deletions app/Contracts/Interfaces/EmployeeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ public function paginate($query): mixed;
public function whereSchool(mixed $id, $query): mixed;
public function getTeacherBySchool(mixed $id): mixed;
public function getCountEmployee(mixed $query) : mixed;
public function getSchool(mixed $id): mixed;
}
6 changes: 3 additions & 3 deletions app/Contracts/Repositories/ClassroomRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function show(mixed $id): mixed
{
return $this->model->query()->findOrFail($id);
}

public function update(mixed $id, array $data): mixed
{
return $this->model->query()->findOrFail($id)->update($data);
Expand All @@ -44,6 +44,6 @@ public function paginate() : mixed

public function whereInSchoolYears($schoolYears)
{
return $this->model->query()->where('school_year_id', $schoolYears)->get();
return $this->model->query()->whereIn('school_year_id', $schoolYears)->get();
}
}
}
5 changes: 5 additions & 0 deletions app/Contracts/Repositories/EmployeeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public function where(mixed $data): mixed
->get();
}

public function getSchool(mixed $id): mixed
{
return $this->model->query()->where('school_id', $id)->get();
}

public function getTeacherBySchool(mixed $id): mixed
{
return $this->model->query()->whereRelation('user.roles', 'name', RoleEnum::TEACHER->value)->where('school_id', $id)->get();
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/ClassroomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function index()
$school = $this->school->whereUserId(auth()->user()->id);
$levelClasses = $this->levelClass->where($school->id);
$schoolYears = $this->schoolYear->where($school->id);
$classrooms = $this->classroom->whereInSchoolYears($schoolYears->pluck('id'));
$classrooms = $this->classroom->get();
$teachers = $this->employee->getTeacherBySchool($school->id);
return view('school.pages.class.index', compact('classrooms', 'levelClasses', 'schoolYears', 'teachers'));
Expand Down
8 changes: 6 additions & 2 deletions app/Http/Controllers/ExtracurricularController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use App\Contracts\Interfaces\EmployeeInterface;
use App\Contracts\Interfaces\ExtracurricularInterface;
use App\Models\Extracurricular;
use App\Http\Requests\StoreExtracurricularRequest;
Expand All @@ -12,20 +13,23 @@ class ExtracurricularController extends Controller
{
private ExtracurricularInterface $extracurricular;
private ExtracurricularService $service;
private EmployeeInterface $employee;

public function __construct(ExtracurricularInterface $extracurricular, ExtracurricularService $service)
public function __construct(ExtracurricularInterface $extracurricular, ExtracurricularService $service, EmployeeInterface $employee)
{
$this->extracurricular = $extracurricular;
$this->service = $service;
$this->employee = $employee;
}

/**
* Display a listing of the resource.
*/
public function index()
{
$employees = $this->employee->getSchool(auth()->user()->school->id);
$extracurriculars = $this->extracurricular->whereSchool(auth()->user()->school->id);
return view('school.pages.extracurricular.index', compact('extracurriculars'));
return view('school.pages.extracurricular.index', compact('extracurriculars', 'employees'));
}

/**
Expand Down
113 changes: 69 additions & 44 deletions resources/views/school/pages/extracurricular/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,33 @@
<h5 class="modal-title" id="importPegawai">Tambah Extracurricular</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<div class="form-group">
<label for="" class="mb-2">Nama Extracurricular</label>
<input type="text" class="form-control">
</div>
<div class="form-group">
<label for="" class="mb-2 pt-3">Pengajar</label>
<select id="pengajar" class="form-control">
<option value="">Pilih Pengajar</option>
<option value="1">Pengajar 1</option>
<option value="2">Pengajar 2</option>
<option value="3">Pengajar 3</option>
</select>
<form action="{{ route('extraa.store') }}" method="POST" enctype="multipart/form-data">
@method('post')
@csrf
<div class="modal-body">
<div class="mb-3">
<div class="form-group">
<label for="" class="mb-2">Nama Extracurricular</label>
<input type="text" class="form-control" name="name">
</div>
<div class="form-group">
<label for="" class="mb-2 pt-3">Pengajar</label>
<select id="pengajar" class="form-control" name="employee_id">
<option value="">Pilih Pengajar</option>
@forelse ($employees as $employee)
<option value="{{ $employee->id }}">{{ $employee->user->name }}</option>
@empty
@endforelse
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-rounded btn-light-danger text-danger"
data-bs-dismiss="modal">Tutup</button>
<button type="submit" class="btn btn-rounded btn-light-success text-success">Tambah</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-rounded btn-light-danger text-danger"
data-bs-dismiss="modal">Tutup</button>
<button type="submit" class="btn btn-rounded btn-light-success text-success">Tambah</button>
</div>
</form>
</div>
</div>
</div>
Expand All @@ -75,7 +80,7 @@
<tbody>
@forelse ($extracurriculars as $extracurricular)
<tr>
<td>{{ $item }}</td>
<td>{{ $loop->iteration }}</td>
<td>
{{ $extracurricular->name }}
</td>
Expand Down Expand Up @@ -104,10 +109,10 @@
class="note-business badge-group-item badge-business dropdown-item position-relative category-business d-flex align-items-center gap-3">
<i class="fs-4 ti ti-eye"></i>Detail
</a>
<a
class="note-business badge-group-item badge-business dropdown-item position-relative category-business d-flex align-items-center gap-3">
<button class="btn-edit note-business badge-group-item badge-business dropdown-item position-relative category-business d-flex align-items-center gap-3"
data-id="{{ $extracurricular->id }}" data-name="{{ $extracurricular->name }}" data-employee="{{ $extracurricular->employee_id }}">
<i class="fs-4 ti ti-edit"></i>Edit
</a>
</button>
<a
class="note-business badge-group-item badge-business dropdown-item text-danger position-relative category-business d-flex align-items-center gap-3">
<i class="fs-4 ti ti-trash"></i>Hapus
Expand All @@ -130,28 +135,34 @@ class="note-business badge-group-item badge-business dropdown-item text-danger p
<h5 class="modal-title" id="importPegawai">Edit Extracurricular</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<div class="form-group">
<label for="" class="mb-2">Nama Extracurricular</label>
<input type="text" class="form-control">
</div>
<div class="form-group">
<label for="" class="mb-2 pt-3">Pengajar</label>
<select id="pengajar" class="form-control">
<option value="">Pilih Pengajar</option>
<option value="1">Pengajar 1</option>
<option value="2">Pengajar 2</option>
<option value="3">Pengajar 3</option>
</select>
<form id="form-update" method="POST" enctype="multipart/form-data">
@method('post')
@csrf
<div class="modal-body">
<div class="mb-3">
<div class="form-group">
<label for="" class="mb-2">Nama Extracurricular</label>
<input type="text" class="form-control" id="name-update">
</div>
<div class="form-group">
<label for="" class="mb-2 pt-3">Pengajar</label>
<select id="employee-update" class="form-control">
@forelse ($employees as $emloyee)

@empty

@endforelse
<option value="">Pilih Pengajar</option>
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-rounded btn-light-danger text-danger"
data-bs-dismiss="modal">Tutup</button>
<button type="submit" class="btn btn-rounded btn-light-success text-success">Tambah</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-rounded btn-light-danger text-danger"
data-bs-dismiss="modal">Tutup</button>
<button type="submit" class="btn btn-rounded btn-light-success text-success">Tambah</button>
</div>
</form>
</div>
</div>
</div>
Expand Down Expand Up @@ -188,5 +199,19 @@ class="note-business badge-group-item badge-business dropdown-item text-danger p
$(this).closest('.table-responsive').css('overflow', 'auto');
});
});
$('.btn-edit').click(function() {
var id = $(this).data('id');
var name = $(this).data('name');
var employee_id = $(this).data('employee_id');
var level_class_id = $(this).data('level_class_id');
var school_year_id = $(this).data('school_year_id');
$('#name-edit').val(name);
$('#employee-edit').val(employee_id).trigger('change');
$('#level_class-edit').val(level_class_id).trigger('change');
$('#school_year-edit').val(school_year_id).trigger('change');
$('#form-update').attr('action', '/school/update-class/' + id);
$('#modal-edit').modal('show');
});
</script>
@endsection
2 changes: 1 addition & 1 deletion resources/views/school/pages/student/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
<img src="{{ $student->image ? asset('storage/' . $student->image) : asset('admin_assets/dist/images/profile/user-1.jpg') }}" class="rounded-circle me-2 user-profile" style="object-fit: cover" width="30" height="30" alt="" />
{{ $student->user->name }}
</td>
<td>Kelas Dumy</td>
<td>{{ $student->classroomStudents[0] ? $student->classroomStudents[0]->classroom->name : 'Kelas tidak ada' }}</td>
<td>{{ $student->gender == 'famale' ? 'Perempuan' : 'Laki-laki' }}</td>
<td>{{ $student->nisn }}</td>
<td>{{ $student->modelHasRfid ? $student->modelHasRfid->rfid : '' }}
Expand Down
3 changes: 3 additions & 0 deletions routes/role/school.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@

//Extracurricular
Route::get('extracurricular', [ExtracurricularController::class, 'index'])->name('extraa.index');
Route::post('add-extracurricular', [ExtracurricularController::class, 'store'])->name('extraa.store');
Route::put('update-extracurricular', [ExtracurricularController::class, 'update'])->name('extraa.update');
Route::delete('delete-extracurricular', [ExtracurricularController::class, 'destroy'])->name('extraa.delete');

//kelas
Route::get('class', [ClassroomController::class, 'index'])->name('class.index');
Expand Down

0 comments on commit d8e71d6

Please sign in to comment.