<?php

namespace App\Http\Controllers;

use App\Models\Lahan;
use Illuminate\Http\Request;

class LahanController extends Controller
{
    public function index()
    {
        $lahans = Lahan::all();
        return view('lahan.index', compact('lahans'));
    }

    public function store(Request $request)
    {
        $request->validate([
            'nama_lahan' => 'required',
            'luas_m2' => 'required|numeric',
            'lokasi' => 'required',
        ]);

        Lahan::create($request->all());

        return redirect()->back()->with('success', 'Data lahan berhasil ditambahkan!');
    }
}
