-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
menambahkan fitur kamar, mapel, riwayat yang sudah fix
- Loading branch information
1 parent
aaf3e54
commit ceeed72
Showing
52 changed files
with
1,759 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Kamar; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Kamar; | ||
use Illuminate\Http\Request; | ||
use Toastr; | ||
|
||
class KamarController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$kamar = Kamar::all(); | ||
|
||
return view('pages.kamar.index', compact('kamar')); | ||
} | ||
|
||
public function store(Request $request) | ||
{ | ||
$validate = $request->validate([ | ||
'nama' => 'required|min:3|unique:kamars,nama', | ||
'blok' => 'required|min:1', | ||
'jumlah_santri' => 'required|numeric|min:0', | ||
'maksimal_santri' => 'required|numeric|min:0', | ||
]); | ||
|
||
try { | ||
Kamar::create($validate); | ||
Toastr::success('Berhasil menambah data'); | ||
return redirect()->back(); | ||
} catch (\Throwable $th) { | ||
Toastr::error('Gagal menambah data'); | ||
return redirect()->back(); | ||
} | ||
} | ||
|
||
public function update(Request $request, Kamar $kamar) | ||
{ | ||
$validate = $request->validate([ | ||
'nama' => "required|min:3|unique:kamars,nama,$kamar->id", | ||
'blok' => 'required|min:1', | ||
'jumlah_santri' => 'required|numeric|min:0', | ||
'maksimal_santri' => 'required|numeric|min:0', | ||
]); | ||
try { | ||
$kamar->update($validate); | ||
Toastr::success('Berhasil merubah data'); | ||
|
||
return redirect()->back(); | ||
} catch (\Throwable $th) { | ||
Toastr::error('Gagal merubah data'); | ||
|
||
return redirect()->back()->withInput(); | ||
} | ||
} | ||
|
||
public function destroy(Kamar $kamar) | ||
{ | ||
try { | ||
if ($kamar->jumlah_santri == 0) { | ||
$kamar->delete(); | ||
Toastr::success('Berhasil menghapus data'); | ||
} else { | ||
Toastr::info('Kamar telah diisi, tidak dapat dihapus'); | ||
} | ||
return redirect()->back(); | ||
} catch (\Throwable $th) { | ||
Toastr::error('Gagal menghapus data'); | ||
return redirect()->back(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\MataPelajaran; | ||
use Illuminate\Http\Request; | ||
use Toastr; | ||
|
||
class MapelController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$mapel = MataPelajaran::all(); | ||
return view('pages.mapel.index', compact('mapel')); | ||
} | ||
public function store(Request $request) | ||
{ | ||
$validate = $request->validate([ | ||
'kategori' => 'required|in:Fan Pokok, Non Pokok, Tes Kelas Tertentu, Absensi, Kondisi Siswa', | ||
'nama' => 'required|string|min:5' | ||
]); | ||
try { | ||
MataPelajaran::create($validate); | ||
Toastr::success('Berhasil menyimpan data'); | ||
return redirect()->back(); | ||
} catch (\Throwable $th) { | ||
Toastr::error('Gagal menyimpan data'); | ||
return redirect()->back(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Rapor; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Kelas; | ||
use App\Models\MataPelajaran; | ||
use App\Models\RaporSantri; | ||
use App\Models\Santri; | ||
use Illuminate\Http\Request; | ||
|
||
class RaportSantriController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$kelas = Kelas::get(); | ||
return view('pages.rapor.index', compact('kelas')); | ||
} | ||
|
||
public function santri(Kelas $kelas) | ||
{ | ||
$santri = Santri::where('kelas_id', $kelas->id)->get(); | ||
return view('pages.rapor.santri', compact('santri', 'kelas')); | ||
} | ||
public function nilai(Santri $santri) | ||
{ | ||
$rapor = RaporSantri::join('mata_pelajarans', 'rapor_santris.mata_pelajaran_id', '=', 'mata_pelajarans.id') | ||
->where('santri_id', $santri->id) | ||
->get(); | ||
|
||
$mapel = MataPelajaran::all(); | ||
|
||
$kelas = Kelas::where('id', $santri->kelas_id)->first(); | ||
return view('pages.rapor.nilai', [ | ||
'rapor' => $rapor->isEmpty() ? $mapel : $rapor, | ||
'santri' => $santri, | ||
'kelas' => $kelas | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Riwayat; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\ActivityLog; | ||
use Illuminate\Http\Request; | ||
|
||
class RiwayatController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$riwayat = ActivityLog::with('user')->get(); | ||
return view('pages.riwayat.index', compact('riwayat')); | ||
} | ||
} |
Oops, something went wrong.