From d29c283a5004e0e011a59494c2a49165cd828d8b Mon Sep 17 00:00:00 2001 From: FahrezaDaffa93 <117092951+FahrezaDaffa93@users.noreply.github.com> Date: Sat, 17 Feb 2024 20:12:46 +0700 Subject: [PATCH] fixing banyak --- app/Http/Controllers/AturanController.php | 70 +++++++++++++++++++ app/Http/Controllers/GejalaController.php | 65 +++++++++++++++++ app/Http/Controllers/PenyakitController.php | 66 +++++++++++++++++ app/Models/Aturan.php | 15 +++- app/Models/Gejala.php | 2 + app/Models/Penyakit.php | 2 + .../2024_02_13_014922_create_gejala_table.php | 6 +- ...24_02_13_015637_create_penyakit_table.php} | 0 .../2024_02_13_015750_create_aturan_table.php | 7 ++ resources/views/aturan.blade.php | 6 -- resources/views/aturan/aturan.blade.php | 43 ++++++++++++ resources/views/gejala.blade.php | 24 +++---- resources/views/layouts/master.blade.php | 15 ++-- resources/views/penyakit.blade.php | 6 -- resources/views/penyakit/penyakit.blade.php | 20 ++++++ routes/web.php | 17 +++-- 16 files changed, 315 insertions(+), 49 deletions(-) create mode 100644 app/Http/Controllers/AturanController.php create mode 100644 app/Http/Controllers/GejalaController.php create mode 100644 app/Http/Controllers/PenyakitController.php rename database/migrations/{2024_02_13_015937_create_penyakit_table.php => 2024_02_13_015637_create_penyakit_table.php} (100%) delete mode 100644 resources/views/aturan.blade.php create mode 100644 resources/views/aturan/aturan.blade.php delete mode 100644 resources/views/penyakit.blade.php create mode 100644 resources/views/penyakit/penyakit.blade.php diff --git a/app/Http/Controllers/AturanController.php b/app/Http/Controllers/AturanController.php new file mode 100644 index 0000000..05c0a6c --- /dev/null +++ b/app/Http/Controllers/AturanController.php @@ -0,0 +1,70 @@ +get(); + return view("aturan.aturan", compact('aturan','gejalas')); + } + + /** + * 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(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) + { + // + } +} diff --git a/app/Http/Controllers/GejalaController.php b/app/Http/Controllers/GejalaController.php new file mode 100644 index 0000000..4a047c3 --- /dev/null +++ b/app/Http/Controllers/GejalaController.php @@ -0,0 +1,65 @@ +belongsTo(Gejala::class, 'id_gejala'); + } + + // Relasi ke model Penyakit + public function penyakit() + { + return $this->belongsTo(Penyakit::class, 'id_penyakit'); + } } diff --git a/app/Models/Gejala.php b/app/Models/Gejala.php index b3d88d6..519ccc6 100644 --- a/app/Models/Gejala.php +++ b/app/Models/Gejala.php @@ -8,4 +8,6 @@ class Gejala extends Model { use HasFactory; + protected $table='gejala'; + protected $primaryKey='id_gejala'; } diff --git a/app/Models/Penyakit.php b/app/Models/Penyakit.php index 421ddee..85cf31c 100644 --- a/app/Models/Penyakit.php +++ b/app/Models/Penyakit.php @@ -8,4 +8,6 @@ class Penyakit extends Model { use HasFactory; + protected $table="penyakit"; + protected $primaryKey="id_penyakit"; } diff --git a/database/migrations/2024_02_13_014922_create_gejala_table.php b/database/migrations/2024_02_13_014922_create_gejala_table.php index a40449e..c154f93 100644 --- a/database/migrations/2024_02_13_014922_create_gejala_table.php +++ b/database/migrations/2024_02_13_014922_create_gejala_table.php @@ -1,5 +1,4 @@ increments('id_gejala'); + $table->id('id_gejala'); $table->string('kode_gejala'); $table->string('gejala'); + $table->timestamps(); }); } @@ -24,6 +24,6 @@ public function up(): void */ public function down(): void { - Schema::dropIfExists('gejalas'); + Schema::dropIfExists('gejala'); // Menghapus tabel gejala } }; diff --git a/database/migrations/2024_02_13_015937_create_penyakit_table.php b/database/migrations/2024_02_13_015637_create_penyakit_table.php similarity index 100% rename from database/migrations/2024_02_13_015937_create_penyakit_table.php rename to database/migrations/2024_02_13_015637_create_penyakit_table.php diff --git a/database/migrations/2024_02_13_015750_create_aturan_table.php b/database/migrations/2024_02_13_015750_create_aturan_table.php index c5284c6..0404954 100644 --- a/database/migrations/2024_02_13_015750_create_aturan_table.php +++ b/database/migrations/2024_02_13_015750_create_aturan_table.php @@ -13,8 +13,15 @@ public function up(): void { Schema::create('aturan', function (Blueprint $table) { $table->id('id_aturan'); + $table->unsignedBigInteger('id_gejala'); + $table->unsignedBigInteger('id_penyakit'); + $table->float('belief'); + + $table->foreign('id_gejala')->references('id_gejala')->on('gejala')->onDelete('cascade'); + $table->foreign('id_penyakit')->references('id_penyakit')->on('penyakit')->onDelete('cascade'); }); + } /** diff --git a/resources/views/aturan.blade.php b/resources/views/aturan.blade.php deleted file mode 100644 index c5b86ab..0000000 --- a/resources/views/aturan.blade.php +++ /dev/null @@ -1,6 +0,0 @@ -@extends('layouts.master') -@section('title', 'aturan') - -@section('konten') - -@endsection diff --git a/resources/views/aturan/aturan.blade.php b/resources/views/aturan/aturan.blade.php new file mode 100644 index 0000000..a644c57 --- /dev/null +++ b/resources/views/aturan/aturan.blade.php @@ -0,0 +1,43 @@ +@extends('layouts.master') +@section('title', 'aturan') + +@section('konten') +
No | +Kode Gejala | +Gejala | +Penyakit | +Nilai Kepercayaan | +Action | +
---|---|---|---|---|---|
{{ $loop->iteration }} | +{{ optional($group->first()->gejala)->kode_gejala}} | +{{ optional($group->first()->gejala)->gejala}} | +
+ @foreach ($group as $data)
+ {{ $data->penyakit->nama_penyakit }} ({{ $data->penyakit->kode_penyakit }}) + @endforeach + |
+ {{ $group->first()->belief }} | ++ + + + | +