diff --git a/app/Http/Controllers/Admin/KategoriController.php b/app/Http/Controllers/Admin/KategoriController.php new file mode 100644 index 0000000..af200e9 --- /dev/null +++ b/app/Http/Controllers/Admin/KategoriController.php @@ -0,0 +1,70 @@ +latest()->get(); + return view('admin.kategori.index', compact('kategoris')); + } + + public function create() + { + return view('admin.kategori.create'); + } + + public function store(Request $request) + { + $request->validate([ + 'nama_kategori' => 'required|string|max:255|unique:kategoris,nama_kategori', + 'ikon' => 'nullable|string|max:50', + ]); + + Kategori::create([ + 'nama_kategori' => $request->nama_kategori, + 'slug' => Str::slug($request->nama_kategori), + 'ikon' => $request->ikon, + ]); + + return redirect()->route('admin.kategori.index')->with('success', 'Kategori berhasil ditambahkan.'); + } + + public function edit($id) + { + $kategori = Kategori::findOrFail($id); + return view('admin.kategori.edit', compact('kategori')); + } + + public function update(Request $request, $id) + { + $kategori = Kategori::findOrFail($id); + + $request->validate([ + 'nama_kategori' => 'required|string|max:255|unique:kategoris,nama_kategori,'.$id, + 'ikon' => 'nullable|string|max:50', + ]); + + $kategori->update([ + 'nama_kategori' => $request->nama_kategori, + 'slug' => Str::slug($request->nama_kategori), + 'ikon' => $request->ikon, + ]); + + return redirect()->route('admin.kategori.index')->with('success', 'Kategori berhasil diperbarui.'); + } + + public function destroy($id) + { + $kategori = Kategori::findOrFail($id); + $kategori->delete(); + + return redirect()->route('admin.kategori.index')->with('success', 'Kategori berhasil dihapus.'); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 59355a1..d690dde 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -16,7 +16,10 @@ public function dashboard() $totalProduk = Produk::count(); $totalTransaksi = Transaksi::count(); - $transaksiTerbaru = Transaksi::with(['pembeli', 'details'])->latest()->take(5)->get(); + $transaksiTerbaru = Transaksi::with(['pembeli', 'petani']) + ->latest() + ->take(5) + ->get(); return view('admin.dashboard', compact( 'totalPetani', @@ -30,15 +33,28 @@ public function dashboard() public function monitoring() { $produks = Produk::with('petani')->latest()->paginate(10); - $transaksis = Transaksi::with(['pembeli'])->latest()->paginate(10); + $transaksis = Transaksi::with(['pembeli', 'petani']) + ->latest() + ->paginate(10); return view('admin.monitoring', compact('produks', 'transaksis')); } + // --- FITUR BARU: DETAIL TRANSAKSI --- + public function transaksiDetail($id) + { + $transaksi = Transaksi::with(['pembeli', 'petani', 'detailTransaksis.produk']) + ->findOrFail($id); + + return view('admin.transaksi_detail', compact('transaksi')); + } + + // --- VERIFIKASI PETANI --- + public function verifikasiIndex() { // Ambil data petani yang statusnya 'menunggu' - $petanis = Petani::orderBy('created_at', 'desc')->get(); + $petanis = Petani::orderBy('created_at', 'desc')->get(); return view('admin.verifikasi.index', compact('petanis')); } diff --git a/app/Http/Controllers/LandingController.php b/app/Http/Controllers/LandingController.php index a21e26e..0721158 100644 --- a/app/Http/Controllers/LandingController.php +++ b/app/Http/Controllers/LandingController.php @@ -19,8 +19,12 @@ public function index(Request $request) return view('landing.partials.product_list', compact('produks'))->render(); } - $produkTerlaris = Produk::with('petani') - ->inRandomOrder() + $produkTerlaris = Produk::withSum(['detailTransaksis as total_terjual' => function ($query) { + $query->whereHas('transaksi', function ($q) { + $q->where('status', '!=', 'batal'); + }); + }], 'jumlah') + ->orderByDesc('total_terjual') ->take(4) ->get(); @@ -29,25 +33,53 @@ public function index(Request $request) public function shop(Request $request) { - $query = Produk::with('petani'); + $query = Produk::where('stok', '>', 0); - if ($request->has('search') && $request->search != '') { - $query->where('nama_produk', 'like', '%' . $request->search . '%'); + // Filter Kategori Berdasarkan Slug + if ($request->has('kategori') && $request->kategori != '') { + $slug = $request->kategori; + + $query->whereHas('kategori', function ($q) use ($slug) { + $q->where('slug', $slug); + }); } - $produks = $query->paginate(12); + // Sorting (Urutkan) + if ($request->has('sort')) { + switch ($request->sort) { + case 'termurah': + $query->orderBy('harga', 'asc'); + break; + case 'termahal': + $query->orderBy('harga', 'desc'); + break; + case 'terbaru': + $query->latest(); + break; + default: + $query->latest(); + break; + } + } else { + $query->latest(); + } + + $produks = $query->paginate(9); return view('landing.shop', compact('produks')); } public function detail($id) { - $produk = Produk::with('petani')->findOrFail($id); - $related_products = Produk::where('petani_id', $produk->petani_id) - ->where('id', '!=', $id) + $produk = Produk::with(['kategori', 'petani', 'images'])->findOrFail($id); + + $produk_terkait = Produk::where('kategori_id', $produk->kategori_id) + ->where('id', '!=', $produk->id) + ->where('stok', '>', 0) + ->inRandomOrder() ->take(4) ->get(); - return view('landing.detail', compact('produk', 'related_products')); + return view('landing.detail', compact('produk', 'produk_terkait')); } } diff --git a/app/Http/Controllers/PesanController.php b/app/Http/Controllers/PesanController.php index 3e5ad57..783a5ff 100644 --- a/app/Http/Controllers/PesanController.php +++ b/app/Http/Controllers/PesanController.php @@ -20,27 +20,36 @@ private function getChatList($user) })->orderBy('created_at', 'desc')->get(); $conversations = $allMessages->groupBy(function ($pesan) use ($user) { - return $pesan->pengirim_id == $user->id - ? $pesan->penerima_type . '_' . $pesan->penerima_id - : $pesan->pengirim_type . '_' . $pesan->pengirim_id; + if ($pesan->pengirim_id == $user->id && $pesan->pengirim_type == get_class($user)) { + return $pesan->penerima_type . '_' . $pesan->penerima_id; + } else { + return $pesan->pengirim_type . '_' . $pesan->pengirim_id; + } }); return $conversations->map(function ($msgs) use ($user) { $lastMsg = $msgs->first(); - if ($lastMsg->pengirim_id == $user->id) { + + if ($lastMsg->pengirim_id == $user->id && $lastMsg->pengirim_type == get_class($user)) { $lawan = $lastMsg->penerima; } else { $lawan = $lastMsg->pengirim; } + // Fallback + $lawanObj = $lawan ?? new \stdClass; + return [ 'lawan_id' => $lawan->id ?? 0, - 'lawan_type' => get_class($lawan ?? new \stdClass), + 'lawan_type' => get_class($lawanObj), 'nama' => $lawan->nama_lengkap ?? 'User Terhapus', - 'foto' => $lawan->foto ?? null, // Pastikan ada accessor url foto + 'foto' => $lawan->foto ?? null, 'last_message' => $lastMsg->isi_pesan, 'time' => $lastMsg->created_at->diffForHumans(), - 'unread' => $msgs->where('penerima_id', $user->id)->where('sudah_dibaca', false)->count() + 'unread' => $msgs->where('penerima_id', $user->id) + ->where('penerima_type', get_class($user)) + ->where('sudah_dibaca', false) + ->count() ]; }); } diff --git a/app/Http/Controllers/Petani/ProdukController.php b/app/Http/Controllers/Petani/ProdukController.php index f78d585..a753ec9 100644 --- a/app/Http/Controllers/Petani/ProdukController.php +++ b/app/Http/Controllers/Petani/ProdukController.php @@ -5,42 +5,52 @@ use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\Produk; +use App\Models\ProdukImage; +use App\Models\Kategori; // PENTING: Import Model Kategori use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Storage; class ProdukController extends Controller { - // Tampilkan Daftar Produk Petani public function index() { - $produks = Produk::where('petani_id', Auth::guard('petani')->id())->latest()->get(); + $produks = Produk::with('kategori') + ->where('petani_id', Auth::guard('petani')->id()) + ->latest() + ->get(); + return view('petani.produk.index', compact('produks')); } - // Form Tambah Produk public function create() { - return view('petani.produk.create'); + $kategoris = Kategori::all(); + + return view('petani.produk.create', compact('kategoris')); } - // Simpan Produk Baru public function store(Request $request) { $request->validate([ - 'nama_produk' => 'required|string|max:255', - 'harga' => 'required|numeric|min:0', - 'stok' => 'required|integer|min:0', - 'deskripsi' => 'required|string', - 'foto_produk' => 'required|image|mimes:jpeg,png,jpg|max:2048', + 'nama_produk' => 'required|string|max:255', + 'kategori_id' => 'required|exists:kategoris,id', + 'harga' => 'required|numeric|min:0', + 'stok' => 'required|integer|min:0', + 'deskripsi' => 'required|string', + 'foto_produk' => 'required|image|mimes:jpeg,png,jpg|max:2048', + 'foto_tambahan.*' => 'nullable|image|mimes:jpeg,png,jpg|max:2048' ]); + // Simpan Foto Utama $fotoPath = null; if ($request->hasFile('foto_produk')) { $fotoPath = $request->file('foto_produk')->store('produk', 'public'); } - Produk::create([ + // Simpan Data Produk + $produk = Produk::create([ 'petani_id' => Auth::guard('petani')->id(), + 'kategori_id' => $request->kategori_id, 'nama_produk' => $request->nama_produk, 'harga' => $request->harga, 'stok' => $request->stok, @@ -48,29 +58,50 @@ public function store(Request $request) 'foto_produk' => $fotoPath, ]); + // Simpan Foto Tambahan + if ($request->hasFile('foto_tambahan')) { + foreach ($request->file('foto_tambahan') as $file) { + $path = $file->store('produk/gallery', 'public'); + ProdukImage::create([ + 'produk_id' => $produk->id, + 'foto' => $path + ]); + } + } + return redirect()->route('petani.produk.index')->with('success', 'Produk berhasil ditambahkan.'); } - // Form Edit Produk public function edit($id) { - $produk = Produk::where('id', $id)->where('petani_id', Auth::guard('petani')->id())->firstOrFail(); - return view('petani.produk.edit', compact('produk')); + $produk = Produk::with('images')->where('id', $id)->where('petani_id', Auth::guard('petani')->id())->firstOrFail(); + $kategoris = Kategori::all(); + + return view('petani.produk.edit', compact('produk', 'kategoris')); } - // Update Produk public function update(Request $request, $id) { - $produk = Produk::where('id', $id)->where('petani_id', Auth::guard('petani')->id())->firstOrFail(); + $produk = Produk::with('images')->where('id', $id)->where('petani_id', Auth::guard('petani')->id())->firstOrFail(); + + // Hitung slot gambar tersisa + $jumlahGambarLama = $produk->images->count(); + $sisaSlot = max(3 - $jumlahGambarLama, 0); $request->validate([ - 'nama_produk' => 'required|string|max:255', - 'harga' => 'required|numeric|min:0', - 'stok' => 'required|integer|min:0', - 'deskripsi' => 'required|string', - 'foto_produk' => 'nullable|image|mimes:jpeg,png,jpg|max:2048', + 'nama_produk' => 'required|string|max:255', + 'kategori_id' => 'required|exists:kategoris,id', + 'harga' => 'required|numeric|min:0', + 'stok' => 'required|integer|min:0', + 'deskripsi' => 'required|string', + 'foto_produk' => 'nullable|image|mimes:jpeg,png,jpg|max:2048', + 'foto_tambahan' => 'array|max:' . $sisaSlot, + 'foto_tambahan.*' => 'image|mimes:jpeg,png,jpg|max:2048' + ], [ + 'foto_tambahan.max' => "Anda hanya bisa menambah $sisaSlot foto lagi." ]); + // Update Foto Utama if ($request->hasFile('foto_produk')) { if ($produk->foto_produk && Storage::disk('public')->exists($produk->foto_produk)) { Storage::disk('public')->delete($produk->foto_produk); @@ -78,21 +109,32 @@ public function update(Request $request, $id) $produk->foto_produk = $request->file('foto_produk')->store('produk', 'public'); } + // Update Data $produk->update([ 'nama_produk' => $request->nama_produk, + 'kategori_id' => $request->kategori_id, 'harga' => $request->harga, 'stok' => $request->stok, 'deskripsi' => $request->deskripsi, + 'foto_produk' => $produk->foto_produk ]); - if ($request->hasFile('foto_produk')) { - $produk->save(); + // Tambah Foto Galeri + if ($request->hasFile('foto_tambahan')) { + foreach ($request->file('foto_tambahan') as $file) { + if ($produk->images()->count() >= 3) break; + + $path = $file->store('produk/gallery', 'public'); + ProdukImage::create([ + 'produk_id' => $produk->id, + 'foto' => $path + ]); + } } return redirect()->route('petani.produk.index')->with('success', 'Produk berhasil diperbarui.'); } - // Hapus Produk public function destroy($id) { $produk = Produk::where('id', $id)->where('petani_id', Auth::guard('petani')->id())->firstOrFail(); @@ -101,8 +143,32 @@ public function destroy($id) Storage::disk('public')->delete($produk->foto_produk); } + foreach($produk->images as $img) { + if (Storage::disk('public')->exists($img->foto)) { + Storage::disk('public')->delete($img->foto); + } + } + + $produk->images()->delete(); $produk->delete(); return redirect()->route('petani.produk.index')->with('success', 'Produk berhasil dihapus.'); } + + public function deleteImage($id) + { + $image = ProdukImage::findOrFail($id); + + if ($image->produk->petani_id != Auth::guard('petani')->id()) { + abort(403); + } + + if (Storage::disk('public')->exists($image->foto)) { + Storage::disk('public')->delete($image->foto); + } + + $image->delete(); + + return back()->with('success', 'Foto berhasil dihapus.'); + } } \ No newline at end of file diff --git a/app/Http/Controllers/TransaksiController.php b/app/Http/Controllers/TransaksiController.php index fa1084e..af96605 100644 --- a/app/Http/Controllers/TransaksiController.php +++ b/app/Http/Controllers/TransaksiController.php @@ -72,16 +72,17 @@ public function prosesCheckout(Request $request) DB::transaction(function () use ($request, $pembeli_id) { if ($request->has('produk_id')) { - // LOGIKA BELI LANGSUNG (Single Item) + // --- LOGIKA BELI LANGSUNG (Single Item) --- $produk = Produk::findOrFail($request->produk_id); $total_harga = $produk->harga * $request->jumlah; $transaksi = Transaksi::create([ 'pembeli_id' => $pembeli_id, + 'petani_id' => $produk->petani_id, 'tanggal_transaksi' => now(), 'alamat_pengiriman' => $request->alamat_pengiriman, 'total_harga' => $total_harga, - 'status' => 'menunggu_konfirmasi', + 'status' => 'menunggu konfirmasi', 'kode_invoice' => 'INV/' . date('Ymd') . '/' . rand(1000, 9999), ]); @@ -94,7 +95,9 @@ public function prosesCheckout(Request $request) ]); $produk->decrement('stok', $request->jumlah); + } else { + // --- LOGIKA KERANJANG (Cart) --- $cart = session()->get('cart'); // Kelompokkan produk berdasarkan Petani ID @@ -113,13 +116,14 @@ public function prosesCheckout(Request $request) $subtotal_transaksi = 0; $kode_invoice = 'INV/' . date('Ymd') . '/' . rand(1000, 9999); - // Membuat Header Transaksi + // Membuat Header Transaksi per Petani $transaksi = Transaksi::create([ 'pembeli_id' => $pembeli_id, + 'petani_id' => $petani_id, 'tanggal_transaksi' => now(), 'alamat_pengiriman' => $request->alamat_pengiriman, 'total_harga' => 0, - 'status' => 'menunggu_konfirmasi', + 'status' => 'menunggu konfirmasi', 'kode_invoice' => $kode_invoice, ]); @@ -154,7 +158,7 @@ public function prosesCheckout(Request $request) // Riwayat Pesanan public function pesananSaya() { - $transaksis = Transaksi::with(['details.produk.petani']) + $transaksis = Transaksi::with(['detailTransaksis.produk.petani']) ->where('pembeli_id', Auth::guard('pembeli')->id()) ->latest() ->get(); @@ -186,10 +190,10 @@ public function pesananMasuk() { $petaniId = Auth::guard('petani')->id(); - $pesanans = Transaksi::whereHas('details.produk', function ($q) use ($petaniId) { + $pesanans = Transaksi::whereHas('detailTransaksis.produk', function ($q) use ($petaniId) { $q->where('petani_id', $petaniId); }) - ->with(['pembeli', 'details.produk']) + ->with(['pembeli', 'detailTransaksis.produk']) ->latest() ->get(); @@ -223,10 +227,10 @@ public function pesananDetail($id) $petaniId = Auth::guard('petani')->id(); // Ambil transaksi berdasarkan ID - $pesanan = Transaksi::whereHas('details.produk', function ($q) use ($petaniId) { + $pesanan = Transaksi::whereHas('detailTransaksis.produk', function ($q) use ($petaniId) { $q->where('petani_id', $petaniId); }) - ->with(['pembeli', 'details.produk']) + ->with(['pembeli', 'detailTransaksis.produk']) ->findOrFail($id); return view('petani.pesanan.detail', compact('pesanan')); diff --git a/app/Models/Kategori.php b/app/Models/Kategori.php new file mode 100644 index 0000000..6675c12 --- /dev/null +++ b/app/Models/Kategori.php @@ -0,0 +1,18 @@ +hasMany(Produk::class, 'kategori_id'); + } +} \ No newline at end of file diff --git a/app/Models/Produk.php b/app/Models/Produk.php index 8e495b9..e5ac3a5 100644 --- a/app/Models/Produk.php +++ b/app/Models/Produk.php @@ -14,7 +14,6 @@ class Produk extends Model protected $fillable = [ 'petani_id', 'nama_produk', - 'kategori', 'harga', 'stok', 'deskripsi', @@ -25,9 +24,19 @@ public function petani() { return $this->belongsTo(Petani::class, 'petani_id'); } - + public function detailTransaksis() { return $this->hasMany(DetailTransaksi::class, 'produk_id'); } -} \ No newline at end of file + + public function images() + { + return $this->hasMany(ProdukImage::class, 'produk_id'); + } + + public function kategori() + { + return $this->belongsTo(Kategori::class, 'kategori_id'); + } +} diff --git a/app/Models/ProdukImage.php b/app/Models/ProdukImage.php new file mode 100644 index 0000000..6b48a1d --- /dev/null +++ b/app/Models/ProdukImage.php @@ -0,0 +1,21 @@ +belongsTo(Produk::class, 'produk_id'); + } +} \ No newline at end of file diff --git a/app/Models/Transaksi.php b/app/Models/Transaksi.php index 71ee785..92f9952 100644 --- a/app/Models/Transaksi.php +++ b/app/Models/Transaksi.php @@ -13,6 +13,7 @@ class Transaksi extends Model protected $fillable = [ 'pembeli_id', + 'petani_id', 'tanggal_transaksi', 'alamat_pengiriman', 'total_harga', @@ -25,7 +26,12 @@ public function pembeli() return $this->belongsTo(Pembeli::class, 'pembeli_id'); } - public function details() + public function petani() + { + return $this->belongsTo(Petani::class, 'petani_id'); + } + + public function detailTransaksis() { return $this->hasMany(DetailTransaksi::class, 'transaksi_id'); } diff --git a/database/migrations/2025_11_25_123400_create_kategoris_table.php b/database/migrations/2025_11_25_123400_create_kategoris_table.php new file mode 100644 index 0000000..8111372 --- /dev/null +++ b/database/migrations/2025_11_25_123400_create_kategoris_table.php @@ -0,0 +1,27 @@ +id(); + $table->string('nama_kategori'); + $table->string('slug')->unique(); + $table->string('ikon')->nullable(); + $table->timestamps(); + }); + } + + public function down() + { + Schema::dropIfExists('kategoris'); + } +}; diff --git a/database/migrations/2025_11_25_123429_create_produks_table.php b/database/migrations/2025_11_25_123429_create_produks_table.php index 6f1b948..415a636 100644 --- a/database/migrations/2025_11_25_123429_create_produks_table.php +++ b/database/migrations/2025_11_25_123429_create_produks_table.php @@ -14,8 +14,8 @@ public function up(): void Schema::create('produks', function (Blueprint $table) { $table->id(); $table->foreignId('petani_id')->constrained('petanis')->onDelete('cascade'); + $table->foreignId('kategori_id')->nullable()->constrained('kategoris')->onDelete('set null'); $table->string('nama_produk'); - $table->string('kategori')->default('Lainnya'); $table->decimal('harga', 12, 0); $table->integer('stok'); $table->text('deskripsi'); @@ -31,4 +31,4 @@ public function down(): void { Schema::dropIfExists('produks'); } -}; +}; \ No newline at end of file diff --git a/database/migrations/2025_11_25_123429_create_transaksis_table.php b/database/migrations/2025_11_25_123429_create_transaksis_table.php index 7d80483..b8caa9b 100644 --- a/database/migrations/2025_11_25_123429_create_transaksis_table.php +++ b/database/migrations/2025_11_25_123429_create_transaksis_table.php @@ -10,20 +10,21 @@ * Run the migrations. */ public function up(): void -{ - Schema::create('transaksis', function (Blueprint $table) { - $table->id(); - $table->foreignId('pembeli_id')->constrained('pembelis')->onDelete('cascade'); - $table->dateTime('tanggal_transaksi'); - $table->text('alamat_pengiriman'); - $table->decimal('total_harga', 15, 0); - $table->enum('status', ['menunggu_konfirmasi', 'diproses', 'dikirim', 'selesai', 'batal']) - ->default('menunggu_konfirmasi'); - - $table->string('kode_invoice')->unique()->nullable(); - $table->timestamps(); - }); -} + { + Schema::create('transaksis', function (Blueprint $table) { + $table->id(); + $table->foreignId('pembeli_id')->constrained('pembelis')->onDelete('cascade'); + $table->foreignId('petani_id')->constrained('petanis')->onDelete('cascade'); + $table->dateTime('tanggal_transaksi'); + $table->text('alamat_pengiriman'); + $table->decimal('total_harga', 15, 0); + $table->enum('status', ['menunggu konfirmasi', 'diproses', 'dikirim', 'selesai', 'batal']) + ->default('menunggu konfirmasi'); + + $table->string('kode_invoice')->unique()->nullable(); + $table->timestamps(); + }); + } /** * Reverse the migrations. diff --git a/database/migrations/2025_12_14_172342_create_produk_images_table.php b/database/migrations/2025_12_14_172342_create_produk_images_table.php new file mode 100644 index 0000000..d9ffcb8 --- /dev/null +++ b/database/migrations/2025_12_14_172342_create_produk_images_table.php @@ -0,0 +1,29 @@ +id(); + $table->foreignId('produk_id')->constrained('produks')->onDelete('cascade'); + $table->string('foto'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('produk_images'); + } +}; diff --git a/database/seeders/PetaniSeeder.php b/database/seeders/PetaniSeeder.php index 9791a04..a8d9092 100644 --- a/database/seeders/PetaniSeeder.php +++ b/database/seeders/PetaniSeeder.php @@ -13,6 +13,19 @@ class PetaniSeeder extends Seeder */ public function run(): void { + // Petani SUDAH AKTIF -> Bisa login & jualan + DB::table('petanis')->insert([ + 'nama_lengkap' => 'Siti Aminah', + 'username' => 'siti_sayur', + 'email' => 'siti@gmail.com', + 'password' => Hash::make('password123'), + 'no_hp' => '085678901234', + 'alamat' => 'Dusun Krajan RT 02 RW 01', + 'nama_usaha' => 'Sayur Segar Bu Siti', + 'status_akun' => 'aktif', + 'created_at' => now(), + 'updated_at' => now(), + ]); // Petani BARU DAFTAR menunggu verifikasi DB::table('petanis')->insert([ 'nama_lengkap' => 'Budi Santoso', @@ -27,19 +40,6 @@ public function run(): void 'updated_at' => now(), ]); - // Petani SUDAH AKTIF -> Bisa login & jualan - DB::table('petanis')->insert([ - 'nama_lengkap' => 'Siti Aminah', - 'username' => 'siti_sayur', - 'email' => 'siti@gmail.com', - 'password' => Hash::make('password123'), - 'no_hp' => '085678901234', - 'alamat' => 'Dusun Krajan RT 02 RW 01', - 'nama_usaha' => 'Sayur Segar Bu Siti', - 'status_akun' => 'aktif', - 'created_at' => now(), - 'updated_at' => now(), - ]); // Petani DITOLAK DB::table('petanis')->insert([ diff --git a/database/seeders/ProdukSeeder.php b/database/seeders/ProdukSeeder.php index f18eaf0..7571ea4 100644 --- a/database/seeders/ProdukSeeder.php +++ b/database/seeders/ProdukSeeder.php @@ -3,7 +3,11 @@ namespace Database\Seeders; use Illuminate\Database\Seeder; -use Illuminate\Support\Facades\DB; +use App\Models\Produk; +use App\Models\ProdukImage; +use App\Models\Kategori; +use App\Models\Petani; +use Illuminate\Support\Str; class ProdukSeeder extends Seeder { @@ -12,49 +16,105 @@ class ProdukSeeder extends Seeder */ public function run(): void { - $data = [ - [ - 'petani_id' => 2, - 'nama_produk' => 'Cabai Merah Keriting Segar', - 'harga' => 45000, - 'stok' => 50, - 'deskripsi' => 'Cabai merah keriting hasil panen pagi ini. Pedas mantap, cocok untuk sambal. Bebas pestisida kimia.', - 'foto_produk' => null, - 'created_at' => now(), - 'updated_at' => now(), - ], - [ - 'petani_id' => 2, - 'nama_produk' => 'Tomat Buah Organik', - 'harga' => 12000, - 'stok' => 100, - 'deskripsi' => 'Tomat buah ukuran besar, merah merona. Sangat segar untuk jus atau lalapan.', - 'foto_produk' => null, - 'created_at' => now(), - 'updated_at' => now(), - ], - [ - 'petani_id' => 2, - 'nama_produk' => 'Sawi Hijau (Caisim)', - 'harga' => 5000, - 'stok' => 25, - 'deskripsi' => 'Sawi hijau segar, satu ikat besar kira-kira 500gram. Renyah dan tidak pahit.', - 'foto_produk' => null, - 'created_at' => now(), - 'updated_at' => now(), - ], - [ - 'petani_id' => 2, - 'nama_produk' => 'Wortel Brastagi Super', - 'harga' => 15000, - 'stok' => 40, - 'deskripsi' => 'Wortel impor lokal kualitas super. Manis, renyah, dan warna oranye pekat.', - 'foto_produk' => null, - 'created_at' => now(), - 'updated_at' => now(), - ] + $petani = Petani::inRandomOrder()->first(); + + if (!$petani) { + $this->command->error('Tabel petani kosong. Jalankan PetaniSeeder terlebih dahulu!'); + return; + } + + // KATEGORI + $kategoriGabah = [ + ['nama' => 'Gabah Kering Panen (GKP)', 'slug' => 'gkp', 'ikon' => 'fas fa-seedling'], + ['nama' => 'Gabah Kering Giling (GKG)', 'slug' => 'gkg', 'ikon' => 'fas fa-sun'], + ['nama' => 'Benih Padi Unggul', 'slug' => 'benih-padi', 'ikon' => 'fas fa-leaf'], + ['nama' => 'Padi Ketan', 'slug' => 'padi-ketan', 'ikon' => 'fas fa-box'], + ['nama' => 'Padi Organik', 'slug' => 'padi-organik', 'ikon' => 'fas fa-heart'], ]; - DB::table('produks')->insert($data); + foreach ($kategoriGabah as $k) { + Kategori::firstOrCreate( + ['slug' => $k['slug']], + [ + 'nama_kategori' => $k['nama'], + 'ikon' => $k['ikon'] + ] + ); + } + + // DAFTAR PRODUK + $daftarProduk = [ + [ + 'nama' => 'Gabah Ciherang (GKP) Baru Panen', + 'harga' => 5200, + 'stok' => 2000, + 'deskripsi' => 'Gabah varietas Ciherang kondisi Kering Panen (GKP). Baru dipotong pagi ini. Bulir kuning bersih, hampa rendah. Lokasi sawah pinggir jalan raya, akses truk mudah.', + 'kategori_slug' => 'gkp', + 'gallery' => 2 + ], + [ + 'nama' => 'Gabah IR-64 Siap Giling (GKG)', + 'harga' => 7500, + 'stok' => 500, + 'deskripsi' => 'Gabah IR-64 kondisi Kering Giling (GKG). Kadar air sudah dibawah 14%, siap masuk huller/penggilingan. Dijamin rendemen beras tinggi.', + 'kategori_slug' => 'gkg', + 'gallery' => 3 + ], + [ + 'nama' => 'Benih Padi Inpari 32 Bersertifikat', + 'harga' => 15000, + 'stok' => 50, + 'deskripsi' => 'Benih padi varietas Inpari 32 label ungu. Tahan wereng dan penyakit hawar daun. Potensi hasil panen hingga 8 ton/hektar.', + 'kategori_slug' => 'benih-padi', + 'gallery' => 1 + ], + [ + 'nama' => 'Gabah Padi Ketan Putih Super', + 'harga' => 8000, + 'stok' => 300, + 'deskripsi' => 'Padi ketan putih murni, tidak tercampur padi biasa. Cocok untuk industri tape atau olahan ketan. Kualitas super.', + 'kategori_slug' => 'padi-ketan', + 'gallery' => 2 + ], + [ + 'nama' => 'Gabah Mentik Wangi Organik', + 'harga' => 9000, + 'stok' => 100, + 'deskripsi' => 'Gabah Mentik Wangi (Pandan Wangi Jawa) ditanam full organik tanpa pestisida kimia. Aroma sangat wangi, beras pulen.', + 'kategori_slug' => 'padi-organik', + 'gallery' => 2 + ], + [ + 'nama' => 'Gabah Kering Giling (GKG) Situbagendit', + 'harga' => 7200, + 'stok' => 1500, + 'deskripsi' => 'Gabah Situbagendit kering jemur 3 hari. Cocok untuk stok gudang penggilingan. Lokasi Nganjuk.', + 'kategori_slug' => 'gkg', + 'gallery' => 1 + ], + ]; + + // INSERT DATA + foreach ($daftarProduk as $item) { + $kategori = Kategori::where('slug', $item['kategori_slug'])->first(); + + // Create Produk + $produk = Produk::create([ + 'petani_id' => $petani->id, + 'kategori_id' => $kategori->id, + 'nama_produk' => $item['nama'], + 'harga' => $item['harga'], + 'stok' => $item['stok'], + 'deskripsi' => $item['deskripsi'], + 'foto_produk' => null, + ]); + + for ($i = 0; $i < $item['gallery']; $i++) { + ProdukImage::create([ + 'produk_id' => $produk->id, + 'foto' => 'dummy/gabah/sample_' . $i . '.jpg', + ]); + } + } } } \ No newline at end of file diff --git a/public/images/banner.jpg b/public/images/banner.jpg new file mode 100644 index 0000000..340fe7d Binary files /dev/null and b/public/images/banner.jpg differ diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index 1099e1d..4bf21ff 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -4,123 +4,158 @@ @section('page-title', 'Overview Sistem') @section('content') -
-
-
- {{-- Statistik Petani Aktif --}} -
-
-
-
-
-
+
+
+
+ {{-- Statistik Petani Aktif --}} +
+
+
+
+
+
+
+
+
Petani Aktif
+
{{ $totalPetani }}
+
-
-
Petani Aktif
-
{{ $totalPetani }}
+
+
+
+ + {{-- Statistik Menunggu Verifikasi --}} +
+
+
+
+
+
+
+
+
Verifikasi Pending
+
{{ $petaniPending }}
+
+
+
+
+
+ + {{-- Statistik Total Produk --}} +
+
+
+
+
+
+
+
+
Total Produk
+
{{ $totalProduk }}
+
+
+
+
+
+ + {{-- Statistik Total Transaksi --}} +
+
+
+
+
+
+
+
+
Total Transaksi
+
{{ $totalTransaksi }}
+
- {{-- Statistik Menunggu Verifikasi --}} -
-
-
-
-
-
-
-
-
Verifikasi Pending
-
{{ $petaniPending }}
-
+ {{-- Tabel Ringkasan Transaksi --}} +
+
+
+
+

Transaksi Terbaru di Platform

-
-
-
+
+
+ + + + + + + + + + + + + @forelse($transaksiTerbaru as $trx) + + + - {{-- Statistik Total Produk --}} -
-
-
-
-
-
-
-
-
Total Produk
-
{{ $totalProduk }}
-
-
-
-
-
+ - {{-- Statistik Total Transaksi --}} -
-
-
-
-
-
+
+ + + + + + @empty + + + + @endforelse + +
InvoicePetani / UsahaPembeliTotalStatusTanggal
#{{ $trx->kode_invoice }} +
+ + {{ $trx->petani->nama_lengkap ?? 'Petani Tidak Ditemukan' }} + + + + {{ $trx->petani->nama_usaha ?? '-' }} + +
+
{{ $trx->pembeli->nama_lengkap ?? 'Guest' }}Rp {{ number_format($trx->total_harga, 0, ',', '.') }} + @php + $badgeClass = match ($trx->status) { + 'selesai' => 'bg-success', + 'batal' => 'bg-danger', + 'dikirim' => 'bg-primary', + 'diproses' => 'bg-info', + 'menunggu konfirmasi' => 'bg-warning text-dark', + default => 'bg-secondary', + }; + @endphp + + {{ ucwords($trx->status) }} + + {{ $trx->created_at->format('d M Y') }}
+
+ + Belum ada transaksi baru. +
+
-
-
Total Transaksi
-
{{ $totalTransaksi }}
+
- - {{-- Tabel Ringkasan Transaksi Terbaru --}} -
-
-
-
-

Transaksi Terbaru di Platform

-
-
-
- - - - - - - - - - - - @forelse($transaksiTerbaru as $trx) - - - - - - - - @empty - - @endforelse - -
InvoicePembeliTotalStatusTanggal
#{{ $trx->kode_invoice }}{{ $trx->pembeli->nama_lengkap }}Rp {{ number_format($trx->total_harga, 0, ',', '.') }} - - {{ ucfirst($trx->status) }} - - {{ $trx->created_at->diffForHumans() }}
Belum ada transaksi.
-
- -
-
-
-
-
-
+
@endsection \ No newline at end of file diff --git a/resources/views/admin/kategori/create.blade.php b/resources/views/admin/kategori/create.blade.php new file mode 100644 index 0000000..ffecd64 --- /dev/null +++ b/resources/views/admin/kategori/create.blade.php @@ -0,0 +1,44 @@ +@extends('layouts.admin') + +@section('title', 'Tambah Kategori') +@section('page-title', 'Tambah Kategori Baru') + +@section('content') +
+
+
+
+
+ @csrf + +
+ + + @error('nama_kategori') +
{{ $message }}
+ @enderror +
+ +
+ +
+ + +
+
Opsional. Gunakan class dari FontAwesome atau Bootstrap Icons. +
+
+ +
+ Batal + +
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/admin/kategori/edit.blade.php b/resources/views/admin/kategori/edit.blade.php new file mode 100644 index 0000000..7fa622d --- /dev/null +++ b/resources/views/admin/kategori/edit.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.admin') + +@section('title', 'Edit Kategori') +@section('page-title', 'Edit Kategori') + +@section('content') +
+
+
+
+
+ @csrf + @method('PUT') + +
+ + + @error('nama_kategori') +
{{ $message }}
+ @enderror +
+ +
+ +
+ + + + +
+
+ +
+ Batal + +
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/admin/kategori/index.blade.php b/resources/views/admin/kategori/index.blade.php new file mode 100644 index 0000000..0b9f8d1 --- /dev/null +++ b/resources/views/admin/kategori/index.blade.php @@ -0,0 +1,76 @@ +@extends('layouts.admin') + +@section('title', 'Master Kategori') +@section('page-title', 'Kelola Kategori Produk') + +@section('content') +
+
+
Daftar Kategori
+ + Tambah Baru + +
+
+ @if(session('success')) + + @endif + +
+ + + + + + + + + + + + + @forelse($kategoris as $index => $kat) + + + + + + + + + @empty + + + + @endforelse + +
NoIkonNama KategoriSlugJumlah ProdukAksi
{{ $loop->iteration }} + @if($kat->ikon) + + @else + - + @endif + {{ $kat->nama_kategori }}{{ $kat->slug }} + + {{ $kat->produks_count }} Produk + + + + + +
+ @csrf @method('DELETE') + +
+
Belum ada kategori data.
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/admin/monitoring.blade.php b/resources/views/admin/monitoring.blade.php index b0f799b..ab39591 100644 --- a/resources/views/admin/monitoring.blade.php +++ b/resources/views/admin/monitoring.blade.php @@ -4,75 +4,122 @@ @section('page-title', 'Monitoring Data') @section('content') -
- {{-- TABEL SEMUA TRANSAKSI --}} -
-
-
-

Semua Transaksi

-
-
-
- - - - - - - - - - - - @foreach($transaksis as $t) - - - - - - - - @endforeach - -
InvoicePembeliTotalStatusWaktu
{{ $t->kode_invoice }}{{ $t->pembeli->nama_lengkap }}Rp {{ number_format($t->total_harga, 0, ',', '.') }}{{ strtoupper($t->status) }}{{ $t->created_at->format('d M Y H:i') }}
+
+ {{-- TABEL SEMUA TRANSAKSI --}} +
+
+
+

Semua Transaksi

- {{ $transaksis->links() }} -
-
-
+
+
+ + + + + + + + + + + + + + @forelse($transaksis as $trx) + + + - {{-- TABEL SEMUA PRODUK --}} -
-
-
-

Semua Produk Terdaftar

-
-
-
-
InvoicePetani / UsahaPembeliTotalStatusTanggalAksi
#{{ $trx->kode_invoice }} +
+ + {{ $trx->petani->nama_lengkap ?? 'Petani Tidak Ditemukan' }} + + + + {{ $trx->petani->nama_usaha ?? '-' }} + +
+
- - - - - - - - - - @foreach($produks as $p) - - - - - - - @endforeach - -
Nama ProdukPemilik (Petani)HargaStok
{{ $p->nama_produk }}{{ $p->petani->nama_lengkap }}Rp {{ number_format($p->harga, 0, ',', '.') }}{{ $p->stok }}
+ {{ $trx->pembeli->nama_lengkap ?? 'Guest' }} + + Rp {{ number_format($trx->total_harga, 0, ',', '.') }} + + + @php + $badgeClass = match ($trx->status) { + 'selesai' => 'bg-success', + 'batal' => 'bg-danger', + 'dikirim' => 'bg-primary', + 'diproses' => 'bg-info', + 'menunggu konfirmasi' => 'bg-warning text-dark', + default => 'bg-secondary', + }; + @endphp + + {{ ucwords($trx->status) }} + + + + {{ $trx->created_at->format('d M Y') }} + + + + Detail + + + + @empty + + +
+ + Belum ada transaksi baru. +
+ + + @endforelse + + +
+
+
+
+ + {{-- TABEL SEMUA PRODUK --}} +
+
+
+

Semua Produk Terdaftar

+
+
+
+ + + + + + + + + + + @foreach($produks as $p) + + + + + + + @endforeach + +
Nama ProdukPemilik (Petani)HargaStok
{{ $p->nama_produk }}{{ $p->petani->nama_lengkap }}Rp {{ number_format($p->harga, 0, ',', '.') }}{{ $p->stok }}
+
+ {{ $produks->links() }}
- {{ $produks->links() }}
-
@endsection \ No newline at end of file diff --git a/resources/views/admin/transaksi_detail.blade.php b/resources/views/admin/transaksi_detail.blade.php new file mode 100644 index 0000000..6a7f014 --- /dev/null +++ b/resources/views/admin/transaksi_detail.blade.php @@ -0,0 +1,170 @@ +@extends('layouts.admin') + +@section('title', 'Detail Transaksi') + +@section('content') +
+
+
+

Detail Transaksi

+ Invoice: #{{ $transaksi->kode_invoice }} +
+ + Kembali + +
+ +
+
+
+ + {{-- Header Card yang Bersih --}} +
+
+ Daftar Produk +
+
+ +
+
+ + + + + + + + + + + @foreach($transaksi->detailTransaksis as $detail) + + + + {{-- Harga Satuan --}} + + + {{-- Qty --}} + + + {{-- Subtotal --}} + + + @endforeach + + + {{-- Footer Total --}} + + + + + +
Produk + HargaQtySubtotal +
+
+
+ {{ $detail->produk->nama_produk }} +
+ + {{-- Detail Nama & Badge --}} +
+
{{ $detail->produk->nama_produk }} +
+ + {{-- Badge Kategori --}} + @php + $kategori = $detail->produk->kategori->nama_kategori ?? 'Umum'; + $badgeColor = match ($kategori) { + default => 'bg-primary bg-opacity-10 text-primary' + }; + @endphp + + {{ $kategori }} + +
+
+
+ Rp {{ number_format($detail->harga_satuan, 0, ',', '.') }} + + + x{{ $detail->jumlah }} + + + Rp {{ number_format($detail->subtotal, 0, ',', '.') }} +
+
+
+ Total Transaksi +

+ Rp {{ number_format($transaksi->total_harga, 0, ',', '.') }} +

+
+
+
+
+
+
+
+ + {{-- Info Pihak Terkait --}} +
+ {{-- Info Status --}} +
+
+
Status Pesanan
+ @php + $badgeClass = match ($transaksi->status) { + 'selesai' => 'bg-success', + 'batal' => 'bg-danger', + 'dikirim' => 'bg-primary', + 'diproses' => 'bg-info', + 'menunggu konfirmasi' => 'bg-warning text-dark', + default => 'bg-secondary', + }; + @endphp + + {{ ucwords($transaksi->status) }} + + + Tanggal: {{ $transaksi->created_at->format('d M Y H:i') }} + +
+
+ + {{-- Info Pembeli --}} +
+
+ Data Pembeli +
+
+
{{ $transaksi->pembeli->nama_lengkap ?? 'Guest' }}
+

+ {{ $transaksi->pembeli->no_hp ?? '-' }}

+
+ Alamat Pengiriman: +

{{ $transaksi->alamat_pengiriman }}

+
+
+ + {{-- Info Petani --}} +
+
+ Data Penjual (Petani) +
+
+
{{ $transaksi->petani->nama_lengkap ?? 'Tidak Diketahui' }}
+

{{ $transaksi->petani->nama_usaha ?? '-' }}

+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 6ce4104..00d76d1 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -3,7 +3,7 @@ - Masuk - TaniDesa + Masuk - GriyaPadi.id @@ -23,7 +23,7 @@
-

TaniDesa

+

GriyaPadi.id

Masuk untuk melanjutkan

@@ -58,7 +58,7 @@
- +
diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 089422d..0543152 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -4,7 +4,7 @@ - Daftar - TaniDesa + Daftar - GriyaPadi.id @@ -82,7 +82,7 @@

Daftar Akun

-

Gabung komunitas TaniDesa

+

Gabung komunitas GriyaPadi.id

@@ -150,7 +150,7 @@
- +
diff --git a/resources/views/auth/reset-password.blade.php b/resources/views/auth/reset-password.blade.php index 04ba791..913ddfa 100644 --- a/resources/views/auth/reset-password.blade.php +++ b/resources/views/auth/reset-password.blade.php @@ -2,7 +2,7 @@ - Reset Password - TaniDesa + Reset Password - GriyaPadi.id + +
+
+ + {{-- SIDEBAR KIRI --}} +
+ {{-- Header Sidebar --}} +
+
Pesan Masuk
+
-
+ {{-- List Chat --}} +
@foreach ($chatList as $chat) - -
+ {{-- AREA CHAT KANAN --}} +
- {{-- Chat Header --}} -
- - - + {{-- Header Chat --}} +
+
+ -
- {{ substr($lawan->nama_lengkap, 0, 1) }} -
-
-
{{ $lawan->nama_lengkap }}
- {{ $lawan->nama_usaha }} + {{-- Inisial Nama Lawan --}} +
+ {{ substr($lawan->nama_lengkap, 0, 1) }} +
+ +
+
{{ $lawan->nama_lengkap }}
+ + {{ $lawan->nama_usaha ?? 'Online' }} + +
- {{-- Chat Box --}} -
+ {{-- Isi Pesan (Chat Box) --}} +
+ @php + $currentUser = Auth::guard('petani')->check() ? Auth::guard('petani')->user() : Auth::guard('pembeli')->user(); + $currentUserType = get_class($currentUser); + @endphp + @forelse ($chats as $chat) @php - $isMe = - $chat->pengirim_id == Auth::guard('pembeli')->id() && - $chat->pengirim_type == 'App\Models\Pembeli'; + $isMe = ($chat->pengirim_id == $currentUser->id) && ($chat->pengirim_type == $currentUserType); @endphp -
-
-
{{ $chat->isi_pesan }}
-
- {{ $chat->created_at->format('H:i') }} - @if ($isMe) - - @endif -
-
+ {{-- BUBBLE CHAT --}} +
+ {{ $chat->isi_pesan }} + + {{ $chat->created_at->format('H:i') }} + @if ($isMe) + + @endif +
+ @empty -
-

Mulai percakapan - dengan {{ $lawan->nama_lengkap }}

+
+ +

Belum ada percakapan.
Sapa + {{ $lawan->nama_lengkap }} sekarang!

@endforelse
- - {{-- Footer Chat --}} + {{-- Input Footer --}} +
@@ -107,15 +250,13 @@ class="btn btn-success rounded-circle d-flex align-items-center justify-content- @section('js') -@endsection +@endsection \ No newline at end of file diff --git a/resources/views/landing/pesanan_saya.blade.php b/resources/views/landing/pesanan_saya.blade.php index 26e2df2..c8cb9b5 100644 --- a/resources/views/landing/pesanan_saya.blade.php +++ b/resources/views/landing/pesanan_saya.blade.php @@ -4,95 +4,109 @@ @section('content')
-
-

Riwayat Pesanan

- - Pesan Lagi + {{-- Header Section --}} + - @if (session('success')) - - @endif @if ($transaksis->isEmpty()) -
- -
Belum ada riwayat pesanan.
- Mulai Belanja + {{-- Empty State --}} +
+
+ +
+
Belum ada pesanan
+

Yuk, mulai isi keranjang belanja Anda dengan produk segar!

+ Mulai Belanja
@else -
+ {{-- List Transaksi --}} +
@foreach ($transaksis as $trx) -
-
+
+
+ {{-- Invoice & Status --}} +
+
+
+ +
+
+
#{{ $trx->kode_invoice }}
+ {{ \Carbon\Carbon::parse($trx->tanggal_transaksi)->format('d M Y • H:i') }} +
+
+ + @php + $statusClass = match ($trx->status) { + 'menunggu_konfirmasi', 'menunggu konfirmasi' => 'bg-warning text-dark bg-opacity-25 border border-warning', + 'diproses' => 'bg-info text-dark bg-opacity-25 border border-info', + 'dikirim' => 'bg-primary bg-opacity-10 border border-primary', + 'selesai' => 'bg-success bg-opacity-10 border border-success', + 'batal' => 'bg-danger bg-opacity-10 border border-danger', + default => 'bg-secondary text-secondary bg-opacity-10' + }; + @endphp + + {{ ucwords(str_replace('_', ' ', $trx->status)) }} + +
+
-
-
-
- -
-
-
Order #{{ $trx->kode_invoice }}
- {{ \Carbon\Carbon::parse($trx->tanggal_transaksi)->format('d F Y') }} -
-
- @if ($trx->status == 'menunggu_konfirmasi') - Menunggu - @elseif($trx->status == 'diproses') - Diproses - @elseif($trx->status == 'dikirim') - Dikirim - @elseif($trx->status == 'selesai') - Selesai - @else - Batal - @endif -
-
- @php $firstItem = $trx->details->first(); @endphp -
- -
- {{ $firstItem->produk->nama_produk }} - @if ($trx->details->count() > 1) - + {{ $trx->details->count() - 1 }} - produk lainnya - @else - ({{ $firstItem->jumlah }} kg) - @endif + {{-- Preview Produk --}} +
+ @php $firstItem = $trx->detailTransaksis->first(); @endphp + @if($firstItem) +
+ Produk + +
+
{{ $firstItem->produk->nama_produk }}
+

+ {{ $firstItem->jumlah }} kg x Rp + {{ number_format($firstItem->harga_satuan, 0, ',', '.') }} + @if ($trx->detailTransaksis->count() > 1) + + + {{ $trx->detailTransaksis->count() - 1 }} produk lainnya + @endif +

+
-
+ @endif
-
-

Total Belanja

-
Rp - {{ number_format($trx->total_harga, 0, ',', '.') }}
+ {{-- Total & Button --}} +
+ Total Tagihan +
Rp {{ number_format($trx->total_harga, 0, ',', '.') }} +
- + @if ($trx->status == 'dikirim')
+ onsubmit="return confirm('Apakah Anda yakin barang sudah diterima dengan baik?')"> @csrf -
@endif @@ -105,41 +119,143 @@ class="badge bg-danger text-danger bg-opacity-10 border border-danger">Batal -