From 36514e912397715ce50ee6f14aa0cd92f3655088 Mon Sep 17 00:00:00 2001 From: E31232303evimr <158023512+E31232303evimr@users.noreply.github.com> Date: Wed, 4 Mar 2026 01:18:14 +0700 Subject: [PATCH] user-diagnosa done --- .../Controllers/User/DiagnosaController.php | 45 +- composer.json | 1 + composer.lock | 524 +++++++++++++++++- resources/views/user/diagnosa/hasil.blade.php | 286 ++++++---- resources/views/user/diagnosa/index.blade.php | 14 +- resources/views/user/diagnosa/pdf.blade.php | 280 ++++++++++ .../views/user/diagnosa/riwayat.blade.php | 39 +- routes/web.php | 2 + 8 files changed, 1065 insertions(+), 126 deletions(-) create mode 100644 resources/views/user/diagnosa/pdf.blade.php diff --git a/app/Http/Controllers/User/DiagnosaController.php b/app/Http/Controllers/User/DiagnosaController.php index 039cee2..9192fa6 100644 --- a/app/Http/Controllers/User/DiagnosaController.php +++ b/app/Http/Controllers/User/DiagnosaController.php @@ -8,6 +8,7 @@ use App\Models\RuleBasis; use App\Models\RiwayatDiagnosis; use Illuminate\Http\Request; +use Barryvdh\DomPDF\Facade\Pdf; class DiagnosaController extends Controller { @@ -97,14 +98,20 @@ public function hasil($id) { $riwayat = RiwayatDiagnosis::with('penyakit')->findOrFail($id); - // Pastikan hanya pemilik yang bisa lihat if ($riwayat->user_id !== auth()->id()) { abort(403); } $gejalaInput = MasterGejala::whereIn('id_gejala', $riwayat->gejala_input)->get(); - return view('user.diagnosa.hasil', compact('riwayat', 'gejalaInput')); + // Ambil relasi gejala-penyakit dari rule_basis + $relasiGejala = RuleBasis::whereIn('id_gejala', $riwayat->gejala_input) + ->whereIn('id_penyakit', collect($riwayat->hasil_diagnosa)->pluck('id_penyakit')) + ->with(['penyakit', 'gejala']) + ->get() + ->groupBy('id_penyakit'); + + return view('user.diagnosa.hasil', compact('riwayat', 'gejalaInput', 'relasiGejala')); } public function riwayat() @@ -116,4 +123,38 @@ public function riwayat() return view('user.diagnosa.riwayat', compact('riwayats')); } + + public function destroy($id) + { + $riwayat = RiwayatDiagnosis::findOrFail($id); + + if ($riwayat->user_id !== auth()->id()) { + abort(403); + } + + $riwayat->delete(); + + return redirect()->route('user.diagnosa.riwayat') + ->with('success', 'Riwayat diagnosa berhasil dihapus!'); + } + + public function downloadPdf($id) + { + $riwayat = RiwayatDiagnosis::with('penyakit')->findOrFail($id); + + if ($riwayat->user_id !== auth()->id()) { + abort(403); + } + + $gejalaInput = MasterGejala::whereIn('id_gejala', $riwayat->gejala_input)->get(); + + $relasiGejala = RuleBasis::whereIn('id_gejala', $riwayat->gejala_input) + ->whereIn('id_penyakit', collect($riwayat->hasil_diagnosa)->pluck('id_penyakit')) + ->get() + ->groupBy('id_penyakit'); + + $pdf = Pdf::loadView('user.diagnosa.pdf', compact('riwayat', 'gejalaInput', 'relasiGejala')); + + return $pdf->download('hasil-diagnosa-' . $riwayat->id_diagnosis . '.pdf'); + } } \ No newline at end of file diff --git a/composer.json b/composer.json index 682ddb0..32bcb9a 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "license": "MIT", "require": { "php": "^8.2", + "barryvdh/laravel-dompdf": "^3.1", "laravel/framework": "^12.0", "laravel/tinker": "^2.10.1" }, diff --git a/composer.lock b/composer.lock index ef39751..6a3478d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,85 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bdc6d92507d397adf1c269ed49ec424d", + "content-hash": "90ba1bfa56afef0cd88d7d3c0cdcf358", "packages": [ + { + "name": "barryvdh/laravel-dompdf", + "version": "v3.1.1", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-dompdf.git", + "reference": "8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d", + "reference": "8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d", + "shasum": "" + }, + "require": { + "dompdf/dompdf": "^3.0", + "illuminate/support": "^9|^10|^11|^12", + "php": "^8.1" + }, + "require-dev": { + "larastan/larastan": "^2.7|^3.0", + "orchestra/testbench": "^7|^8|^9|^10", + "phpro/grumphp": "^2.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "PDF": "Barryvdh\\DomPDF\\Facade\\Pdf", + "Pdf": "Barryvdh\\DomPDF\\Facade\\Pdf" + }, + "providers": [ + "Barryvdh\\DomPDF\\ServiceProvider" + ] + }, + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\DomPDF\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "A DOMPDF Wrapper for Laravel", + "keywords": [ + "dompdf", + "laravel", + "pdf" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-dompdf/issues", + "source": "https://github.com/barryvdh/laravel-dompdf/tree/v3.1.1" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2025-02-13T15:07:54+00:00" + }, { "name": "brick/math", "version": "0.14.7", @@ -377,6 +454,161 @@ ], "time": "2024-02-05T11:56:58+00:00" }, + { + "name": "dompdf/dompdf", + "version": "v3.1.5", + "source": { + "type": "git", + "url": "https://github.com/dompdf/dompdf.git", + "reference": "f11ead23a8a76d0ff9bbc6c7c8fd7e05ca328496" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/f11ead23a8a76d0ff9bbc6c7c8fd7e05ca328496", + "reference": "f11ead23a8a76d0ff9bbc6c7c8fd7e05ca328496", + "shasum": "" + }, + "require": { + "dompdf/php-font-lib": "^1.0.0", + "dompdf/php-svg-lib": "^1.0.0", + "ext-dom": "*", + "ext-mbstring": "*", + "masterminds/html5": "^2.0", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "ext-gd": "*", + "ext-json": "*", + "ext-zip": "*", + "mockery/mockery": "^1.3", + "phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11", + "squizlabs/php_codesniffer": "^3.5", + "symfony/process": "^4.4 || ^5.4 || ^6.2 || ^7.0" + }, + "suggest": { + "ext-gd": "Needed to process images", + "ext-gmagick": "Improves image processing performance", + "ext-imagick": "Improves image processing performance", + "ext-zlib": "Needed for pdf stream compression" + }, + "type": "library", + "autoload": { + "psr-4": { + "Dompdf\\": "src/" + }, + "classmap": [ + "lib/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ + { + "name": "The Dompdf Community", + "homepage": "https://github.com/dompdf/dompdf/blob/master/AUTHORS.md" + } + ], + "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter", + "homepage": "https://github.com/dompdf/dompdf", + "support": { + "issues": "https://github.com/dompdf/dompdf/issues", + "source": "https://github.com/dompdf/dompdf/tree/v3.1.5" + }, + "time": "2026-03-03T13:54:37+00:00" + }, + { + "name": "dompdf/php-font-lib", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/dompdf/php-font-lib.git", + "reference": "a6e9a688a2a80016ac080b97be73d3e10c444c9a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/a6e9a688a2a80016ac080b97be73d3e10c444c9a", + "reference": "a6e9a688a2a80016ac080b97be73d3e10c444c9a", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11 || ^12" + }, + "type": "library", + "autoload": { + "psr-4": { + "FontLib\\": "src/FontLib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "The FontLib Community", + "homepage": "https://github.com/dompdf/php-font-lib/blob/master/AUTHORS.md" + } + ], + "description": "A library to read, parse, export and make subsets of different types of font files.", + "homepage": "https://github.com/dompdf/php-font-lib", + "support": { + "issues": "https://github.com/dompdf/php-font-lib/issues", + "source": "https://github.com/dompdf/php-font-lib/tree/1.0.2" + }, + "time": "2026-01-20T14:10:26+00:00" + }, + { + "name": "dompdf/php-svg-lib", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/dompdf/php-svg-lib.git", + "reference": "8259ffb930817e72b1ff1caef5d226501f3dfeb1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/8259ffb930817e72b1ff1caef5d226501f3dfeb1", + "reference": "8259ffb930817e72b1ff1caef5d226501f3dfeb1", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0", + "sabberworm/php-css-parser": "^8.4 || ^9.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11" + }, + "type": "library", + "autoload": { + "psr-4": { + "Svg\\": "src/Svg" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "The SvgLib Community", + "homepage": "https://github.com/dompdf/php-svg-lib/blob/master/AUTHORS.md" + } + ], + "description": "A library to read, parse and export to PDF SVG files.", + "homepage": "https://github.com/dompdf/php-svg-lib", + "support": { + "issues": "https://github.com/dompdf/php-svg-lib/issues", + "source": "https://github.com/dompdf/php-svg-lib/tree/1.0.2" + }, + "time": "2026-01-02T16:01:13+00:00" + }, { "name": "dragonmantank/cron-expression", "version": "v3.6.0", @@ -2019,6 +2251,73 @@ ], "time": "2026-01-15T06:54:53+00:00" }, + { + "name": "masterminds/html5", + "version": "2.10.0", + "source": { + "type": "git", + "url": "https://github.com/Masterminds/html5-php.git", + "reference": "fcf91eb64359852f00d921887b219479b4f21251" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/fcf91eb64359852f00d921887b219479b4f21251", + "reference": "fcf91eb64359852f00d921887b219479b4f21251", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7 || ^8 || ^9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Masterminds\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matt Butcher", + "email": "technosophos@gmail.com" + }, + { + "name": "Matt Farina", + "email": "matt@mattfarina.com" + }, + { + "name": "Asmir Mustafic", + "email": "goetas@gmail.com" + } + ], + "description": "An HTML5 parser and serializer.", + "homepage": "http://masterminds.github.io/html5-php", + "keywords": [ + "HTML5", + "dom", + "html", + "parser", + "querypath", + "serializer", + "xml" + ], + "support": { + "issues": "https://github.com/Masterminds/html5-php/issues", + "source": "https://github.com/Masterminds/html5-php/tree/2.10.0" + }, + "time": "2025-07-25T09:04:22+00:00" + }, { "name": "monolog/monolog", "version": "3.10.0", @@ -3290,6 +3589,86 @@ }, "time": "2025-12-14T04:43:48+00:00" }, + { + "name": "sabberworm/php-css-parser", + "version": "v9.2.0", + "source": { + "type": "git", + "url": "https://github.com/MyIntervals/PHP-CSS-Parser.git", + "reference": "59373045e11ad47b5c18fc615feee0219e42f6d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MyIntervals/PHP-CSS-Parser/zipball/59373045e11ad47b5c18fc615feee0219e42f6d3", + "reference": "59373045e11ad47b5c18fc615feee0219e42f6d3", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "php": "^7.2.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "thecodingmachine/safe": "^1.3 || ^2.5 || ^3.4" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "1.4.0", + "phpstan/extension-installer": "1.4.3", + "phpstan/phpstan": "1.12.32 || 2.1.32", + "phpstan/phpstan-phpunit": "1.4.2 || 2.0.8", + "phpstan/phpstan-strict-rules": "1.6.2 || 2.0.7", + "phpunit/phpunit": "8.5.52", + "rawr/phpunit-data-provider": "3.3.1", + "rector/rector": "1.2.10 || 2.2.8", + "rector/type-perfect": "1.0.0 || 2.1.0", + "squizlabs/php_codesniffer": "4.0.1", + "thecodingmachine/phpstan-safe-rule": "1.2.0 || 1.4.1" + }, + "suggest": { + "ext-mbstring": "for parsing UTF-8 CSS" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "9.3.x-dev" + } + }, + "autoload": { + "files": [ + "src/Rule/Rule.php", + "src/RuleSet/RuleContainer.php" + ], + "psr-4": { + "Sabberworm\\CSS\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Raphael Schweikert" + }, + { + "name": "Oliver Klee", + "email": "github@oliverklee.de" + }, + { + "name": "Jake Hotson", + "email": "jake.github@qzdesign.co.uk" + } + ], + "description": "Parser for CSS Files written in PHP", + "homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser", + "keywords": [ + "css", + "parser", + "stylesheet" + ], + "support": { + "issues": "https://github.com/MyIntervals/PHP-CSS-Parser/issues", + "source": "https://github.com/MyIntervals/PHP-CSS-Parser/tree/v9.2.0" + }, + "time": "2026-02-21T17:12:03+00:00" + }, { "name": "symfony/clock", "version": "v7.4.0", @@ -5791,6 +6170,149 @@ ], "time": "2026-01-01T22:13:48+00:00" }, + { + "name": "thecodingmachine/safe", + "version": "v3.4.0", + "source": { + "type": "git", + "url": "https://github.com/thecodingmachine/safe.git", + "reference": "705683a25bacf0d4860c7dea4d7947bfd09eea19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thecodingmachine/safe/zipball/705683a25bacf0d4860c7dea4d7947bfd09eea19", + "reference": "705683a25bacf0d4860c7dea4d7947bfd09eea19", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpstan/phpstan": "^2", + "phpunit/phpunit": "^10", + "squizlabs/php_codesniffer": "^3.2" + }, + "type": "library", + "autoload": { + "files": [ + "lib/special_cases.php", + "generated/apache.php", + "generated/apcu.php", + "generated/array.php", + "generated/bzip2.php", + "generated/calendar.php", + "generated/classobj.php", + "generated/com.php", + "generated/cubrid.php", + "generated/curl.php", + "generated/datetime.php", + "generated/dir.php", + "generated/eio.php", + "generated/errorfunc.php", + "generated/exec.php", + "generated/fileinfo.php", + "generated/filesystem.php", + "generated/filter.php", + "generated/fpm.php", + "generated/ftp.php", + "generated/funchand.php", + "generated/gettext.php", + "generated/gmp.php", + "generated/gnupg.php", + "generated/hash.php", + "generated/ibase.php", + "generated/ibmDb2.php", + "generated/iconv.php", + "generated/image.php", + "generated/imap.php", + "generated/info.php", + "generated/inotify.php", + "generated/json.php", + "generated/ldap.php", + "generated/libxml.php", + "generated/lzf.php", + "generated/mailparse.php", + "generated/mbstring.php", + "generated/misc.php", + "generated/mysql.php", + "generated/mysqli.php", + "generated/network.php", + "generated/oci8.php", + "generated/opcache.php", + "generated/openssl.php", + "generated/outcontrol.php", + "generated/pcntl.php", + "generated/pcre.php", + "generated/pgsql.php", + "generated/posix.php", + "generated/ps.php", + "generated/pspell.php", + "generated/readline.php", + "generated/rnp.php", + "generated/rpminfo.php", + "generated/rrd.php", + "generated/sem.php", + "generated/session.php", + "generated/shmop.php", + "generated/sockets.php", + "generated/sodium.php", + "generated/solr.php", + "generated/spl.php", + "generated/sqlsrv.php", + "generated/ssdeep.php", + "generated/ssh2.php", + "generated/stream.php", + "generated/strings.php", + "generated/swoole.php", + "generated/uodbc.php", + "generated/uopz.php", + "generated/url.php", + "generated/var.php", + "generated/xdiff.php", + "generated/xml.php", + "generated/xmlrpc.php", + "generated/yaml.php", + "generated/yaz.php", + "generated/zip.php", + "generated/zlib.php" + ], + "classmap": [ + "lib/DateTime.php", + "lib/DateTimeImmutable.php", + "lib/Exceptions/", + "generated/Exceptions/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHP core functions that throw exceptions instead of returning FALSE on error", + "support": { + "issues": "https://github.com/thecodingmachine/safe/issues", + "source": "https://github.com/thecodingmachine/safe/tree/v3.4.0" + }, + "funding": [ + { + "url": "https://github.com/OskarStark", + "type": "github" + }, + { + "url": "https://github.com/shish", + "type": "github" + }, + { + "url": "https://github.com/silasjoisten", + "type": "github" + }, + { + "url": "https://github.com/staabm", + "type": "github" + } + ], + "time": "2026-02-04T18:08:13+00:00" + }, { "name": "tijsverkoyen/css-to-inline-styles", "version": "v2.4.0", diff --git a/resources/views/user/diagnosa/hasil.blade.php b/resources/views/user/diagnosa/hasil.blade.php index 7091828..02c122c 100644 --- a/resources/views/user/diagnosa/hasil.blade.php +++ b/resources/views/user/diagnosa/hasil.blade.php @@ -1,128 +1,132 @@ @extends('layouts.user-app') -@section('page-title', '📋 Hasil Diagnosa') +@section('page-title', 'Hasil Diagnosa') @section('page-subtitle', 'Hasil analisis penyakit tanaman kopi kamu') @section('content')
- +
- -
-
-
- - - +
+ +
+
+
+ + Penyakit Terdeteksi + + @if($riwayat->penyakit?->tingkat_bahaya) + + âš ī¸ {{ $riwayat->penyakit->tingkat_bahaya }} + + @endif +
+ + {{-- Tombol Download PDF --}} + + + + + Download PDF + +
+ +

{{ $riwayat->penyakit->nama_penyakit ?? 'Tidak Teridentifikasi' }}

+ @if($riwayat->penyakit?->nama_latin) +

{{ $riwayat->penyakit->nama_latin }}

+ @endif + + +
+
+ Tingkat Kepercayaan + {{ round($riwayat->cf_tertinggi * 100, 1) }}% +
+
+
+
+
+ 0%50%100% +
-

Hasil Diagnosa

- @if($riwayat->penyakit) - -
-
-
-

Penyakit Terdeteksi

-

{{ $riwayat->penyakit->nama_penyakit }}

- @if($riwayat->penyakit->nama_latin) -

{{ $riwayat->penyakit->nama_latin }}

- @endif -
-
-

Tingkat Kepercayaan

-

{{ round($riwayat->cf_tertinggi * 100, 1) }}%

-
-
- - -
-
-
-
-
- - - @if($riwayat->penyakit->tingkat_bahaya) -
- - âš ī¸ Tingkat Bahaya: {{ $riwayat->penyakit->tingkat_bahaya }} - -
- @endif -
- - - @if($riwayat->penyakit->deskripsi_singkat) -
-

📝 Deskripsi

-

{{ $riwayat->penyakit->deskripsi_singkat }}

+ +
+ @if($riwayat->penyakit?->deskripsi_singkat) +
+

+ 📝 + Deskripsi Penyakit +

+

{{ $riwayat->penyakit->deskripsi_singkat }}

@endif +

+ 💊 + Cara Pengendalian +

- @if($riwayat->penyakit->pengendalian_pencegahan) -
-

đŸ›Ąī¸ Pencegahan

+ @if($riwayat->penyakit?->pengendalian_pencegahan) +
+
đŸ›Ąī¸
Pencegahan

{{ $riwayat->penyakit->pengendalian_pencegahan }}

@endif - @if($riwayat->penyakit->pengendalian_kimia) -
-

âš—ī¸ Pengendalian Kimia

+ @if($riwayat->penyakit?->pengendalian_kimia) +
+
âš—ī¸
Pengendalian Kimia

{{ $riwayat->penyakit->pengendalian_kimia }}

@endif - @if($riwayat->penyakit->pengendalian_organik) -
-

đŸŒŋ Pengendalian Organik

+ @if($riwayat->penyakit?->pengendalian_organik) +
+
đŸŒŋ
Pengendalian Organik

{{ $riwayat->penyakit->pengendalian_organik }}

@endif - @if($riwayat->penyakit->pengendalian_budidaya) -
-

🌱 Pengendalian Budidaya

+ @if($riwayat->penyakit?->pengendalian_budidaya) +
+
🌱
Pengendalian Budidaya

{{ $riwayat->penyakit->pengendalian_budidaya }}

@endif
- @else -
-

Tidak ditemukan data penyakit

-
- @endif +
- + @if($riwayat->hasil_diagnosa && count($riwayat->hasil_diagnosa) > 1)
-

📊 Semua Kemungkinan Penyakit

+

+ 📊 + Semua Kemungkinan Penyakit +

@foreach($riwayat->hasil_diagnosa as $index => $hasil) -
-
- - {{ $index + 1 }} - - - {{ $hasil['nama_penyakit'] }} - -
-
+
+ {{ $index + 1 }} + + {{ $hasil['nama_penyakit'] }} + @if($index === 0)Terpilih@endif + +
-
+
- - {{ $hasil['persentase'] }}% - + {{ $hasil['persentase'] }}%
@endforeach @@ -131,38 +135,99 @@ @endif
- + + @if($relasiGejala->count() > 0) +
+

+ 🔗 + Relasi Gejala & Penyakit +

+
+ + + + + @foreach($riwayat->hasil_diagnosa as $hasil) + + @endforeach + + + + @foreach($gejalaInput as $gejala) + + + @foreach($riwayat->hasil_diagnosa as $hasil) + + @endforeach + + @endforeach + +
Gejala + {{ $hasil['nama_penyakit'] }} +
{{ $hasil['persentase'] }}%
+
{{ $gejala->nama_gejala }} + @if(isset($relasiGejala[$hasil['id_penyakit']]) && + $relasiGejala[$hasil['id_penyakit']]->contains('id_gejala', $gejala->id_gejala)) + + + + + + @else + + + + + + @endif +
+
+

✅ = gejala terkait penyakit tersebut  |  ❌ = tidak terkait

+
+ @endif + +
-

â„šī¸ Info Diagnosa

-
-
- Tanggal - {{ $riwayat->tanggal->format('d M Y, H:i') }} +

+ â„šī¸ + Info Diagnosa +

+
+
+ Tanggal + {{ $riwayat->tanggal->format('d M Y') }}
-
- Jumlah Gejala - {{ count($riwayat->gejala_input) }} gejala +
+ Waktu + {{ $riwayat->tanggal->format('H:i') }} WIB
-
- CF Tertinggi - {{ round($riwayat->cf_tertinggi * 100, 1) }}% +
+ Jumlah Gejala + {{ count($riwayat->gejala_input) }} gejala +
+
+ CF Tertinggi + {{ round($riwayat->cf_tertinggi * 100, 1) }}%
- +
-

đŸŠē Gejala yang Dipilih

-
+

+ đŸŠē + Gejala Dipilih +

+
@foreach($gejalaInput as $gejala) -
- +
+ - {{ $gejala->nama_gejala }} + {{ $gejala->nama_gejala }}
@endforeach
@@ -170,14 +235,13 @@
diff --git a/resources/views/user/diagnosa/index.blade.php b/resources/views/user/diagnosa/index.blade.php index 268e384..081ff82 100644 --- a/resources/views/user/diagnosa/index.blade.php +++ b/resources/views/user/diagnosa/index.blade.php @@ -1,6 +1,6 @@ @extends('layouts.user-app') -@section('page-title', '🔍 Diagnosa Penyakit') +@section('page-title', 'Diagnosa Penyakit') @section('page-subtitle', 'Pilih gejala yang dialami tanaman kopi kamu') @section('content') @@ -22,8 +22,8 @@
-
-
+
+
@@ -35,8 +35,8 @@
- +
@@ -74,7 +74,7 @@ class="gejala-checkbox w-5 h-5 text-green-600 rounded focus:ring-green-500 mr-4"
-

✅ Gejala Terpilih

+

Gejala Terpilih

0

gejala dipilih

@@ -90,7 +90,7 @@ class="w-full mb-3 px-4 py-2 border border-gray-300 text-gray-600 font-semibold diff --git a/resources/views/user/diagnosa/pdf.blade.php b/resources/views/user/diagnosa/pdf.blade.php new file mode 100644 index 0000000..a20f9bb --- /dev/null +++ b/resources/views/user/diagnosa/pdf.blade.php @@ -0,0 +1,280 @@ + + + + + Hasil Diagnosa - {{ $riwayat->id_diagnosis }} + + + + +{{-- HEADER --}} +
+ + + + + +
+
+ 🔬 Penyakit Terdeteksi + @if($riwayat->penyakit?->tingkat_bahaya) + @php + $badgeClass = match($riwayat->penyakit->tingkat_bahaya) { + 'Sangat Tinggi' => 'badge-danger-sangat-tinggi', + 'Tinggi' => 'badge-danger-tinggi', + 'Sedang' => 'badge-danger-sedang', + default => 'badge-danger-rendah', + }; + @endphp +  ⚠ {{ $riwayat->penyakit->tingkat_bahaya }} + @endif +
+
+ {{ $riwayat->penyakit->nama_penyakit ?? 'Tidak Teridentifikasi' }} +
+ @if($riwayat->penyakit?->nama_latin) +
{{ $riwayat->penyakit->nama_latin }}
+ @endif +
+
+
{{ $riwayat->tanggal->format('d M Y') }}
+
{{ $riwayat->tanggal->format('H:i') }} WIB
+
ID: {{ $riwayat->id_diagnosis }}
+
+
+ +
+ + + + + +
Tingkat Kepercayaan{{ round($riwayat->cf_tertinggi * 100, 1) }}%
+
+
+
+ + + + + + +
0%50%100%
+
+
+ +{{-- CONTENT --}} +
+ + + + + + +
+
+
Info Diagnosa
+ + + + + + +
Tanggal{{ $riwayat->tanggal->format('d F Y') }}
Waktu{{ $riwayat->tanggal->format('H:i') }} WIB
Jumlah Gejala{{ count($riwayat->gejala_input) }} gejala
CF Tertinggi{{ round($riwayat->cf_tertinggi * 100, 1) }}%
Tingkat Bahaya{{ $riwayat->penyakit?->tingkat_bahaya ?? '-' }}
+
+
+
+
Gejala Dipilih
+ @foreach($gejalaInput as $gejala) + ✓ {{ $gejala->nama_gejala }} + @endforeach +
+
+ + @if($riwayat->penyakit?->deskripsi_singkat) +
+
Deskripsi Penyakit
+
{{ $riwayat->penyakit->deskripsi_singkat }}
+
+ @endif + + @if($riwayat->penyakit?->pengendalian_pencegahan || $riwayat->penyakit?->pengendalian_kimia || $riwayat->penyakit?->pengendalian_organik || $riwayat->penyakit?->pengendalian_budidaya) +
+
Cara Pengendalian
+ + + @if($riwayat->penyakit?->pengendalian_pencegahan) + + @endif + @if($riwayat->penyakit?->pengendalian_kimia) + + @endif + + + @if($riwayat->penyakit?->pengendalian_organik) + + @endif + @if($riwayat->penyakit?->pengendalian_budidaya) + + @endif + +
+
Pencegahan
+ {{ $riwayat->penyakit->pengendalian_pencegahan }} +
+
Pengendalian Kimia
+ {{ $riwayat->penyakit->pengendalian_kimia }} +
+
Pengendalian Organik
+ {{ $riwayat->penyakit->pengendalian_organik }} +
+
Pengendalian Budidaya
+ {{ $riwayat->penyakit->pengendalian_budidaya }} +
+
+ @endif + + @if($riwayat->hasil_diagnosa && count($riwayat->hasil_diagnosa) > 1) +
+
Semua Kemungkinan Penyakit
+ + + + + + + + + + + @foreach($riwayat->hasil_diagnosa as $index => $hasil) + + + + + + + @endforeach + +
#Nama PenyakitCFGrafik
{{ $index + 1 }}{{ $hasil['nama_penyakit'] }}{{ $hasil['persentase'] }}% +
+
+
+
+
+ @endif + + @if($relasiGejala->count() > 0) +
+
Relasi Gejala & Penyakit
+ + + + + @foreach($riwayat->hasil_diagnosa as $hasil) + + @endforeach + + + + @foreach($gejalaInput as $gejala) + + + @foreach($riwayat->hasil_diagnosa as $hasil) + + @endforeach + + @endforeach + +
Gejala + {{ $hasil['nama_penyakit'] }}
+ {{ $hasil['persentase'] }}% +
{{ $gejala->nama_gejala }} + @if(isset($relasiGejala[$hasil['id_penyakit']]) && + $relasiGejala[$hasil['id_penyakit']]->contains('id_gejala', $gejala->id_gejala)) + + @else + + @endif +
+

✓ = gejala terkait penyakit tersebut  |  ✗ = tidak terkait

+
+ @endif + +
+ +{{-- FOOTER --}} + + + + + +
+ Dokumen ini digenerate otomatis oleh sistem pakar diagnosa penyakit tanaman kopi.
+ Hasil diagnosa bersifat prediktif. Konsultasikan dengan ahli pertanian untuk penanganan lebih lanjut. +
+ ID: {{ $riwayat->id_diagnosis }}
+ {{ now()->format('d/m/Y H:i') }} +
+ + + \ No newline at end of file diff --git a/resources/views/user/diagnosa/riwayat.blade.php b/resources/views/user/diagnosa/riwayat.blade.php index ed88fb7..2790975 100644 --- a/resources/views/user/diagnosa/riwayat.blade.php +++ b/resources/views/user/diagnosa/riwayat.blade.php @@ -1,6 +1,6 @@ @extends('layouts.user-app') -@section('page-title', '📋 Riwayat Diagnosa') +@section('page-title', 'Riwayat Diagnosa') @section('page-subtitle', 'Histori diagnosa penyakit tanaman kopi kamu') @section('content') @@ -23,6 +23,11 @@ class="flex items-center px-5 py-3 bg-gradient-to-r from-green-500 to-green-600
+ @if(session('success')) +
+ {{ session('success') }} +
+ @endif @@ -57,10 +62,34 @@ class="flex items-center px-5 py-3 bg-gradient-to-r from-green-500 to-green-600 @empty diff --git a/routes/web.php b/routes/web.php index fbe5444..9ec154a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -38,6 +38,8 @@ Route::post('/diagnosa', [DiagnosaController::class, 'proses'])->name('diagnosa.proses'); Route::get('/diagnosa/hasil/{id}', [DiagnosaController::class, 'hasil'])->name('diagnosa.hasil'); Route::get('/diagnosa/riwayat', [DiagnosaController::class, 'riwayat'])->name('diagnosa.riwayat'); + Route::get('/diagnosa/riwayat/{id}/pdf', [DiagnosaController::class, 'downloadPdf'])->name('riwayat.pdf'); + Route::delete('/diagnosa/{id}', [DiagnosaController::class, 'destroy'])->name('diagnosa.destroy'); Route::get('/artikel/budidaya', [ArtikelUserController::class, 'budidaya'])->name('artikel.budidaya'); Route::get('/artikel/budidaya/{slug}', [ArtikelUserController::class, 'detailBudidaya'])->name('artikel.budidaya.detail'); Route::get('/artikel/hama-penyakit', [ArtikelUserController::class, 'hamaPenyakit'])->name('artikel.hama-penyakit');
- - Lihat Detail - +
+ {{-- Lihat Detail --}} + + Lihat Detail + + + {{-- Download PDF --}} + + + + + PDF + + + {{-- Hapus --}} +
+ @csrf + @method('DELETE') + +
+