au ah
This commit is contained in:
parent
0c37f99ee8
commit
ef91a16430
|
|
@ -1,68 +1,59 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Models\Guru;
|
use App\Models\Guru;
|
||||||
use App\Models\User;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class GuruController extends Controller
|
class GuruController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$guru = Guru::with('user')->get();
|
$guru = Guru::latest()->get();
|
||||||
return view('admin.guru.index', compact('guru'));
|
return view('admin.guru.index', compact('guru'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$users = User::all(); // misalnya guru punya relasi ke user
|
return view('admin.guru.create');
|
||||||
return view('admin.guru.create', compact('users'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'nama' => 'required|string|max:255',
|
'nama_guru' => 'required|string|max:100',
|
||||||
'bidang' => 'required|string|max:255',
|
'email' => 'nullable|email|max:100',
|
||||||
'alamat' => 'nullable|string',
|
'no_hp' => 'nullable|string|max:20',
|
||||||
'no_hp' => 'nullable|string',
|
'bidang' => 'nullable|string|max:100',
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
Guru::create($request->all());
|
|
||||||
return redirect()->route('guru.index')->with('success', 'Guru berhasil ditambahkan');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function show($id)
|
|
||||||
{
|
|
||||||
$guru = Guru::with('user')->findOrFail($id);
|
|
||||||
return view('admin.guru.show', compact('guru'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function edit($id)
|
|
||||||
{
|
|
||||||
$guru = Guru::findOrFail($id);
|
|
||||||
$users = User::all();
|
|
||||||
return view('admin.guru.edit', compact('guru', 'users'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request, $id)
|
|
||||||
{
|
|
||||||
$request->validate([
|
|
||||||
'user_id' => 'required|exists:users,id',
|
|
||||||
'bidang' => 'required|string|max:255',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$guru = Guru::findOrFail($id);
|
Guru::create($request->all());
|
||||||
$guru->update($request->all());
|
|
||||||
|
|
||||||
return redirect()->route('guru.index')->with('success', 'Data guru berhasil diperbarui');
|
return redirect()->route('guru.index')->with('success', 'Data guru berhasil ditambahkan.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy($id)
|
public function edit(Guru $guru)
|
||||||
{
|
{
|
||||||
Guru::destroy($id);
|
return view('admin.guru.edit', compact('guru'));
|
||||||
return redirect()->route('guru.index')->with('success', 'Guru berhasil dihapus');
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, Guru $guru)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'nama_guru' => 'required|string|max:100',
|
||||||
|
'email' => 'nullable|email|max:100',
|
||||||
|
'no_hp' => 'nullable|string|max:20',
|
||||||
|
'bidang' => 'nullable|string|max:100',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$guru->update($request->all());
|
||||||
|
return redirect()->route('guru.index')->with('success', 'Data guru berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Guru $guru)
|
||||||
|
{
|
||||||
|
$guru->delete();
|
||||||
|
return redirect()->route('guru.index')->with('success', 'Data guru berhasil dihapus.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Perkembangan;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class PerkembanganController extends Controller
|
||||||
|
{
|
||||||
|
// ✅ Admin hanya bisa lihat (read-only)
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$perkembangans = Perkembangan::orderBy('tanggal', 'desc')->get();
|
||||||
|
return view('admin.perkembangan.index', compact('perkembangans'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$perkembangan = Perkembangan::with(['siswa', 'guru'])->findOrFail($id);
|
||||||
|
return view('admin.perkembangan.show', compact('perkembangan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function print($id)
|
||||||
|
{
|
||||||
|
$perkembangan = Perkembangan::with(['siswa', 'guru'])->findOrFail($id);
|
||||||
|
return view('admin.perkembangan.print', compact('perkembangan'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,15 +2,18 @@
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Guru extends Model
|
class Guru extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
protected $table = 'guru';
|
protected $table = 'guru';
|
||||||
protected $fillable = ['user_id','bidang'];
|
|
||||||
|
|
||||||
public function user()
|
protected $fillable = [
|
||||||
{
|
'nama_guru',
|
||||||
return $this->belongsTo(User::class);
|
'email',
|
||||||
}
|
'no_hp',
|
||||||
|
'bidang',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Perkembangan extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'siswa_id', 'guru_id', 'tanggal', 'aspek', 'deskripsi', 'foto'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function siswa()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Siswa::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function guru()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Guru::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('perkembangans', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->unsignedBigInteger('siswa_id');
|
||||||
|
$table->unsignedBigInteger('guru_id');
|
||||||
|
$table->date('tanggal');
|
||||||
|
$table->string('aspek'); // contoh: Motorik, Bahasa, Sosial
|
||||||
|
$table->text('deskripsi');
|
||||||
|
$table->string('foto')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign('siswa_id')->references('id')->on('siswas')->onDelete('cascade');
|
||||||
|
$table->foreign('guru_id')->references('id')->on('users')->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('perkembangans');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -1,55 +1,34 @@
|
||||||
@extends('layouts.app')
|
@extends('layouts.app')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="bg-white shadow-md rounded-lg p-6">
|
<div class="container mx-auto p-4">
|
||||||
<div class="flex justify-between items-center mb-4">
|
<h1 class="text-2xl font-bold mb-4">Laporan Perkembangan Anak</h1>
|
||||||
<h1 class="text-xl font-semibold text-gray-700">👨🏫 Data Guru</h1>
|
|
||||||
<a href="{{ route('guru.create') }}"
|
|
||||||
class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700 transition">
|
|
||||||
+ Tambah Guru
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table class="w-full table-auto border-collapse">
|
@if($perkembangans->isEmpty())
|
||||||
<thead>
|
<p>Tidak ada data perkembangan yang tersedia.</p>
|
||||||
<tr class="bg-green-600 text-white text-left">
|
@else
|
||||||
<th class="p-2">#</th>
|
<table class="table-auto w-full border-collapse border border-gray-300">
|
||||||
<th class="p-2">Nama</th>
|
<thead class="bg-gray-100">
|
||||||
<th class="p-2">Bidang</th>
|
<tr>
|
||||||
<th class="p-2">Telepon</th>
|
<th class="border p-2">Nama Siswa</th>
|
||||||
<th class="p-2">Alamat</th>
|
<th class="border p-2">Tanggal</th>
|
||||||
<th class="p-2">Aksi</th>
|
<th class="border p-2">Aspek</th>
|
||||||
</tr>
|
<th class="border p-2">Deskripsi</th>
|
||||||
</thead>
|
<th class="border p-2">Guru</th>
|
||||||
<tbody>
|
</tr>
|
||||||
@forelse ($guru as $i => $item)
|
</thead>
|
||||||
<tr class="border-b hover:bg-gray-50">
|
<tbody>
|
||||||
<td class="p-2">{{ $i+1 }}</td>
|
@foreach($perkembangans as $p)
|
||||||
<td class="p-2">{{ $item->nama ?? '-' }}</td>
|
<tr>
|
||||||
<td class="p-2">{{ $item->bidang ?? '-' }}</td>
|
<td class="border p-2">{{ $p->siswa->nama ?? '-' }}</td>
|
||||||
<td class="p-2">{{ $item->telepon ?? '-' }}</td>
|
<td class="border p-2">{{ $p->tanggal }}</td>
|
||||||
<td class="p-2">{{ $item->alamat ?? '-' }}</td>
|
<td class="border p-2">{{ $p->aspek }}</td>
|
||||||
<td class="p-2 flex gap-2">
|
<td class="border p-2">{{ $p->deskripsi }}</td>
|
||||||
<a href="{{ route('guru.edit', $item->id) }}"
|
<td class="border p-2">{{ $p->guru->nama_guru ?? '-' }}</td>
|
||||||
class="bg-blue-500 text-white px-3 py-1 rounded hover:bg-blue-600">
|
</tr>
|
||||||
Edit
|
@endforeach
|
||||||
</a>
|
</tbody>
|
||||||
<form action="{{ route('guru.destroy', $item->id) }}" method="POST" onsubmit="return confirm('Yakin ingin menghapus data ini?')">
|
</table>
|
||||||
@csrf
|
@endif
|
||||||
@method('DELETE')
|
|
||||||
<button type="submit"
|
|
||||||
class="bg-red-500 text-white px-3 py-1 rounded hover:bg-red-600">
|
|
||||||
Hapus
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@empty
|
|
||||||
<tr>
|
|
||||||
<td colspan="6" class="text-center text-gray-500 p-4">Belum ada data guru</td>
|
|
||||||
</tr>
|
|
||||||
@endforelse
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="bg-white p-6 rounded-lg shadow">
|
||||||
|
<h1 class="text-2xl font-semibold mb-4">📊 Laporan Perkembangan Anak</h1>
|
||||||
|
|
||||||
|
<table class="w-full border-collapse border border-gray-300 text-sm">
|
||||||
|
<thead class="bg-green-600 text-white">
|
||||||
|
<tr>
|
||||||
|
<th class="p-2 border">No</th>
|
||||||
|
<th class="p-2 border">Nama Anak</th>
|
||||||
|
<th class="p-2 border">Guru</th>
|
||||||
|
<th class="p-2 border">Tanggal</th>
|
||||||
|
<th class="p-2 border">Aspek</th>
|
||||||
|
<th class="p-2 border">Deskripsi</th>
|
||||||
|
<th class="p-2 border">Aksi</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@forelse($perkembangans as $i => $item)
|
||||||
|
<tr class="hover:bg-gray-50">
|
||||||
|
<td class="p-2 border text-center">{{ $i+1 }}</td>
|
||||||
|
<td class="p-2 border">{{ $item->siswa->nama ?? '-' }}</td>
|
||||||
|
<td class="p-2 border">{{ $item->guru->nama_guru ?? '-' }}</td>
|
||||||
|
<td class="p-2 border">{{ $item->tanggal }}</td>
|
||||||
|
<td class="p-2 border">{{ $item->aspek }}</td>
|
||||||
|
<td class="p-2 border">{{ Str::limit($item->deskripsi, 40) }}</td>
|
||||||
|
<td class="p-2 border text-center">
|
||||||
|
<a href="{{ route('admin.perkembangan.show', $item->id) }}"
|
||||||
|
class="text-blue-600 hover:underline">Lihat</a> |
|
||||||
|
<a href="{{ route('admin.perkembangan.print', $item->id) }}"
|
||||||
|
class="text-green-600 hover:underline" target="_blank">Cetak</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr><td colspan="7" class="text-center p-4 text-gray-500">Belum ada data perkembangan</td></tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
@ -26,9 +26,9 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="#" class="flex items-center p-2 rounded-lg hover:bg-green-700 transition">
|
<a href="{{ route('admin.perkembangan.index') }}" class="flex items-center p-2 rounded-lg hover:bg-green-700 transition">
|
||||||
<i class="fas fa-chart-line mr-3"></i> Laporan Perkembangan
|
<i class="fas fa-chart-line mr-3"></i> Laporan Perkembangan
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="{{ route('pengumuman.index') }}" class="flex items-center p-2 rounded-lg hover:bg-green-700 transition">
|
<a href="{{ route('pengumuman.index') }}" class="flex items-center p-2 rounded-lg hover:bg-green-700 transition">
|
||||||
<i class="fas fa-bullhorn mr-3"></i> Menu Pengumuman
|
<i class="fas fa-bullhorn mr-3"></i> Menu Pengumuman
|
||||||
|
|
|
||||||
|
|
@ -42,5 +42,4 @@
|
||||||
'update' => 'api.siswa.update',
|
'update' => 'api.siswa.update',
|
||||||
'destroy' => 'api.siswa.destroy',
|
'destroy' => 'api.siswa.destroy',
|
||||||
]);
|
]);
|
||||||
Route::middleware('auth:sanctum')->get('/wali/perkembangan', [ApiPerkembangan::class,'index']);
|
|
||||||
});
|
});
|
||||||
|
|
@ -7,8 +7,7 @@
|
||||||
use App\Http\Controllers\Admin\WaliMuridController;
|
use App\Http\Controllers\Admin\WaliMuridController;
|
||||||
use App\Http\Controllers\Admin\SiswaController;
|
use App\Http\Controllers\Admin\SiswaController;
|
||||||
use App\Http\Controllers\Admin\PengumumanController;
|
use App\Http\Controllers\Admin\PengumumanController;
|
||||||
use App\Http\Controllers\Guru\PerkembanganController as GuruPerkembangan;
|
use App\Http\Controllers\Admin\PerkembanganController;
|
||||||
use App\Http\Controllers\Admin\PerkembanganController as AdminPerkembangan;
|
|
||||||
|
|
||||||
// Login routes
|
// Login routes
|
||||||
Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
|
Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
|
||||||
|
|
@ -30,13 +29,12 @@
|
||||||
Route::resource('wali', WaliMuridController::class);
|
Route::resource('wali', WaliMuridController::class);
|
||||||
Route::resource('siswa', SiswaController::class);
|
Route::resource('siswa', SiswaController::class);
|
||||||
|
|
||||||
Route::middleware(['auth','role:guru'])->prefix('guru')->name('guru.')->group(function(){
|
Route::middleware(['auth'])->group(function () {
|
||||||
Route::resource('perkembangan', GuruPerkembangan::class);
|
Route::prefix('admin')->group(function () {
|
||||||
});
|
Route::get('/perkembangan', [PerkembanganController::class, 'index'])->name('admin.perkembangan.index');
|
||||||
|
Route::get('/perkembangan/{id}', [PerkembanganController::class, 'show'])->name('admin.perkembangan.show');
|
||||||
Route::middleware(['auth','role:admin'])->prefix('admin')->name('admin.')->group(function(){
|
Route::get('/perkembangan/{id}/print', [PerkembanganController::class, 'print'])->name('admin.perkembangan.print');
|
||||||
Route::get('perkembangan', [AdminPerkembangan::class, 'index'])->name('perkembangan.index');
|
|
||||||
Route::get('perkembangan/{id}', [AdminPerkembangan::class, 'show'])->name('perkembangan.show');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue