|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Http\Requests\ValidasiUpdatePengembalian;
|
|
|
|
use App\Models\Peti;
|
|
|
|
use App\Models\m_warehouse;
|
|
|
|
use App\Models\asset_status;
|
|
|
|
use App\Models\Kondisi_Peti;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
|
|
|
class PengembalianController extends Controller
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$pengembalian = asset_status::orderBy('created_at', 'desc')->get();
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
'peminjaman' => $pengembalian,
|
|
|
|
'active' => 'menu-pengembalian',
|
|
|
|
];
|
|
|
|
|
|
|
|
return view('dashboard.Pengembalian.index', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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($id)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*/
|
|
|
|
public function edit($id)
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
'peti' => Peti::get(),
|
|
|
|
'peminjaman' => asset_status::findOrFail($id),
|
|
|
|
'warehouse' => m_warehouse::get(),
|
|
|
|
'kondisiPeti' => Kondisi_Peti::get(),
|
|
|
|
'active' => 'menu-pengembalian',
|
|
|
|
];
|
|
|
|
return view('dashboard.Pengembalian.edit', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*/
|
|
|
|
public function update(ValidasiUpdatePengembalian $request, $id)
|
|
|
|
{
|
|
|
|
// dd($request);
|
|
|
|
try {
|
|
|
|
$peminjaman = asset_status::findOrFail($id);
|
|
|
|
|
|
|
|
// Update atribut-atribut yang diperlukan
|
|
|
|
$peminjaman->enter_pic = Auth::user()->fullname;
|
|
|
|
$peminjaman->updated_by = Auth::user()->fullname;
|
|
|
|
|
|
|
|
$peminjaman->peti_id = $request->input('peti_id');
|
|
|
|
$peminjaman->exit_at = $request->input('exit_at');
|
|
|
|
$peminjaman->est_pengembalian = $request->input('est_pengembalian');
|
|
|
|
$peminjaman->exit_warehouse = $request->input('exit_warehouse');
|
|
|
|
$peminjaman->enter_at = $request->input('enter_at');
|
|
|
|
$peminjaman->enter_warehouse = $request->input('enter_warehouse');
|
|
|
|
$peminjaman->kondisi_peti_id = $request->input('kondisi_peti_id');
|
|
|
|
// Mengatur status menjadi 1 secara otomatis
|
|
|
|
$peminjaman->status = 1;
|
|
|
|
// dd($peminjaman);
|
|
|
|
$peminjaman->save();
|
|
|
|
|
|
|
|
return redirect()->route('dashboard.pengembalian.index')->with('success', 'Data peminjaman berhasil diperbaharui');
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
// Tampilkan pesan kesalahan untuk debugging
|
|
|
|
return redirect()->back()->with('error', 'Data peminjaman gagal diperbaharui: ' . $th->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*/
|
|
|
|
public function destroy($id)
|
|
|
|
{
|
|
|
|
// dd("oke");
|
|
|
|
}
|
|
|
|
}
|