-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
743 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
/node_modules | ||
/public/hot | ||
/public/storage | ||
/public/images/ | ||
/storage/*.key | ||
.env | ||
.env.backup | ||
.phpunit.result.cache | ||
|
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,29 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
use App\Models\User; | ||
|
||
use Illuminate\Http\Request; | ||
|
||
class ListAnggotaController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$anggota = User::all(); | ||
$unverified = User::where('is_verified', 0)->get(); | ||
|
||
if (request()->has('search')) { | ||
$anggota = User::where('name', 'LIKE', '%' . request('search') . '%')->get(); | ||
} | ||
|
||
return view('admin.list-anggota.index', compact('anggota', 'unverified')); | ||
} | ||
|
||
public function verify() | ||
{ | ||
$anggota = User::find(request()->id); | ||
$anggota->is_verified = 1; | ||
$anggota->save(); | ||
return back()->with('success', 'Berhasil mengkonfirmasi data!'); | ||
} | ||
} |
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,84 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use App\Models\Buku; | ||
use App\Models\User; | ||
use App\Models\Admin; | ||
use App\Models\Peminjaman; | ||
use App\Models\Pengembalian; | ||
|
||
class PeminjamanController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$buku = Buku::all(); | ||
$anggota = User::all(); | ||
$petugas = Admin::all(); | ||
$peminjaman = Peminjaman::where('status', '!=', 'tersedia')->get(); | ||
$booking = Peminjaman::where('status', 'booking')->get(); | ||
|
||
return view('admin.peminjaman.index', compact('buku', 'anggota', 'petugas', 'peminjaman', 'booking')); | ||
} | ||
|
||
public function verify() | ||
{ | ||
date_default_timezone_set('Asia/Jakarta'); | ||
$dt = Peminjaman::find(request()->id); | ||
$buku = Buku::findOrFail($dt->buku_id); | ||
|
||
$buku->status = 'dipinjam'; | ||
$dt->admin_id = auth()->user()->id; | ||
$dt->status = request()->status; | ||
$dt->tanggal_kembali = date_format(date_create(request()->tanggal_kembali), 'Y-m-d'); | ||
|
||
$buku->save(); | ||
$dt->save(); | ||
|
||
return back()->with('success', 'Buku dipinjamkan'); | ||
} | ||
|
||
public function findById(Request $request, $id) | ||
{ | ||
$dt = Peminjaman::findOrFail($id); | ||
|
||
return view('admin.peminjaman.view', compact('dt')); | ||
} | ||
|
||
public function update(Request $request, $id) | ||
{ | ||
date_default_timezone_set('Asia/Jakarta'); | ||
$peminjaman = Peminjaman::findOrFail($id); | ||
$buku = Buku::findOrFail($peminjaman->buku_id); | ||
|
||
$pengembalian = new Pengembalian(); | ||
|
||
$buku->status = 'tersedia'; | ||
|
||
$pengembalian->tanggal_kembali = date_format(date_create(request()->tanggal_kembali), 'Y-m-d'); | ||
$pengembalian->jatuh_tempo = $peminjaman->tanggal_kembali; | ||
|
||
$jumlah_hari = date_diff(date_create($peminjaman->tanggal_kembali), date_create(request()->tanggal_kembali))->days; | ||
|
||
if ($jumlah_hari > 0) { | ||
$pengembalian->jumlah_hari = $jumlah_hari; | ||
$pengembalian->total_denda = $jumlah_hari * $peminjaman->buku->denda; | ||
$pengembalian->status = 'Denda'; | ||
} else { | ||
$pengembalian->jumlah_hari = 0; | ||
$pengembalian->total_denda = 0; | ||
$pengembalian->status = 'Tepat Waktu'; | ||
} | ||
|
||
$pengembalian->buku_id = $peminjaman->buku->id; | ||
$pengembalian->admin_id = auth()->user()->id; | ||
$pengembalian->user_id = $peminjaman->user->id; | ||
|
||
$pengembalian->save(); | ||
$buku->save(); | ||
$peminjaman->delete(); | ||
|
||
return redirect()->route('admin.peminjaman')->with('success', 'Buku dipinjamkan'); | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use App\Models\Pengembalian; | ||
|
||
class PengembalianController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$data = Pengembalian::all(); | ||
$verif_status = Pengembalian::where('status', '=', 'denda')->get(); | ||
|
||
if (auth()->user()->is_verified == 1) { | ||
$data = Pengembalian::where('user_id', '=', auth()->user()->id)->get(); | ||
return view('user.denda.index', compact('data', 'verif_status')); | ||
} | ||
return view('admin.pengembalian.index', compact('data', 'verif_status')); | ||
} | ||
|
||
public function verify() | ||
{ | ||
$dt = Pengembalian::find(request()->id); | ||
|
||
$dt->status = request()->status; | ||
$dt->jumlah_hari = 0; | ||
$dt->total_denda = 0; | ||
|
||
$dt->save(); | ||
|
||
return back()->with('success', 'Denda terbayar'); | ||
} | ||
} |
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
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
Oops, something went wrong.