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 accd757 + 9f8485d commit 37aad98
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 36 deletions.
1 change: 1 addition & 0 deletions app/Contracts/Interfaces/ModelHasRfidInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface ModelHasRfidInterface extends GetInterface, StoreInterface, UpdateInte
public function exists(mixed $rfid): mixed;

public function activeRfid(): mixed;
public function masterRfid(): mixed;
public function nonActiveRfid(): mixed;
public function whereSchool($id): mixed;
public function whereNotNull(mixed $column):mixed;
Expand Down
13 changes: 10 additions & 3 deletions app/Contracts/Repositories/ModelHasRfidRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public function nonActiveRfid(): mixed
->get();
}

public function masterRfid(): mixed
{
return $this->model->query()
->where('model_type', 'App\Models\School')
->get();
}

public function store(array $data): mixed
{
return $this->model->query()->create($data);
Expand Down Expand Up @@ -66,17 +73,17 @@ public function exists(mixed $rfid): mixed
return $this->model->query()->where('rfid', $rfid)->exists();
}

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

public function whereNotNull(mixed $column):mixed
public function whereNotNull(mixed $column):mixed
{
return $this->model->query()->whereNotNull($column)->get();
}

public function whereNull(mixed $column):mixed
public function whereNull(mixed $column):mixed
{
return $this->model->query()->whereNull($column)->get();
}
Expand Down
27 changes: 27 additions & 0 deletions app/Helpers/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

if (!function_exists('auth_school')) {
function auth_school()
{
return auth()->user()->school;
}
}

if (!function_exists('auth_student')) {
function auth_student()
{
return auth()->user()->student;
}
}
if (!function_exists('auth_employee')) {
function auth_employee()
{
return auth()->user()->employee;
}
}
if (!function_exists('auth_user')) {
function auth_user()
{
return auth()->user();
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/ModelHasRfidController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public function store(StoreModelHasRfidRequest $request)
public function storeMaster(StoreModelHasRfidRequest $request)
{
$exist = $this->service->check($request);
$school = $this->school->whereUserId(auth()->user()->id);
$school = auth_school();
if ($exist) {
$this->modelHasRfid->store(['rfid' => $request->rfid, 'model_type' => 'App\Models\School', 'model_id' => $school->id]);
$this->modelHasRfid->store(['rfid' => $request->rfid, 'model_type' => 'App\Models\School', 'model_id' => $school->id, 'school_id' => auth_school()->id]);
return redirect()->back()->with('success', 'Berhasil menambahkan master key');
} else {
return redirect()->back()->with('error', 'Kartu tidak valid');
Expand Down
29 changes: 23 additions & 6 deletions app/Http/Controllers/SchoolDashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,50 @@

namespace App\Http\Controllers;

use App\Contracts\Interfaces\ModelHasRfidInterface;
use App\Contracts\Interfaces\SchoolInterface;
use App\Contracts\Interfaces\SchoolYearInterface;
use App\Http\Requests\StoreModelHasRfidRequest;
use App\Models\School;
use App\Services\ModelHasRfidService;
use Illuminate\Http\Request;
use PhpParser\Node\Expr\FuncCall;

class SchoolDashboardController extends Controller
{
private SchoolInterface $school;
private SchoolYearInterface $schoolYear;
private ModelHasRfidInterface $rfid;

public function __construct(SchoolInterface $school, SchoolYearInterface $schoolYear) {
public function __construct(SchoolInterface $school, SchoolYearInterface $schoolYear, ModelHasRfidInterface $rfid)
{
$this->school = $school;
$this->schoolYear = $schoolYear;
$this->rfid = $rfid;
}

public function index() {
public function index()
{
$classroomCount =
return view('school.pages.dashboard');
}

public function show()
{
$rfids = $this->rfid->masterRfid();
$school = $this->school->showWithSlug(auth()->user()->slug);
$schoolYear = $this->schoolYear->active($school->id);
return view('school.pages.settings.information', compact('school', 'schoolYear'));
return view('school.pages.settings.information', compact('school', 'schoolYear', 'rfids'));
}

public function edit() {
public function edit()
{
$school = $this->school->showWithSlug(auth()->user()->slug);
return view('school.pages.settings.update-information', compact('school'));
}

public function update() {
public function update()
{
//
}
}
}
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"files": [
"app/Helpers/helpers.php"
]

},
"autoload-dev": {
"psr-4": {
Expand Down
19 changes: 3 additions & 16 deletions resources/views/school/pages/settings/information.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,14 @@
<thead>
<tr>
<th style="background-color: #5D87FF;" class="text-white">No</th>
<th style="background-color: #5D87FF;" class="text-white">Nama Pengguna</th>
<th style="background-color: #5D87FF;" class="text-white">Email</th>
<th style="background-color: #5D87FF;" class="text-white">RFID</th>
</tr>
</thead>
<tbody>
@forelse (range(1,6) as $rfid)
@forelse ($rfids as $rfid)
<tr>
<td>1</td>
<td>Arya Rizki</td>
<td>arya@gmail.com</td>
<td>12345678</td>
</tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $rfid->rfid }}</td>
@empty
<tr>
<td colspan="4">Belum ada RFID</td>
Expand All @@ -131,14 +126,6 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label for="">Nama</label>
<input type="text" name="" class="form-control mt-1" placeholder="Masukan nama">
</div>
<div class="mb-3">
<label for="">Email</label>
<input type="text" name="" class="form-control mt-1" placeholder="Masukan Email">
</div>
<div class="mb-3">
<label for="">RFID</label>
<p class="mt-2 fs-2">Lakukan tab pada rfid reader untuk menginputkan rfid</p>
Expand Down
10 changes: 2 additions & 8 deletions routes/role/school.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
use Illuminate\Support\Facades\Route;

Route::prefix('school')->group(function() {
Route::get('', function(){
return view('school.pages.dashboard');
})->name('school.index');
Route::get('', [SchoolDashboardController::class, 'index'])->name('school.index');

// pegawai
Route::get('employe', [StaffController::class, 'index'])->name('school.employee.index');
Expand Down Expand Up @@ -50,10 +48,6 @@
// jam mata pelajaran
// Route::get('lesson-hours', [LessonHourController::class, 'index'])->name('lesson-hours.index');
Route::resource('lesson-hours', LessonHourController::class);
//semeter
Route::get('semesters', function(){
return view('school.pages.semesters.index');
})->name('semesters.index');

//siswa
Route::get('student', [StudentController::class, 'index'])->name('school-student.index');
Expand Down Expand Up @@ -114,7 +108,7 @@
Route::delete('delete-class-level/{levelClass}', [LevelClassController::class, 'destroy'])->name('class-level.delete');

// setting informasi
Route::get('information', [SchoolDashboardController::class, 'index'])->name('settings-information.index');
Route::get('information', [SchoolDashboardController::class, 'show'])->name('settings-information.index');
Route::post('information/add-masterKey', [ModelHasRfidController::class, 'storeMaster'])->name('master-key.store');
Route::get('information/edit', [SchoolDashboardController::class, 'edit'])->name('settings-information.edit');
Route::put('information/update', [SchoolDashboardController::class, 'update'])->name('settings-information.update');
Expand Down

0 comments on commit 37aad98

Please sign in to comment.