name('home'); Route::get('/shop', [LandingController::class, 'shop'])->name('shop'); Route::get('/produk/{id}', [LandingController::class, 'detail'])->name('produk.detail'); // --- CART ROUTES --- Route::get('/cart', [CartController::class, 'index'])->name('cart'); Route::post('/cart/add', [CartController::class, 'addToCart'])->name('cart.add'); Route::delete('/cart/remove', [CartController::class, 'remove'])->name('cart.remove'); // --- ROUTE GLOBAL (BISA DIAKSES PETANI & PEMBELI) --- Route::post('/pesan/kirim', [PesanController::class, 'store']) ->middleware('auth:pembeli,petani') ->name('pesan.kirim'); // --- AUTH ROUTES (Guest Only) --- Route::middleware('guest')->group(function () { Route::get('/login', [AuthController::class, 'showLoginForm'])->name('login'); Route::post('/login-proses', [AuthController::class, 'loginProcess'])->name('login.proses'); Route::get('/register', [AuthController::class, 'showRegisterForm'])->name('register'); Route::post('/register-proses', [AuthController::class, 'registerProcess'])->name('register.proses'); Route::get('/forgot-password', [ForgotPasswordController::class, 'showLinkRequestForm'])->name('password.request'); Route::post('/forgot-password', [ForgotPasswordController::class, 'sendResetLinkEmail'])->name('password.email'); Route::get('/reset-password/{token}', [ForgotPasswordController::class, 'showResetForm'])->name('password.reset'); Route::post('/reset-password', [ForgotPasswordController::class, 'reset'])->name('password.update'); }); // Logout Route::post('/logout', [AuthController::class, 'logout'])->name('logout'); // --- PEMBELI AREA (Wajib Login) --- Route::middleware(['auth:pembeli'])->group(function () { // Menampilkan halaman checkout dari cart atau beli langsung Route::get('/checkout', [TransaksiController::class, 'checkoutPage'])->name('checkout'); // Proses Simpan Transaksi Route::post('/checkout/process', [TransaksiController::class, 'prosesCheckout'])->name('checkout.proses'); // Riwayat Pesanan Route::get('/pesanan-saya', [TransaksiController::class, 'pesananSaya'])->name('pesanan.saya'); // Route Konfirmasi Pesanan Selesai Route::post('/pesanan/{id}/selesai', [TransaksiController::class, 'konfirmasiSelesai'])->name('pesanan.selesai'); Route::patch('/cart/update', [CartController::class, 'updateCart'])->name('cart.update'); Route::delete('/cart/remove', [CartController::class, 'remove'])->name('cart.remove'); // Route Pesan untuk Pembeli Route::get('/pesan', [PesanController::class, 'index'])->name('pembeli.pesan.index'); Route::get('/pesan/{id}', [PesanController::class, 'show'])->name('pembeli.pesan.show'); Route::get('/profile', [ProfileController::class, 'editPembeli'])->name('pembeli.profile'); Route::put('/profile', [ProfileController::class, 'updatePembeli'])->name('pembeli.profile.update'); }); Route::middleware(['auth:admin'])->group(function () { Route::get('/admin/dashboard', [AdminController::class, 'dashboard'])->name('admin.dashboard'); Route::get('/admin/monitoring', [AdminController::class, 'monitoring'])->name('admin.monitoring'); Route::controller(AdminController::class)->prefix('admin/verifikasi')->group(function () { Route::get('/', 'verifikasiIndex')->name('admin.verifikasi.index'); Route::get('/{id}', 'verifikasiShow')->name('admin.verifikasi.show'); Route::post('/{id}/approve', 'verifikasiApprove'); Route::post('/{id}/reject', 'verifikasiReject'); }); Route::resource('admin/kategori', KategoriController::class)->names('admin.kategori'); Route::get('/admin/transaksi/{id}', [AdminController::class, 'transaksiDetail']) ->name('admin.transaksi.detail'); Route::get('/admin/gapoktan', [GapoktanController::class, 'index'])->name('admin.gapoktan.index'); Route::post('/admin/gapoktan', [GapoktanController::class, 'store'])->name('admin.gapoktan.store'); Route::delete('/admin/gapoktan/{id}', [GapoktanController::class, 'destroy'])->name('admin.gapoktan.destroy'); }); // --- PETANI AREA --- Route::middleware(['auth:petani'])->group(function () { Route::get('/petani/dashboard', [DashboardController::class, 'index'])->name('petani.dashboard'); // CRUD Produk Petani Route::resource('petani/produk', ProdukController::class)->names('petani.produk'); Route::delete('/petani/produk/image/{id}', [App\Http\Controllers\Petani\ProdukController::class, 'deleteImage'])->name('petani.produk.image.delete'); // Manajemen Pesanan Masuk (Petani) Route::get('/petani/pesanan', [TransaksiController::class, 'pesananMasuk'])->name('petani.pesanan.index'); Route::patch('/petani/pesanan/{id}', [TransaksiController::class, 'updateStatus'])->name('petani.pesanan.update'); Route::get('/petani/pesanan/{id}', [TransaksiController::class, 'pesananDetail'])->name('petani.pesanan.detail'); // Route Pesan untuk Petani Route::get('/petani/pesan', [PesanController::class, 'index'])->name('petani.pesan.index'); Route::get('/petani/pesan/{id}', [PesanController::class, 'show'])->name('petani.pesan.show'); Route::get('/petani/profile', [ProfileController::class, 'editPetani'])->name('petani.profile'); Route::put('/petani/profile', [ProfileController::class, 'updatePetani'])->name('petani.profile.update'); }); // Route untuk Dropdown Wilayah Laravolt Route::post('/get-kota', [\App\Http\Controllers\WilayahController::class, 'getKota'])->name('get.kota'); Route::post('/get-kecamatan', [\App\Http\Controllers\WilayahController::class, 'getKecamatan'])->name('get.kecamatan'); Route::post('/get-desa', [\App\Http\Controllers\WilayahController::class, 'getDesa'])->name('get.desa'); // --- CEK NIK GAPOKTAN AJAX --- Route::post('/cek-nik-gapoktan', function (Request $request) { $nik = $request->nik; $adaDiGapoktan = Gapoktan::where('nik', $nik)->exists(); $sudahDipakai = Petani::where('nik', $nik)->exists(); if (!$adaDiGapoktan) { return response()->json(['status' => 'tidak_ditemukan']); } elseif ($sudahDipakai) { return response()->json(['status' => 'sudah_dipakai']); } else { return response()->json(['status' => 'tersedia']); } })->name('cek.nik');