Siopas Inventory PETI for ISTW Website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
3.0 KiB

1 year ago
<?php
namespace App\Http\Controllers;
1 year ago
use App\Models\asset_status;
use App\Models\m_asset;
use App\Models\m_warehouse;
1 year ago
use Illuminate\Http\Request;
1 year ago
use Illuminate\Support\Facades\Auth;
1 year ago
class PengembalianController extends Controller
{
public function index()
{
1 year ago
// dd('oke');
$peminjaman = asset_status::get();
return view('dashboard.Pengembalian.index', compact('peminjaman'));
1 year ago
}
/**
* 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)
1 year ago
{
$warehouse = m_warehouse::get();
$peminjaman = asset_status::findOrFail($id);
return view('dashboard.Pengembalian.edit', compact('peminjaman', 'warehouse'));
1 year ago
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id)
{
$request->validate([
'asset_id' => 'required',
'exit_at' => 'required',
'exit_pic' => 'required',
'enter_at' => 'required',
'enter_pic' => 'required',
'enter_warehouse' => 'required',
]);
1 year ago
try {
$peminjaman = asset_status::findOrFail($id);
$peminjaman['updated_by'] = Auth::user()->fullname; // Menambahkan ID pengguna sebagai updated_by
1 year ago
$peminjaman->update($request->all());
return redirect()->route('dashboard.pengembalian.index')->with('success', 'Data peminjaman berhasil diperbaharui');
1 year ago
} catch (\Throwable $th) {
// Tampilkan pesan kesalahan untuk debugging
return redirect()->back()->with('error', 'Data peminjaman gagal diperbaharui: ' . $th->getMessage());
1 year ago
}
}
// public function update(Request $request, $id)
// {
// $request->validate([
// 'asset_id' => 'required',
// 'exit_at' => 'required',
// 'exit_pic' => 'required',
// 'enter_at' => 'required',
// 'enter_pic' => 'required',
// 'enter_warehouse' => 'required',
// ]);
// try {
// $peminjaman = asset_status::findOrFail($id);
// $peminjaman['updated_by'] = Auth::user()->fullname; // Menambahkan ID pengguna sebagai updated_by
// $peminjaman->update($request->all());
// return redirect()->route('pengembalian.index')->with('success', 'Data peminjaman berhasil diperbaharui');
// } catch (\Throwable $th) {
// return redirect()->back()->with('error', 'Data peminjaman gagal diperbaharui');
// }
// }
1 year ago
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
// dd("oke");
1 year ago
}
}