Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nesaathussholeha committed Nov 15, 2024
2 parents c5da0d0 + 85e7471 commit c991953
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 5 deletions.
79 changes: 79 additions & 0 deletions app/Http/Controllers/Api/TeacherApiController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace App\Http\Controllers\Api;

use App\Contracts\Interfaces\ClassroomInterface;
use App\Contracts\Interfaces\EmployeeInterface;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;

class TeacherApiController extends Controller
{
private EmployeeInterface $employee;
private ClassroomInterface $classroom;

public function __construct(EmployeeInterface $employee, ClassroomInterface $classroom)
{
$this->employee = $employee;
$this->classroom = $classroom;
}

public function class(User $user)
{
$employee = $this->employee->getByUser($user->id);
$classroom = $this->classroom->whereEmployeeId($employee->id);
return response()->json(['status' => 'success', 'message' => "Data Berhasil di Tambahkan", 'code' => 200, 'data' => [
'class' => $classroom->name,
'count_student' => $classroom->classroomStudents()->latest()->count(),
]]);
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}

/**
* Show the form for editing the specified resource.
*/
public function edit(string $id)
{
//
}

/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}
6 changes: 3 additions & 3 deletions resources/views/school/layouts/header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<a class="nav-link pe-0" href="javascript:void(0)" id="drop1" data-bs-toggle="dropdown" aria-expanded="false">
<div class="d-flex align-items-center">
<div class="">
<img src="{{ Auth::user()->image ? asset('storage/' . Auth::user()->image) : asset('assets/images/default-user.jpeg') }}" class="rounded-circle user-profile" style="object-fit: cover" width="35" height="35"/>
<img src="{{ Auth::user()->school->image && Storage::exists('public/' . Auth::user()->school->image) ? asset('storage/' . Auth::user()->school->image) : asset('assets/images/default-user.jpeg') }}" class="rounded-circle user-profile" style="object-fit: cover" width="35" height="35"/>
</div>
</div>
</a>
Expand All @@ -45,10 +45,10 @@
<h5 class="mb-0 fs-5 fw-semibold">{{ auth()->user()->name }} Profile</h5>
</div>
<div class="d-flex align-items-center py-9 mx-7 border-bottom">
<img src="{{ Auth::user()->image ? asset('storage/' . Auth::user()->image) : asset('assets/images/default-user.jpeg') }}" class="rounded-circle user-profile" style="object-fit: cover" width="80" height="80" alt="" />
<img src="{{ Auth::user()->school->image && Storage::exists('public/' . Auth::user()->school->image) ? asset('storage/' . Auth::user()->school->image) : asset('assets/images/default-user.jpeg') }}" class="rounded-circle user-profile" style="object-fit: cover" width="80" height="80" alt="" />
<div class="ms-3">
<h5 class="mb-1 fs-3 username">{{ auth()->user()->name }}</h5>
<span class="mb-1 d-block text-dark role">{{ auth()->user()->name }}</span>
<span class="mb-1 d-block text-dark role">{{ auth()->user()->roles->first()->name }}</span>
<p class="mb-0 d-flex text-dark align-items-center gap-2 email">
<i class="ti ti-mail fs-4"></i>
{{ auth()->user()->email }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="row pb-4 mt-3 mx-3">
<div class="d-flex align-items-center mb-5">
<img class="card-img-top img-responsive me-3" style="max-height:80px; width: auto;"
src="{{ $school->image ? asset('storage/' . $school->image) : asset('assets/images/default-user.jpeg') }}"
src="{{ $school->image && Storage::exists('public/' . $school->image) ? asset('storage/' . $school->image) : asset('assets/images/default-user.jpeg') }}"
alt="{{ $school->user->name }}">
<div class="d-flex flex-column flex-sm-row justify-content-between w-100 ms-3">
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="row pb-4 mt-5 mx-3">
<h4>Edit Profil Sekolah</h4>
<div class="d-flex justify-content-center">
<img id="preview-image" src="{{ $school->image ? asset('storage/' . $school->image) : asset('assets/images/default-user.jpeg') }}" width="180px" alt="Foto Profil Sekolah">
<img id="preview-image" src="{{ $school->image && Storage::exists('public/' . $school->image) ? asset('storage/' . $school->image) : asset('assets/images/default-user.jpeg') }}" width="180px" alt="Foto Profil Sekolah">
</div>
<div class="d-flex justify-content-center mt-4">
<button type="button" id="change-photo-button" class="btn btn-primary px-4">Ganti Foto</button>
Expand Down
3 changes: 3 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Http\Controllers\Api\SchoolDetailController;
use App\Http\Controllers\Api\StafApiController;
use App\Http\Controllers\Api\StudentApiController;
use App\Http\Controllers\Api\TeacherApiController;
use App\Http\Controllers\Schools\PermissionController;
use App\Models\ModelHasRfid;
use App\Models\User;
Expand Down Expand Up @@ -90,6 +91,8 @@
Route::get('staf/list-point-student', [StafApiController::class, 'list_point_student']);
Route::get('staf/popular-violations', [StafApiController::class, 'popular_violations']);


Route::get('teacher/class/{user}', [TeacherApiController::class, 'class']);
Route::get('lesson-schedule/{user}', [LessonScheduleApiController::class, 'index']);
Route::get('teacher-journal/{lessonSchedule}', [LessonScheduleApiController::class, 'create']);
Route::get('history-journal/{user}', [LessonScheduleApiController::class, 'history']);
Expand Down

0 comments on commit c991953

Please sign in to comment.