[Detail Pelanggan]

This commit is contained in:
Arief Dwi Wicaksono 2025-09-12 13:49:26 +07:00
parent 3697113b24
commit 950645adc2
4 changed files with 36 additions and 3 deletions

View File

@ -7,6 +7,14 @@ use Illuminate\Http\Request;
class PelangganController extends Controller
{
public function show($id)
{
$pelanggan = Pelanggan::with('details')->findOrFail($id);
return view('admin.pelanggan.show', compact('pelanggan'));
}
// Tampilkan semua pelanggan (admin)
public function index(Request $request)
{

View File

@ -20,6 +20,6 @@ class Pelanggan extends Model
public function details()
{
return $this->hasOne(PelangganDetail::class);
return $this->hasMany(PelangganDetail::class);
}
}
}

View File

@ -19,4 +19,4 @@ class PelangganDetail extends Model
{
return $this->belongsTo(Pelanggan::class);
}
}
}

View File

@ -0,0 +1,25 @@
@extends('layouts.app')
@section('content')
<div class="container">
<h3>Detail Pelanggan</h3>
<p><strong>Nama Pemesan:</strong> {{ $pelanggan->nama_pemesan }}</p>
<p><strong>Email:</strong> {{ $pelanggan->email }}</p>
<p><strong>No HP:</strong> {{ $pelanggan->no_tlpn }}</p>
<p><strong>Kategori:</strong> {{ $pelanggan->kategori }}</p>
@if($pelanggan->details && count($pelanggan->details) > 0)
<h4>Form Detail</h4>
<ul>
@foreach($pelanggan->details as $detail)
@foreach($detail->detail_form as $key => $value)
<li><strong>{{ ucfirst(str_replace('_',' ',$key)) }}:</strong> {{ $value }}</li>
@endforeach
@endforeach
</ul>
@endif
<a href="{{ route('admin.pelanggan.index') }}" class="btn btn-secondary">Kembali</a>
</div>
@endsection