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') +
+
+
+
+

Manajemen Data Tindakan

+
+
+ +
+
+
+
+@endsection + +@section('main-content') +
+
+ +
+
+ + + + + + + + + + + @foreach ($treatments as $index => $data) + + + + + + + @endforeach + +
NoNama TindakanHarga TindakanAksi
{{ $index + 1 }}{{ $data->name }}Rp. {{ number_format($data->fee) }} + +   Edit + + +
+
+ +
+ + + + + + + + + +@endsection + +@push('scripts') + @if (session('success')) + + @endif + @if (session('error')) + + @endif + + + + + + + +@endpush diff --git a/routes/web.php b/routes/web.php index fedb778..1baeff4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,8 +4,8 @@ use App\Http\Controllers\AuthController; use App\Http\Controllers\DashboardController; use App\Http\Controllers\ManageUserController; use App\Http\Controllers\ProfileController; -use App\Http\Controllers\DocumentTypeController; use App\Http\Controllers\InsuranceController; +use App\Http\Controllers\TreatmentController; use Illuminate\Support\Facades\Route; /* @@ -52,6 +52,12 @@ Route::middleware('auth')->group(function () { Route::post('/asuransi', [InsuranceController::class, 'store'])->name('insurance.store'); Route::put('/asuransi/{id}', [InsuranceController::class, 'update'])->name('insurance.update'); Route::delete('/asuransi/{id}', [InsuranceController::class, 'destroy'])->name('insurance.destroy'); + + # Manage Jenis Tindakan + Route::get('/tindakan', [TreatmentController::class, 'index'])->name('treatment.index'); + Route::post('/tindakan', [TreatmentController::class, 'store'])->name('treatment.store'); + Route::put('/tindakan/{id}', [TreatmentController::class, 'update'])->name('treatment.update'); + Route::delete('/tindakan/{id}', [TreatmentController::class, 'destroy'])->name('treatment.destroy'); }); // Profile Page