diff --git a/app/Http/Controllers/TreatmentController.php b/app/Http/Controllers/TreatmentController.php index e23c630..91d25db 100644 --- a/app/Http/Controllers/TreatmentController.php +++ b/app/Http/Controllers/TreatmentController.php @@ -2,9 +2,62 @@ namespace App\Http\Controllers; +use App\Models\Treatment; use Illuminate\Http\Request; class TreatmentController extends Controller { - // + /** + * Display a listing of the resource. + */ + public function index() + { + $treatments = Treatment::all(); + return view('treatment.index', compact('treatments')); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + $data = $request->validate([ + 'name' => 'required|string|max:255', + 'fee' => 'required|numeric|min:0', + ]); + + Treatment::create($data); + + return redirect()->route('treatment.index') + ->with('success', 'Jenis Tindakan berhasil ditambahkan.'); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, $id) + { + $data = $request->validate([ + 'name' => 'required|string|max:255', + 'fee' => 'required|numeric|min:0', + ]); + + $insurance = Treatment::findOrFail($id); + $insurance->update($data); + + return redirect()->route('treatment.index') + ->with('success', 'Jenis Tindakan berhasil diperbarui.'); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy($id) + { + $insurance = Treatment::findOrFail($id); + $insurance->delete(); + + return redirect()->route('treatment.index') + ->with('success', 'Jenis Tindakan berhasil dihapus.'); + } } diff --git a/app/Models/Treatment.php b/app/Models/Treatment.php index 7f5a28f..c56e46e 100644 --- a/app/Models/Treatment.php +++ b/app/Models/Treatment.php @@ -9,4 +9,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class Treatment extends Model { use HasFactory, SoftDeletes; + + protected $table = "treatments"; + protected $guarded = ["id"]; } diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index 5cb0938..e532b22 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -39,6 +39,13 @@ 'childs' => [], 'is_admin' => true, // Menambahkan field ini untuk mengontrol akses ], + (object) [ + 'icon' => 'fas fa-list', + 'name' => 'Jenis Tindakan', + 'link' => '/tindakan', + 'childs' => [], + 'is_admin' => true, // Menambahkan field ini untuk mengontrol akses + ], (object) [ 'icon' => 'fas fa-user', 'name' => 'Manajemen Pegawai', @@ -46,23 +53,6 @@ 'childs' => [], 'is_admin' => true, // Menambahkan field ini untuk mengontrol akses ], - (object) [ - 'title' => 'DROPDOWN EXAMPLE', - ], - (object) [ - 'icon' => 'fas fa-book', - 'name' => 'Dropdown Example', - 'childs' => [ - (object) [ - 'name' => 'Dropdown 1', - 'link' => '#', - ], - (object) [ - 'name' => 'Dropdown 2', - 'link' => '#', - ], - ], - ], (object) [ 'title' => 'AKUN PENGGUNA', ], diff --git a/resources/views/treatment/index.blade.php b/resources/views/treatment/index.blade.php new file mode 100644 index 0000000..67fde9d --- /dev/null +++ b/resources/views/treatment/index.blade.php @@ -0,0 +1,235 @@ +@extends('layouts.app') + +@push('styles') + + + + +@endpush + +@section('content-header') +
| No | +Nama Tindakan | +Harga Tindakan | +Aksi | +
|---|---|---|---|
| {{ $index + 1 }} | +{{ $data->name }} | +Rp. {{ number_format($data->fee) }} | ++ + Edit + + + | +