MIF_E31210245/app/Http/Controllers/TransactionController.php

74 lines
1.5 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Transaksi;
use Illuminate\Http\Request;
class TransactionController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
return view('pages.data-transaksi');
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
try {
// Simpan data ke database
Transaksi::create($request->all());
return redirect()->route('data-transaksi.index')->with('success', 'Data berhasil disimpan.');
} catch (\Exception $e) {
// Tangkap pengecualian dan tampilkan pesan kesalahan
return redirect()->route('data-transaksi.index')->with('error', 'Key yang anda masukkan tidak ada di saldo mon');
}
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(string $id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}