@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum HubunganDalamKeluarga: string
|
||||||
|
{
|
||||||
|
case KEPALA_KELUARGA = '01_kepala_keluarga';
|
||||||
|
case ISTRI_SUAMI = '02_istri_suami';
|
||||||
|
case ANAK = '03_anak';
|
||||||
|
case KELUARGA_INTI = '04_keluarga_inti';
|
||||||
|
case FAMILI_LAIN = '05_famili_lain';
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match($this) {
|
||||||
|
self::KEPALA_KELUARGA => 'Kepala Keluarga',
|
||||||
|
self::ISTRI_SUAMI => 'Istri/Suami',
|
||||||
|
self::ANAK => 'Anak',
|
||||||
|
self::KELUARGA_INTI => 'Keluarga Inti (Menantu, Cucu, Orang Tua, Mertua, Saudara Kandung)',
|
||||||
|
self::FAMILI_LAIN => 'Famili Lain/Pembantu',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function options(): array
|
||||||
|
{
|
||||||
|
return collect(self::cases())->map(fn ($case) => [
|
||||||
|
'value' => $case->value,
|
||||||
|
'label' => $case->label(),
|
||||||
|
])->toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum Pekerjaan: string
|
||||||
|
{
|
||||||
|
case PETANI_PEMILIK = '01_petani_pemilik';
|
||||||
|
case PETANI_PENYEWA = '02_petani_penyewa';
|
||||||
|
case BURUH_TANI = '03_buruh_tani';
|
||||||
|
case NELAYAN_PEMILIK = '04_nelayan_pemilik';
|
||||||
|
case NELAYAN_PENYEWA = '05_nelayan_penyewa';
|
||||||
|
case BURUH_NELAYAN = '06_buruh_nelayan';
|
||||||
|
case PNS = '07_pns';
|
||||||
|
case PEDAGANG = '08_pedagang';
|
||||||
|
case GURU = '09_guru';
|
||||||
|
case GURU_AGAMA = '10_guru_agama';
|
||||||
|
case PERANGKAT_DESA = '11_perangkat_desa';
|
||||||
|
case PEGAWAI_DESA = '12_pegawai_desa';
|
||||||
|
case PENGOLAHAN_INDUSTRI = '13_pengolahan_industri';
|
||||||
|
case TNI_POLRI = '14_tni_polri';
|
||||||
|
case KARYAWAN_SWASTA = '15_karyawan_swasta';
|
||||||
|
case WIRAUSAHA = '16_wirausaha';
|
||||||
|
case TKI = '17_tki';
|
||||||
|
case LAINNYA = '18_lainnya';
|
||||||
|
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match($this) {
|
||||||
|
self::PETANI_PEMILIK => 'Petani Pemilik Lahan',
|
||||||
|
self::PETANI_PENYEWA => 'Petani Penyewa',
|
||||||
|
self::BURUH_TANI => 'Buruh Tani',
|
||||||
|
self::NELAYAN_PEMILIK => 'Nelayan Pemilik Kapal/Perahu',
|
||||||
|
self::NELAYAN_PENYEWA => 'Nelayan Penyewa Kapal/Perahu',
|
||||||
|
self::BURUH_NELAYAN => 'Buruh Nelayan',
|
||||||
|
self::PNS => 'PNS',
|
||||||
|
self::PEDAGANG => 'Pedagang',
|
||||||
|
self::GURU => 'Guru',
|
||||||
|
self::GURU_AGAMA => 'Guru Agama',
|
||||||
|
self::PERANGKAT_DESA => 'Perangkat Desa',
|
||||||
|
self::PEGAWAI_DESA => 'Pegawai Kantor Desa',
|
||||||
|
self::PENGOLAHAN_INDUSTRI => 'Pengolahan/Industri',
|
||||||
|
self::TNI_POLRI => 'TNI/Polri',
|
||||||
|
self::KARYAWAN_SWASTA => 'Karyawan Swasta',
|
||||||
|
self::WIRAUSAHA => 'Wirausaha',
|
||||||
|
self::TKI => 'TKI',
|
||||||
|
self::LAINNYA => 'Lainnya',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function options(): array
|
||||||
|
{
|
||||||
|
return collect(self::cases())->map(fn ($case) => [
|
||||||
|
'value' => $case->value,
|
||||||
|
'label' => $case->label(),
|
||||||
|
])->toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum Pendidikan: string
|
||||||
|
{
|
||||||
|
case TIDAK_SEKOLAH = '01_tidak_sekolah';
|
||||||
|
case SD = '02_sd';
|
||||||
|
case SMP = '03_smp';
|
||||||
|
case SMA = '04_sma';
|
||||||
|
case DIPLOMA = '05_diploma';
|
||||||
|
case SARJANA = '06_sarjana';
|
||||||
|
case MAGISTER = '07_magister';
|
||||||
|
case DOKTOR = '08_doktor';
|
||||||
|
case PESANTREN = '09_pesantren';
|
||||||
|
case LAINNYA = '10_lainnya';
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match($this) {
|
||||||
|
self::TIDAK_SEKOLAH => 'Tidak Sekolah',
|
||||||
|
self::SD => 'SD atau Sederajat',
|
||||||
|
self::SMP => 'SMP atau Sederajat',
|
||||||
|
self::SMA => 'SMA atau Sederajat',
|
||||||
|
self::DIPLOMA => 'Diploma 1-3 (D1-D3)',
|
||||||
|
self::SARJANA => 'Sarjana (S1) atau sederajat',
|
||||||
|
self::MAGISTER => 'Magister (S2) atau sederajat',
|
||||||
|
self::DOKTOR => 'Doktor (S3) atau sederajat',
|
||||||
|
self::PESANTREN => 'Pesantren, Semiari, Wihara, atau Pendidikan Keagamaan Formal',
|
||||||
|
self::LAINNYA => 'Lainnya',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function options(): array
|
||||||
|
{
|
||||||
|
return collect(self::cases())->map(fn ($case) => [
|
||||||
|
'value' => $case->value,
|
||||||
|
'label' => $case->label(),
|
||||||
|
])->toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum Pernikahan: string
|
||||||
|
{
|
||||||
|
case BELUM_KAWIN = '01_belum_kawin';
|
||||||
|
case KAWIN_TERCATAT = '02_kawin_tercatat';
|
||||||
|
case KAWIN_BELUM_TERCATAT = '03_kawin_belum_tercatat';
|
||||||
|
case CERAI_HIDUP = '04_cerai_hidup';
|
||||||
|
case CERAI_MATI = '05_cerai_mati';
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match($this) {
|
||||||
|
self::BELUM_KAWIN => 'Belum Menikah',
|
||||||
|
self::KAWIN_TERCATAT => 'Menikah (Tercatat)',
|
||||||
|
self::KAWIN_BELUM_TERCATAT => 'Menikah (Belum Tercatat)',
|
||||||
|
self::CERAI_HIDUP => 'Cerai Hidup',
|
||||||
|
self::CERAI_MATI => 'Cerai Mati',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function options(): array
|
||||||
|
{
|
||||||
|
return collect(self::cases())->map(fn ($case) => [
|
||||||
|
'value' => $case->value,
|
||||||
|
'label' => $case->label(),
|
||||||
|
])->toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Web\Ekosistem;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
use App\Models\Ekosistem\PetaniCPM;
|
||||||
|
use App\Models\Wilayah\Provinsi;
|
||||||
|
use App\Models\Pertanian\Komoditas;
|
||||||
|
|
||||||
|
use App\Enums\Pendidikan;
|
||||||
|
use App\Enums\Pekerjaan;
|
||||||
|
use App\Enums\Pernikahan;
|
||||||
|
use App\Enums\HubunganDalamKeluarga;
|
||||||
|
|
||||||
|
class PetaniCPMController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$perPage = $request->query('per_page', 10);
|
||||||
|
$search = strtolower($request->query('search', ''));
|
||||||
|
|
||||||
|
$petani = PetaniCPM::when($search, function ($query, $search) {
|
||||||
|
return $query->where('nama', 'like', "%{$search}%");
|
||||||
|
})
|
||||||
|
->paginate($perPage);
|
||||||
|
|
||||||
|
return view('ekosistem.petani-cpm.index', compact('petani'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pendidikan = Pendidikan::options();
|
||||||
|
$pekerjaan = Pekerjaan::options();
|
||||||
|
$pernikahan = Pernikahan::options();
|
||||||
|
$statusKeluarga = HubunganDalamKeluarga::options();
|
||||||
|
|
||||||
|
$provinsi = Provinsi::all();
|
||||||
|
$komoditas = Komoditas::all();
|
||||||
|
|
||||||
|
return view('ekosistem.petani-cpm.add', compact('pendidikan', 'pekerjaan',
|
||||||
|
'pernikahan', 'statusKeluarga', 'provinsi', 'komoditas'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validatedData = $request->validate([
|
||||||
|
'nama' => ['required','string','max:255'],
|
||||||
|
'jenis_kelamin' => ['required','boolean'],
|
||||||
|
'tanggal_lahir' => ['required','date'],
|
||||||
|
'pendidikan_terakhir' => ['required', Rule::enum(Pendidikan::class)],
|
||||||
|
'alamat' => ['required','string','max:500'],
|
||||||
|
'desa_kelurahan_id' => ['required','exists:master_desa_kelurahan,id'],
|
||||||
|
'pekerjaan_utama' => ['required', Rule::enum(Pekerjaan::class)],
|
||||||
|
'komoditas_id' => ['required','exists:master_komoditas,id'],
|
||||||
|
'lama_bertani' => ['required','numeric','min:0'],
|
||||||
|
'luas_lahan' => ['required','numeric','min:0'],
|
||||||
|
'pekerjaan_sampingan' => ['nullable', Rule::enum(Pekerjaan::class)],
|
||||||
|
'komoditas_sampingan_id' => ['nullable','exists:master_komoditas,id'],
|
||||||
|
'lama_bertani_sampingan' => ['nullable','numeric','min:0'],
|
||||||
|
'luas_lahan_sampingan' => ['nullable','numeric','min:0'],
|
||||||
|
'status_perkawinan' => ['required', Rule::enum(Pernikahan::class)],
|
||||||
|
'status_keluarga' => ['required', Rule::enum(HubunganDalamKeluarga::class)],
|
||||||
|
'jumlah_tanggungan' => ['nullable','integer','min:0'],
|
||||||
|
'petani_pengumpul' => ['nullable','array'],
|
||||||
|
'petani_pengumpul.*' => ['in:petani,pengumpul'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
PetaniCPM::create([...$validatedData,
|
||||||
|
'created_by' => auth()->id(),
|
||||||
|
'updated_by' => auth()->id()]);
|
||||||
|
|
||||||
|
return redirect()->route('petani-cpm.index')->with('success', 'Data petani CPM berhasil ditambahkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(string $id)
|
||||||
|
{
|
||||||
|
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$petani = PetaniCPM::findOrFail($id);
|
||||||
|
|
||||||
|
return view('ekosistem.petani-cpm.view', compact('petani'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(string $id)
|
||||||
|
{
|
||||||
|
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$petani = PetaniCPM::findOrFail($id);
|
||||||
|
|
||||||
|
$pendidikan = Pendidikan::options();
|
||||||
|
$pekerjaan = Pekerjaan::options();
|
||||||
|
$pernikahan = Pernikahan::options();
|
||||||
|
$statusKeluarga = HubunganDalamKeluarga::options();
|
||||||
|
|
||||||
|
$provinsi = Provinsi::all();
|
||||||
|
$komoditas = Komoditas::all();
|
||||||
|
|
||||||
|
return view('ekosistem.petani-cpm.edit', compact('petani', 'pendidikan', 'pekerjaan',
|
||||||
|
'pernikahan', 'statusKeluarga', 'provinsi', 'komoditas'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, string $id)
|
||||||
|
{
|
||||||
|
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$petani = PetaniCPM::findOrFail($id);
|
||||||
|
|
||||||
|
$validatedData = $request->validate([
|
||||||
|
'nama' => ['required','string','max:255'],
|
||||||
|
'jenis_kelamin' => ['required','boolean'],
|
||||||
|
'tanggal_lahir' => ['required','date'],
|
||||||
|
'pendidikan_terakhir' => ['required', Rule::enum(Pendidikan::class)],
|
||||||
|
'alamat' => ['required','string','max:500'],
|
||||||
|
'desa_kelurahan_id' => ['required','exists:master_desa_kelurahan,id'],
|
||||||
|
'pekerjaan_utama' => ['required', Rule::enum(Pekerjaan::class)],
|
||||||
|
'komoditas_id' => ['required','exists:master_komoditas,id'],
|
||||||
|
'lama_bertani' => ['required','numeric','min:0'],
|
||||||
|
'luas_lahan' => ['required','numeric','min:0'],
|
||||||
|
'pekerjaan_sampingan' => ['nullable', Rule::enum(Pekerjaan::class)],
|
||||||
|
'komoditas_sampingan_id' => ['nullable','exists:master_komoditas,id'],
|
||||||
|
'lama_bertani_sampingan' => ['nullable','numeric','min:0'],
|
||||||
|
'luas_lahan_sampingan' => ['nullable','numeric','min:0'],
|
||||||
|
'status_perkawinan' => ['required', Rule::enum(Pernikahan::class)],
|
||||||
|
'status_keluarga' => ['required', Rule::enum(HubunganDalamKeluarga::class)],
|
||||||
|
'jumlah_tanggungan' => ['nullable','integer','min:0'],
|
||||||
|
'petani_pengumpul' => ['nullable','array'],
|
||||||
|
'petani_pengumpul.*' => ['in:petani,pengumpul'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$petani->update([...$validatedData,
|
||||||
|
'updated_by' => auth()->id()]);
|
||||||
|
|
||||||
|
return redirect()->route('petani-cpm.index')->with('success', 'Data petani CPM berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(string $id)
|
||||||
|
{
|
||||||
|
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$petani = PetaniCPM::findOrFail($id);
|
||||||
|
$petani->update(['deleted_by' => auth()->id()]);
|
||||||
|
$petani->delete();
|
||||||
|
|
||||||
|
return redirect()->route('petani-cpm.index')->with('success', 'Data petani CPM berhasil dihapus.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Ekosistem;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
use App\Models\Wilayah\DesaKelurahan;
|
||||||
|
use App\Models\Pertanian\Komoditas;
|
||||||
|
|
||||||
|
use App\Enums\Pendidikan;
|
||||||
|
use App\Enums\Pekerjaan;
|
||||||
|
use App\Enums\Pernikahan;
|
||||||
|
use App\Enums\HubunganDalamKeluarga;
|
||||||
|
|
||||||
|
class PetaniCPM extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $table = 'ekosistem_petani_cpm';
|
||||||
|
protected $appends = ['umur'];
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'nama',
|
||||||
|
'jenis_kelamin',
|
||||||
|
'tanggal_lahir',
|
||||||
|
'pendidikan_terakhir',
|
||||||
|
'alamat',
|
||||||
|
'desa_kelurahan_id',
|
||||||
|
'pekerjaan_utama',
|
||||||
|
'komoditas_id',
|
||||||
|
'lama_bertani',
|
||||||
|
'luas_lahan',
|
||||||
|
'pekerjaan_sampingan',
|
||||||
|
'komoditas_sampingan_id',
|
||||||
|
'lama_bertani_sampingan',
|
||||||
|
'luas_lahan_sampingan',
|
||||||
|
'status_perkawinan',
|
||||||
|
'status_keluarga',
|
||||||
|
'jumlah_tanggungan',
|
||||||
|
'petani_pengumpul',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'jenis_kelamin' => 'boolean',
|
||||||
|
'tanggal_lahir' => 'date',
|
||||||
|
'lama_bertani' => 'float',
|
||||||
|
'luas_lahan' => 'float',
|
||||||
|
'lama_bertani_sampingan' => 'float',
|
||||||
|
'luas_lahan_sampingan' => 'float',
|
||||||
|
'jumlah_tanggungan' => 'integer',
|
||||||
|
'petani_pengumpul' => 'array',
|
||||||
|
'pendidikan_terakhir' => Pendidikan::class,
|
||||||
|
'pekerjaan_utama' => Pekerjaan::class,
|
||||||
|
'pekerjaan_sampingan' => Pekerjaan::class,
|
||||||
|
'status_perkawinan' => Pernikahan::class,
|
||||||
|
'status_keluarga' => HubunganDalamKeluarga::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getUmurAttribute(): ?int
|
||||||
|
{
|
||||||
|
if (!$this->tanggal_lahir) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Carbon::parse($this->tanggal_lahir)->age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function desaKelurahan(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(DesaKelurahan::class, 'desa_kelurahan_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function komoditas(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Komoditas::class, 'komoditas_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function komoditasSampingan(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Komoditas::class, 'komoditas_sampingan_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('ekosistem_petani_cpm', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
|
||||||
|
$table->string('nama');
|
||||||
|
$table->boolean('jenis_kelamin');
|
||||||
|
$table->date('tanggal_lahir');
|
||||||
|
|
||||||
|
$table->string('pendidikan_terakhir')->nullable();
|
||||||
|
|
||||||
|
$table->string('alamat')->nullable();
|
||||||
|
$table->foreignId('desa_kelurahan_id')->nullable()->constrained('master_desa_kelurahan');
|
||||||
|
|
||||||
|
$table->string('pekerjaan_utama')->nullable();
|
||||||
|
$table->foreignId('komoditas_id')->nullable()->constrained('master_komoditas');
|
||||||
|
$table->float('lama_bertani', 8)->nullable();
|
||||||
|
$table->float('luas_lahan', 8)->nullable();
|
||||||
|
|
||||||
|
$table->string('pekerjaan_sampingan')->nullable();
|
||||||
|
$table->foreignId('komoditas_sampingan_id')->nullable()->constrained('master_komoditas');
|
||||||
|
$table->float('lama_bertani_sampingan', 8)->nullable();
|
||||||
|
$table->float('luas_lahan_sampingan', 8)->nullable();
|
||||||
|
|
||||||
|
$table->string('status_perkawinan')->nullable();
|
||||||
|
$table->string('status_keluarga')->nullable();
|
||||||
|
$table->integer('jumlah_tanggungan')->nullable();
|
||||||
|
|
||||||
|
$table->jsonb('petani_pengumpul')->nullable();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null');
|
||||||
|
$table->foreignId('updated_by')->nullable()->constrained('users')->onDelete('set null');
|
||||||
|
$table->foreignId('deleted_by')->nullable()->constrained('users')->onDelete('set null');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('ekosistem_petani_cpm');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,315 @@
|
|||||||
|
@extends('layout.main')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container-xxl flex-grow-1 container-p-y">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header border-bottom mb-4">
|
||||||
|
<h5 class="card-title mb-0">Tambah Petani (CPM) Baru</h5>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<form id="addNewPetaniForm" action="{{ route('petani-cpm.store') }}" method="POST" >
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<ul class="mb-0">
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<h6 class="mb-3">Informasi Petani</h6>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-nama">Nama Petani<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control @error('nama') is-invalid @enderror" id="add-petani-nama" name="nama" placeholder="Cth: John Doe" value="{{ old('nama') }}" />
|
||||||
|
@error('nama')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-jenis-kelamin">Jenis Kelamin<span class="text-danger">*</span></label>
|
||||||
|
<select class="form-control @error('jenis_kelamin') is-invalid @enderror" id="add-petani-jenis-kelamin" name="jenis_kelamin">
|
||||||
|
<option value="">Pilih Jenis Kelamin</option>
|
||||||
|
<option value="1" {{ old('jenis_kelamin') == '1' ? 'selected' : '' }}>Laki-laki</option>
|
||||||
|
<option value="0" {{ old('jenis_kelamin') == '0' ? 'selected' : '' }}>Perempuan</option>
|
||||||
|
</select>
|
||||||
|
@error('jenis_kelamin')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-tanggal-lahir">Tanggal Lahir</label>
|
||||||
|
<input type="date" class="form-control @error('tanggal_lahir') is-invalid @enderror" id="add-petani-tanggal-lahir" name="tanggal_lahir" value="{{ old('tanggal_lahir') }}" />
|
||||||
|
@error('tanggal_lahir')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-pendidikan-terakhir">Pendidikan Terakhir</label>
|
||||||
|
<select class="form-control @error('pendidikan_terakhir') is-invalid @enderror" id="add-petani-pendidikan-terakhir" name="pendidikan_terakhir">
|
||||||
|
<option value="">Pilih Pendidikan Terakhir</option>
|
||||||
|
@foreach($pendidikan as $value)
|
||||||
|
<option value="{{ $value['value'] }}" {{ old('pendidikan_terakhir') == $value['value'] ? 'selected' : '' }}>{{ $value['label'] }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('pendidikan_terakhir')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-alamat">Alamat</label>
|
||||||
|
<input type="text" class="form-control @error('alamat') is-invalid @enderror" id="add-petani-alamat" name="alamat" placeholder="Cth: Alamat lengkap petani" value="{{ old('alamat') }}" />
|
||||||
|
@error('alamat')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-provinsi">Provinsi</label>
|
||||||
|
<select class="form-control @error('provinsi_id') is-invalid @enderror" id="add-petani-provinsi" name="provinsi_id">
|
||||||
|
<option value="">Pilih Provinsi</option>
|
||||||
|
@foreach($provinsi as $p)
|
||||||
|
<option value="{{ $p->id }}" {{ old('provinsi_id') == $p->id ? 'selected' : '' }}>{{ $p->nama }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('provinsi_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-kabupaten">Kabupaten/Kota</label>
|
||||||
|
<select class="form-control @error('kabupaten_id') is-invalid @enderror" id="add-petani-kabupaten" name="kabupaten_id" disabled>
|
||||||
|
<option value="">Pilih Kabupaten/Kota</option>
|
||||||
|
</select>
|
||||||
|
@error('kabupaten_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-kecamatan">Kecamatan</label>
|
||||||
|
<select class="form-control @error('kecamatan_id') is-invalid @enderror" id="add-petani-kecamatan" name="kecamatan_id" disabled>
|
||||||
|
<option value="">Pilih Kecamatan</option>
|
||||||
|
</select>
|
||||||
|
@error('kecamatan_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-desa">Desa/Kelurahan</label>
|
||||||
|
<select class="form-control @error('desa_kelurahan_id') is-invalid @enderror" id="add-petani-desa" name="desa_kelurahan_id" disabled>
|
||||||
|
<option value="">Pilih Desa/Kelurahan</option>
|
||||||
|
</select>
|
||||||
|
@error('desa_kelurahan_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<h6 class="mb-3">Informasi Pekerjaan</h6>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-pekerjaan-utama">Pekerjaan Utama</label>
|
||||||
|
<select class="form-control @error('pekerjaan_utama') is-invalid @enderror" id="add-petani-pekerjaan-utama" name="pekerjaan_utama">
|
||||||
|
<option value="">Pilih Pekerjaan</option>
|
||||||
|
@foreach($pekerjaan as $value)
|
||||||
|
<option value="{{ $value['value'] }}" {{ old('pekerjaan_utama') == $value['value'] ? 'selected' : '' }}>{{ $value['label'] }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('pekerjaan_utama')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-komoditas">Komoditas Utama</label>
|
||||||
|
<select class="form-control @error('komoditas_id') is-invalid @enderror" id="add-petani-komoditas" name="komoditas_id">
|
||||||
|
<option value="">Pilih Komoditas</option>
|
||||||
|
@foreach($komoditas as $k)
|
||||||
|
<option value="{{ $k->id }}" {{ old('komoditas_id') == $k->id ? 'selected' : '' }}>{{ $k->nama }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('komoditas_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-luas-lahan">Luas Lahan (ha)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control @error('luas_lahan') is-invalid @enderror" id="add-petani-luas-lahan" name="luas_lahan" placeholder="Cth: 1.5" value="{{ old('luas_lahan') }}" />
|
||||||
|
@error('luas_lahan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-lama-bertani">Lama Bertani (tahun)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control @error('lama_bertani') is-invalid @enderror" id="add-petani-lama-bertani" name="lama_bertani" placeholder="Cth: 2.5" value="{{ old('lama_bertani') }}" />
|
||||||
|
@error('lama_bertani')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-pekerjaan-sampingan">Pekerjaan Sampingan</label>
|
||||||
|
<select class="form-control @error('pekerjaan_sampingan') is-invalid @enderror" id="add-petani-pekerjaan-sampingan" name="pekerjaan_sampingan">
|
||||||
|
<option value="">Pilih Pekerjaan</option>
|
||||||
|
@foreach($pekerjaan as $value)
|
||||||
|
<option value="{{ $value['value'] }}" {{ old('pekerjaan_utama') == $value['value'] ? 'selected' : '' }}>{{ $value['label'] }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('pekerjaan_sampingan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-komoditas-sampingan">Komoditas Pekerjaan Sampingan</label>
|
||||||
|
<select class="form-control @error('komoditas_sampingan_id') is-invalid @enderror" id="add-petani-komoditas-sampingan" name="komoditas_sampingan_id">
|
||||||
|
<option value="">Pilih Komoditas</option>
|
||||||
|
@foreach($komoditas as $k)
|
||||||
|
<option value="{{ $k->id }}" {{ old('komoditas_sampingan_id') == $k->id ? 'selected' : '' }}>{{ $k->nama }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('komoditas_sampingan_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-luas-lahan-sampingan">Luas Lahan Pekerjaan Sampingan (ha)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control @error('luas_lahan_sampingan') is-invalid @enderror" id="add-petani-luas-lahan-sampingan" name="luas_lahan_sampingan" placeholder="Cth: 1.5" value="{{ old('luas_lahan_sampingan') }}" />
|
||||||
|
@error('luas_lahan_sampingan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-lama-bertani-sampingan">Lama Bertani Pekerjaan Sampingan (tahun)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control @error('lama_bertani_sampingan') is-invalid @enderror" id="add-petani-lama-bertani-sampingan" name="lama_bertani_sampingan" placeholder="Cth: 2.5" value="{{ old('lama_bertani_sampingan') }}" />
|
||||||
|
@error('lama_bertani_sampingan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-petani-pengumpul">Catatan Khusus</label>
|
||||||
|
<select class="form-control @error('petani_pengumpul') is-invalid @enderror" id="add-petani-petani-pengumpul" name="petani_pengumpul[]" multiple>
|
||||||
|
<option value="petani">Petani</option>
|
||||||
|
<option value="pengumpul">Pengumpul</option>
|
||||||
|
</select>
|
||||||
|
@error('petani_pengumpul')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<h6 class="mb-3">Informasi Keluarga</h6>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-status-pernikahan">Status Pernikahan<span class="text-danger">*</span></label>
|
||||||
|
<select class="form-control @error('status_perkawinan') is-invalid @enderror" id="add-petani-status-pernikahan" name="status_perkawinan">
|
||||||
|
<option value="">Pilih Status Pernikahan</option>
|
||||||
|
@foreach($pernikahan as $value)
|
||||||
|
<option value="{{ $value['value'] }}" {{ old('status_perkawinan') == $value['value'] ? 'selected' : '' }}>{{ $value['label'] }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('status_perkawinan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-status-keluarga">Hubungan Dalam Keluarga<span class="text-danger">*</span></label>
|
||||||
|
<select class="form-control @error('status_keluarga') is-invalid @enderror" id="add-petani-status-keluarga" name="status_keluarga">
|
||||||
|
<option value="">Pilih Status Keluarga</option>
|
||||||
|
@foreach($statusKeluarga as $value)
|
||||||
|
<option value="{{ $value['value'] }}" {{ old('status_keluarga') == $value['value'] ? 'selected' : '' }}>{{ $value['label'] }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('status_keluarga')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-jumlah-anggota-keluarga">Jumlah Tanggungan</label>
|
||||||
|
<input type="number" step="1" min="0" class="form-control @error('jumlah_tanggungan') is-invalid @enderror" id="add-petani-jumlah-anggota-keluarga" name="jumlah_tanggungan" placeholder="Cth: 4" value="{{ old('jumlah_tanggungan') }}" />
|
||||||
|
@error('jumlah_tanggungan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4 text-end">
|
||||||
|
<a href="{{ route('petani-cpm.index') }}" class="btn btn-label-secondary me-2">Kembali</a>
|
||||||
|
<button type="submit" class="btn btn-success data-submit">Simpan Petani</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
'use strict';
|
||||||
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
$('#add-petani-jenis-kelamin, #add-petani-pendidikan-terakhir, #add-petani-pekerjaan-utama, #add-petani-komoditas, #add-petani-pekerjaan-sampingan, #add-petani-komoditas-sampingan, #add-petani-status-pernikahan, #add-petani-status-keluarga, #add-petani-petani-pengumpul').select2();
|
||||||
|
|
||||||
|
$('#add-petani-provinsi').select2().change(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var provinsiId = $(this).val();
|
||||||
|
$('#add-petani-kabupaten').prop('disabled', !provinsiId).val('').trigger('change');
|
||||||
|
$('#add-petani-kecamatan').prop('disabled', true).val('').trigger('change');
|
||||||
|
$('#add-petani-desa').prop('disabled', true).val('').trigger('change');
|
||||||
|
|
||||||
|
if (provinsiId) {
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ route("kabupatenkota.byprovinsi", ":id") }}'.replace(':id', provinsiId),
|
||||||
|
method: 'GET',
|
||||||
|
success: function(data) {
|
||||||
|
$('#add-petani-kabupaten').empty().append('<option value="">Pilih Kabupaten/Kota</option>');
|
||||||
|
data.forEach(function(kabupaten) {
|
||||||
|
$('#add-petani-kabupaten').append('<option value="' + kabupaten.id + '">' + kabupaten.nama + '</option>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#add-petani-kabupaten').select2().change(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var kabupatenId = $(this).val();
|
||||||
|
$('#add-petani-kecamatan').prop('disabled', !kabupatenId).val('').trigger('change');
|
||||||
|
$('#add-petani-desa').prop('disabled', true).val('').trigger('change');
|
||||||
|
|
||||||
|
if (kabupatenId) {
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ route("kecamatan.bykabupatenkota", ":id") }}'.replace(':id', kabupatenId),
|
||||||
|
method: 'GET',
|
||||||
|
success: function(data) {
|
||||||
|
$('#add-petani-kecamatan').empty().append('<option value="">Pilih Kecamatan</option>');
|
||||||
|
data.forEach(function(kecamatan) {
|
||||||
|
$('#add-petani-kecamatan').append('<option value="' + kecamatan.id + '">' + kecamatan.nama + '</option>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#add-petani-kecamatan').select2().change(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var kecamatanId = $(this).val();
|
||||||
|
$('#add-petani-desa').prop('disabled', !kecamatanId).val('').trigger('change');
|
||||||
|
|
||||||
|
if (kecamatanId) {
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ route("desakelurahan.bykecamatan", ":id") }}'.replace(':id', kecamatanId),
|
||||||
|
method: 'GET',
|
||||||
|
success: function(data) {
|
||||||
|
$('#add-petani-desa').empty().append('<option value="">Pilih Desa/Kelurahan</option>');
|
||||||
|
data.forEach(function(desa) {
|
||||||
|
$('#add-petani-desa').append('<option value="' + desa.id + '">' + desa.nama + '</option>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#add-petani-desa').select2();
|
||||||
|
|
||||||
|
$.validator.addMethod("snakecase", function(value, element) {
|
||||||
|
return this.optional(element) || /^[a-z0-9]+(_[a-z0-9]+)*$/.test(value);
|
||||||
|
}, "Gunakan format snake_case (huruf kecil dan underscore)");
|
||||||
|
|
||||||
|
$('#addNewPetaniForm').validate({
|
||||||
|
rules: {
|
||||||
|
nama: { required: true },
|
||||||
|
jenis_kelamin: { required: true },
|
||||||
|
pendidikan_terakhir: { required: true },
|
||||||
|
pekerjaan_utama: { required: true },
|
||||||
|
alamat: { required: true },
|
||||||
|
},
|
||||||
|
messages: {
|
||||||
|
nama: { required: "Nama petani wajib diisi" },
|
||||||
|
jenis_kelamin: { required: "Jenis kelamin wajib diisi" },
|
||||||
|
pendidikan_terakhir: { required: "Pendidikan terakhir wajib diisi" },
|
||||||
|
pekerjaan_utama: { required: "Pekerjaan utama wajib diisi" },
|
||||||
|
alamat: { required: "Alamat wajib diisi" },
|
||||||
|
},
|
||||||
|
errorElement: 'div',
|
||||||
|
errorPlacement: function (error, element) {
|
||||||
|
error.addClass('invalid-feedback');
|
||||||
|
element.closest('.mb-6, .form-control-validation').append(error);
|
||||||
|
},
|
||||||
|
highlight: function (element) {
|
||||||
|
$(element).addClass('is-invalid');
|
||||||
|
},
|
||||||
|
unhighlight: function (element) {
|
||||||
|
$(element).removeClass('is-invalid');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
@@ -0,0 +1,323 @@
|
|||||||
|
@extends('layout.main')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container-xxl flex-grow-1 container-p-y">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header border-bottom mb-4">
|
||||||
|
<h5 class="card-title mb-0">Edit Petani (CPM)</h5>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<form id="addNewPetaniForm" action="{{ route('petani-cpm.update', $petani->id) }}" method="POST" >
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<ul class="mb-0">
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<h6 class="mb-3">Informasi Petani</h6>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-nama">Nama Petani<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control @error('nama') is-invalid @enderror" id="add-petani-nama" name="nama"
|
||||||
|
placeholder="Cth: John Doe" value="{{ old('nama', $petani->nama) }}" />
|
||||||
|
@error('nama')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-jenis-kelamin">Jenis Kelamin<span class="text-danger">*</span></label>
|
||||||
|
<select class="form-control @error('jenis_kelamin') is-invalid @enderror" id="add-petani-jenis-kelamin" name="jenis_kelamin">
|
||||||
|
<option value="">Pilih Jenis Kelamin</option>
|
||||||
|
<option value="1" {{ old('jenis_kelamin', $petani->jenis_kelamin) == '1' ? 'selected' : '' }}>Laki-laki</option>
|
||||||
|
<option value="0" {{ old('jenis_kelamin', $petani->jenis_kelamin) == '0' ? 'selected' : '' }}>Perempuan</option>
|
||||||
|
</select>
|
||||||
|
@error('jenis_kelamin')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-tanggal-lahir">Tanggal Lahir</label>
|
||||||
|
<input type="date" class="form-control @error('tanggal_lahir') is-invalid @enderror" id="add-petani-tanggal-lahir" name="tanggal_lahir"
|
||||||
|
value="{{ old('tanggal_lahir', $petani->tanggal_lahir?->format('Y-m-d')) }}" />
|
||||||
|
@error('tanggal_lahir')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-pendidikan-terakhir">Pendidikan Terakhir</label>
|
||||||
|
<select class="form-control @error('pendidikan_terakhir') is-invalid @enderror" id="add-petani-pendidikan-terakhir" name="pendidikan_terakhir">
|
||||||
|
<option value="">Pilih Pendidikan Terakhir</option>
|
||||||
|
@foreach($pendidikan as $value)
|
||||||
|
<option value="{{ $value['value'] }}" {{ old('pendidikan_terakhir', $petani->pendidikan_terakhir->value) == $value['value'] ? 'selected' : '' }}>{{ $value['label'] }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('pendidikan_terakhir')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-alamat">Alamat</label>
|
||||||
|
<input type="text" class="form-control @error('alamat') is-invalid @enderror" id="add-petani-alamat" name="alamat"
|
||||||
|
placeholder="Cth: Alamat lengkap petani" value="{{ old('alamat', $petani->alamat) }}" />
|
||||||
|
@error('alamat')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-provinsi">Provinsi</label>
|
||||||
|
<select class="form-control @error('provinsi_id') is-invalid @enderror" id="add-petani-provinsi" name="provinsi_id">
|
||||||
|
<option value="">Pilih Provinsi</option>
|
||||||
|
@foreach($provinsi as $p)
|
||||||
|
<option value="{{ $p->id }}" {{ old('provinsi_id', $petani->desaKelurahan->kecamatan->kabupatenKota->provinsi_id) == $p->id ? 'selected' : '' }}>{{ $p->nama }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('provinsi_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-kabupaten">Kabupaten/Kota</label>
|
||||||
|
<select class="form-control @error('kabupaten_id') is-invalid @enderror" id="add-petani-kabupaten" name="kabupaten_id" >
|
||||||
|
<option value="">Pilih Kabupaten/Kota</option>
|
||||||
|
<option value="{{ $petani->desaKelurahan->kecamatan->kabupatenKota->id }}" selected>{{ $petani->desaKelurahan->kecamatan->kabupatenKota->nama }}</option>
|
||||||
|
</select>
|
||||||
|
@error('kabupaten_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-kecamatan">Kecamatan</label>
|
||||||
|
<select class="form-control @error('kecamatan_id') is-invalid @enderror" id="add-petani-kecamatan" name="kecamatan_id" >
|
||||||
|
<option value="">Pilih Kecamatan</option>
|
||||||
|
<option value="{{ $petani->desaKelurahan->kecamatan->id }}" selected>{{ $petani->desaKelurahan->kecamatan->nama }}</option>
|
||||||
|
</select>
|
||||||
|
@error('kecamatan_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-desa">Desa/Kelurahan</label>
|
||||||
|
<select class="form-control @error('desa_kelurahan_id') is-invalid @enderror" id="add-petani-desa" name="desa_kelurahan_id" >
|
||||||
|
<option value="">Pilih Desa/Kelurahan</option>
|
||||||
|
<option value="{{ $petani->desaKelurahan->id }}" selected>{{ $petani->desaKelurahan->nama }}</option>
|
||||||
|
</select>
|
||||||
|
@error('desa_kelurahan_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<h6 class="mb-3">Informasi Pekerjaan</h6>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-pekerjaan-utama">Pekerjaan Utama</label>
|
||||||
|
<select class="form-control @error('pekerjaan_utama') is-invalid @enderror" id="add-petani-pekerjaan-utama" name="pekerjaan_utama">
|
||||||
|
<option value="">Pilih Pekerjaan</option>
|
||||||
|
@foreach($pekerjaan as $value)
|
||||||
|
<option value="{{ $value['value'] }}" {{ old('pekerjaan_utama', $petani->pekerjaan_utama->value) == $value['value'] ? 'selected' : '' }}>{{ $value['label'] }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('pekerjaan_utama')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-komoditas">Komoditas Utama</label>
|
||||||
|
<select class="form-control @error('komoditas_id') is-invalid @enderror" id="add-petani-komoditas" name="komoditas_id">
|
||||||
|
<option value="">Pilih Komoditas</option>
|
||||||
|
@foreach($komoditas as $k)
|
||||||
|
<option value="{{ $k->id }}" {{ old('komoditas_id', $petani->komoditas_id) == $k->id ? 'selected' : '' }}>{{ $k->nama }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('komoditas_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-luas-lahan">Luas Lahan (ha)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control @error('luas_lahan') is-invalid @enderror" id="add-petani-luas-lahan" name="luas_lahan" placeholder="Cth: 1.5" value="{{ old('luas_lahan', $petani->luas_lahan) }}" />
|
||||||
|
@error('luas_lahan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-lama-bertani">Lama Bertani (tahun)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control @error('lama_bertani') is-invalid @enderror" id="add-petani-lama-bertani" name="lama_bertani" placeholder="Cth: 2.5" value="{{ old('lama_bertani', $petani->lama_bertani) }}" />
|
||||||
|
@error('lama_bertani')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-pekerjaan-sampingan">Pekerjaan Sampingan</label>
|
||||||
|
<select class="form-control @error('pekerjaan_sampingan') is-invalid @enderror" id="add-petani-pekerjaan-sampingan" name="pekerjaan_sampingan">
|
||||||
|
<option value="">Pilih Pekerjaan</option>
|
||||||
|
@foreach($pekerjaan as $value)
|
||||||
|
<option value="{{ $value['value'] }}" {{ old('pekerjaan_sampingan', $petani->pekerjaan_sampingan->value) == $value['value'] ? 'selected' : '' }}>{{ $value['label'] }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('pekerjaan_sampingan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-komoditas-sampingan">Komoditas Pekerjaan Sampingan</label>
|
||||||
|
<select class="form-control @error('komoditas_sampingan_id') is-invalid @enderror" id="add-petani-komoditas-sampingan" name="komoditas_sampingan_id">
|
||||||
|
<option value="">Pilih Komoditas</option>
|
||||||
|
@foreach($komoditas as $k)
|
||||||
|
<option value="{{ $k->id }}" {{ old('komoditas_sampingan_id', $petani->komoditas_sampingan_id) == $k->id ? 'selected' : '' }}>{{ $k->nama }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('komoditas_sampingan_id')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-luas-lahan-sampingan">Luas Lahan Pekerjaan Sampingan (ha)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control @error('luas_lahan_sampingan') is-invalid @enderror" id="add-petani-luas-lahan-sampingan" name="luas_lahan_sampingan" placeholder="Cth: 1.5" value="{{ old('luas_lahan_sampingan', $petani->luas_lahan_sampingan) }}" />
|
||||||
|
@error('luas_lahan_sampingan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-lama-bertani-sampingan">Lama Bertani Pekerjaan Sampingan (tahun)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control @error('lama_bertani_sampingan') is-invalid @enderror" id="add-petani-lama-bertani-sampingan" name="lama_bertani_sampingan" placeholder="Cth: 2.5" value="{{ old('lama_bertani_sampingan', $petani->lama_bertani_sampingan) }}" />
|
||||||
|
@error('lama_bertani_sampingan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-petani-pengumpul">Catatan Khusus</label>
|
||||||
|
<select class="form-control @error('petani_pengumpul') is-invalid @enderror" id="add-petani-petani-pengumpul" name="petani_pengumpul[]" multiple>
|
||||||
|
<option value="petani" {{ in_array('petani', old('petani_pengumpul', $petani->petani_pengumpul ?? [])) ? 'selected' : '' }}>Petani</option>
|
||||||
|
<option value="pengumpul" {{ in_array('pengumpul', old('petani_pengumpul', $petani->petani_pengumpul ?? [])) ? 'selected' : '' }}>Pengumpul</option>
|
||||||
|
</select>
|
||||||
|
@error('petani_pengumpul')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<h6 class="mb-3">Informasi Keluarga</h6>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-status-pernikahan">Status Pernikahan<span class="text-danger">*</span></label>
|
||||||
|
<select class="form-control @error('status_perkawinan') is-invalid @enderror" id="add-petani-status-pernikahan" name="status_perkawinan">
|
||||||
|
<option value="">Pilih Status Pernikahan</option>
|
||||||
|
@foreach($pernikahan as $value)
|
||||||
|
<option value="{{ $value['value'] }}" {{ old('status_perkawinan', $petani->status_perkawinan->value) == $value['value'] ? 'selected' : '' }}>{{ $value['label'] }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('status_perkawinan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-status-keluarga">Hubungan Dalam Keluarga<span class="text-danger">*</span></label>
|
||||||
|
<select class="form-control @error('status_keluarga') is-invalid @enderror" id="add-petani-status-keluarga" name="status_keluarga">
|
||||||
|
<option value="">Pilih Status Keluarga</option>
|
||||||
|
@foreach($statusKeluarga as $value)
|
||||||
|
<option value="{{ $value['value'] }}" {{ old('status_keluarga', $petani->status_keluarga->value) == $value['value'] ? 'selected' : '' }}>{{ $value['label'] }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('status_keluarga')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-jumlah-anggota-keluarga">Jumlah Tanggungan</label>
|
||||||
|
<input type="number" step="1" min="0" class="form-control @error('jumlah_tanggungan') is-invalid @enderror" id="add-petani-jumlah-anggota-keluarga" name="jumlah_tanggungan"
|
||||||
|
placeholder="Cth: 4" value="{{ old('jumlah_tanggungan', $petani->jumlah_tanggungan) }}" />
|
||||||
|
@error('jumlah_tanggungan')<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4 text-end">
|
||||||
|
<a href="{{ route('petani-cpm.index') }}" class="btn btn-label-secondary me-2">Kembali</a>
|
||||||
|
<button type="submit" class="btn btn-success data-submit">Simpan Petani</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
'use strict';
|
||||||
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
$('#add-petani-jenis-kelamin, #add-petani-pendidikan-terakhir, #add-petani-pekerjaan-utama, #add-petani-komoditas, #add-petani-pekerjaan-sampingan, #add-petani-komoditas-sampingan, #add-petani-status-pernikahan, #add-petani-status-keluarga, #add-petani-petani-pengumpul').select2();
|
||||||
|
|
||||||
|
$('#add-petani-provinsi').select2().change(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var provinsiId = $(this).val();
|
||||||
|
$('#add-petani-kabupaten').prop('disabled', !provinsiId).val('').trigger('change');
|
||||||
|
$('#add-petani-kecamatan').prop('disabled', true).val('').trigger('change');
|
||||||
|
$('#add-petani-desa').prop('disabled', true).val('').trigger('change');
|
||||||
|
|
||||||
|
if (provinsiId) {
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ route("kabupatenkota.byprovinsi", ":id") }}'.replace(':id', provinsiId),
|
||||||
|
method: 'GET',
|
||||||
|
success: function(data) {
|
||||||
|
$('#add-petani-kabupaten').empty().append('<option value="">Pilih Kabupaten/Kota</option>');
|
||||||
|
data.forEach(function(kabupaten) {
|
||||||
|
$('#add-petani-kabupaten').append('<option value="' + kabupaten.id + '">' + kabupaten.nama + '</option>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#add-petani-kabupaten').select2().change(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var kabupatenId = $(this).val();
|
||||||
|
$('#add-petani-kecamatan').prop('disabled', !kabupatenId).val('').trigger('change');
|
||||||
|
$('#add-petani-desa').prop('disabled', true).val('').trigger('change');
|
||||||
|
|
||||||
|
if (kabupatenId) {
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ route("kecamatan.bykabupatenkota", ":id") }}'.replace(':id', kabupatenId),
|
||||||
|
method: 'GET',
|
||||||
|
success: function(data) {
|
||||||
|
$('#add-petani-kecamatan').empty().append('<option value="">Pilih Kecamatan</option>');
|
||||||
|
data.forEach(function(kecamatan) {
|
||||||
|
$('#add-petani-kecamatan').append('<option value="' + kecamatan.id + '">' + kecamatan.nama + '</option>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#add-petani-kecamatan').select2().change(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var kecamatanId = $(this).val();
|
||||||
|
$('#add-petani-desa').prop('disabled', !kecamatanId).val('').trigger('change');
|
||||||
|
|
||||||
|
if (kecamatanId) {
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ route("desakelurahan.bykecamatan", ":id") }}'.replace(':id', kecamatanId),
|
||||||
|
method: 'GET',
|
||||||
|
success: function(data) {
|
||||||
|
$('#add-petani-desa').empty().append('<option value="">Pilih Desa/Kelurahan</option>');
|
||||||
|
data.forEach(function(desa) {
|
||||||
|
$('#add-petani-desa').append('<option value="' + desa.id + '">' + desa.nama + '</option>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#add-petani-desa').select2();
|
||||||
|
|
||||||
|
$.validator.addMethod("snakecase", function(value, element) {
|
||||||
|
return this.optional(element) || /^[a-z0-9]+(_[a-z0-9]+)*$/.test(value);
|
||||||
|
}, "Gunakan format snake_case (huruf kecil dan underscore)");
|
||||||
|
|
||||||
|
$('#addNewPetaniForm').validate({
|
||||||
|
rules: {
|
||||||
|
nama: { required: true },
|
||||||
|
jenis_kelamin: { required: true },
|
||||||
|
pendidikan_terakhir: { required: true },
|
||||||
|
pekerjaan_utama: { required: true },
|
||||||
|
alamat: { required: true },
|
||||||
|
},
|
||||||
|
messages: {
|
||||||
|
nama: { required: "Nama petani wajib diisi" },
|
||||||
|
jenis_kelamin: { required: "Jenis kelamin wajib diisi" },
|
||||||
|
pendidikan_terakhir: { required: "Pendidikan terakhir wajib diisi" },
|
||||||
|
pekerjaan_utama: { required: "Pekerjaan utama wajib diisi" },
|
||||||
|
alamat: { required: "Alamat wajib diisi" },
|
||||||
|
},
|
||||||
|
errorElement: 'div',
|
||||||
|
errorPlacement: function (error, element) {
|
||||||
|
error.addClass('invalid-feedback');
|
||||||
|
element.closest('.mb-6, .form-control-validation').append(error);
|
||||||
|
},
|
||||||
|
highlight: function (element) {
|
||||||
|
$(element).addClass('is-invalid');
|
||||||
|
},
|
||||||
|
unhighlight: function (element) {
|
||||||
|
$(element).removeClass('is-invalid');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
@extends('layout.main')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container-xxl flex-grow-1 container-p-y">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body border-bottom">
|
||||||
|
<form method="GET" action="{{ route('tabel.index') }}" class="d-flex justify-content-between align-items-center row gap-3 gap-md-0">
|
||||||
|
<div class="col-md-auto">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<label class="me-2 text-nowrap">Show</label>
|
||||||
|
<select name="per_page" class="form-select form-select-sm w-auto" onchange="this.form.submit()">
|
||||||
|
<option value="10" {{ request('per_page') == 10 ? 'selected' : '' }}>10</option>
|
||||||
|
<option value="25" {{ request('per_page') == 25 ? 'selected' : '' }}>25</option>
|
||||||
|
<option value="50" {{ request('per_page') == 50 ? 'selected' : '' }}>50</option>
|
||||||
|
</select>
|
||||||
|
<label class="ms-2 text-nowrap">entries</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-auto d-flex gap-2">
|
||||||
|
<div class="input-group input-group-sm w-auto">
|
||||||
|
<input type="text" name="search" class="form-control" placeholder="Cari Nama Petani..." value="{{ request('search') }}">
|
||||||
|
<button type="submit" class="btn btn-outline-primary"><i class="ti tabler-search"></i></button>
|
||||||
|
</div>
|
||||||
|
<a href="{{ route('petani-cpm.create') }}" class="btn btn-sm btn-primary">
|
||||||
|
<i class="ti tabler-plus me-1"></i> Tambah
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-responsive text-nowrap">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead class="border-top">
|
||||||
|
<tr>
|
||||||
|
<th>No</th>
|
||||||
|
<th>Nama Petani</th>
|
||||||
|
<th>Jenis Kelamin</th>
|
||||||
|
<th>Usia</th>
|
||||||
|
<th>Desa/Kelurahan</th>
|
||||||
|
<th>Aksi</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@forelse($petani as $p)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $loop->iteration }}</td>
|
||||||
|
<td><span class="text-heading">{{ $p->nama }}</span></td>
|
||||||
|
<td><span class="text-muted">{{ $p->jenis_kelamin ? 'Laki-laki' : 'Perempuan' }}</span></td>
|
||||||
|
<td><span class="text-muted">{{ $p->umur }} tahun</span></td>
|
||||||
|
<td><span class="text-muted">{{ $p->desaKelurahan->nama }}, {{ $p->desaKelurahan->kecamatan->nama }}, {{ $p->desaKelurahan->kecamatan->kabupatenKota->nama }}, {{ $p->desaKelurahan->kecamatan->kabupatenKota->provinsi->nama }}</span></td>
|
||||||
|
<td>
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<a href="{{ route('petani-cpm.edit', $p->id) }}" class="btn btn-icon btn-text-secondary rounded-pill edit-record"><i class="ti tabler-edit ti-md"></i></a>
|
||||||
|
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill delete-record" data-id="{{ $p->id }}" data-nama="{{ $p->nama }}"><i class="ti tabler-trash ti-md"></i></a>
|
||||||
|
<a href="{{ route('petani-cpm.show', $p->id) }}" class="btn btn-icon btn-text-secondary rounded-pill view-record"><i class="ti tabler-eye ti-md"></i></a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="text-center py-4">Tidak ada data ditemukan.</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-footer d-flex justify-content-center justify-content-md-end border-top">
|
||||||
|
{{ $petani->appends(request()->query())->links('pagination::bootstrap-5') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
$(".delete-record").click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const id = $(this).data('id');
|
||||||
|
const name = $(this).data('nama');
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Hapus?',
|
||||||
|
text: `Kolom ${name} akan dihapus!`,
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Ya, Hapus!',
|
||||||
|
customClass: { confirmButton: 'btn btn-danger me-3', cancelButton: 'btn btn-label-secondary' },
|
||||||
|
buttonsStyling: false
|
||||||
|
}).then(function (result) {
|
||||||
|
if (result.value) {
|
||||||
|
$.ajax({
|
||||||
|
url: "{{ route('petani-cpm.destroy', ':id') }}".replace(':id', id),
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
_token: '{{ csrf_token() }}',
|
||||||
|
_method: 'DELETE'
|
||||||
|
},
|
||||||
|
success: function () {
|
||||||
|
Swal.fire({ icon: 'success', title: 'Terhapus!', showConfirmButton: false, timer: 1500 })
|
||||||
|
.then(() => location.reload());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
@extends('layout.main')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container-xxl flex-grow-1 container-p-y">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header border-bottom mb-4">
|
||||||
|
<h5 class="card-title mb-0">Edit Petani (CPM)</h5>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<form id="viewPetaniForm">
|
||||||
|
|
||||||
|
<h6 class="mb-3">Informasi Petani</h6>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-nama">Nama Petani</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-nama" name="nama" readonly
|
||||||
|
placeholder="Cth: John Doe" value="{{ $petani->nama }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-jenis-kelamin">Jenis Kelamin<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-jenis-kelamin" name="jenis_kelamin" readonly
|
||||||
|
placeholder="Cth: John Doe" value="{{ $petani->jenis_kelamin == 1 ? 'Laki-laki' : 'Perempuan' }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-tanggal-lahir">Tanggal Lahir</label>
|
||||||
|
<input type="date" class="form-control" id="add-petani-tanggal-lahir" name="tanggal_lahir"
|
||||||
|
value="{{ $petani->tanggal_lahir?->format('Y-m-d') }}" readonly/>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-pendidikan-terakhir">Pendidikan Terakhir</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-pendidikan-terakhir" name="pendidikan_terakhir" readonly
|
||||||
|
value="{{ $petani->pendidikan_terakhir?->label() }}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-alamat">Alamat</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-alamat" name="alamat"
|
||||||
|
placeholder="Cth: Alamat lengkap petani" value="{{ $petani->alamat }}" readonly/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-provinsi">Provinsi</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-provinsi" name="provinsi_id" readonly
|
||||||
|
value="{{ $petani->desaKelurahan->kecamatan->kabupatenKota->provinsi->nama }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-kabupaten">Kabupaten/Kota</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-kabupaten" name="kabupaten_id" readonly
|
||||||
|
value="{{ $petani->desaKelurahan->kecamatan->kabupatenKota->nama }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-kecamatan">Kecamatan</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-kecamatan" name="kecamatan_id" readonly
|
||||||
|
value="{{ $petani->desaKelurahan->kecamatan->nama }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-desa">Desa/Kelurahan</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-desa" name="desa_kelurahan_id" readonly
|
||||||
|
value="{{ $petani->desaKelurahan->nama }}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<h6 class="mb-3">Informasi Pekerjaan</h6>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-pekerjaan-utama">Pekerjaan Utama</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-pekerjaan-utama" name="pekerjaan_utama" readonly
|
||||||
|
value="{{ $petani->pekerjaan_utama?->label() ?? '' }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-komoditas">Komoditas Utama</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-komoditas" name="komoditas_utama" readonly
|
||||||
|
value="{{ $petani->komoditas?->nama ?? '' }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-luas-lahan">Luas Lahan (ha)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control" id="add-petani-luas-lahan" name="luas_lahan" readonly
|
||||||
|
value="{{ $petani->luas_lahan }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-lama-bertani">Lama Bertani (tahun)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control" id="add-petani-lama-bertani" name="lama_bertani" readonly
|
||||||
|
value="{{ $petani->lama_bertani }}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-pekerjaan-sampingan">Pekerjaan Sampingan</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-pekerjaan-sampingan" name="pekerjaan_sampingan" readonly
|
||||||
|
value="{{ $petani->pekerjaan_sampingan?->label() ?? '' }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-komoditas-sampingan">Komoditas Pekerjaan Sampingan</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-komoditas-sampingan" name="komoditas_sampingan" readonly
|
||||||
|
value="{{ $petani->komoditasSampingan?->nama ?? '' }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-luas-lahan-sampingan">Luas Lahan Pekerjaan Sampingan (ha)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control" id="add-petani-luas-lahan-sampingan" name="luas_lahan_sampingan" readonly
|
||||||
|
value="{{ $petani->luas_lahan_sampingan }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-lama-bertani-sampingan">Lama Bertani Pekerjaan Sampingan (tahun)</label>
|
||||||
|
<input type="number" step="0.01" class="form-control" id="add-petani-lama-bertani-sampingan" name="lama_bertani_sampingan" readonly
|
||||||
|
value="{{ $petani->lama_bertani_sampingan }}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-petani-pengumpul">Catatan Khusus</label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-petani-pengumpul" name="catatan_khusus" readonly
|
||||||
|
value="{{ implode(', ', $petani->petani_pengumpul ?? []) }}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<h6 class="mb-3">Informasi Keluarga</h6>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-status-pernikahan">Status Pernikahan<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-status-pernikahan" name="status_perkawinan" readonly
|
||||||
|
value="{{ $petani->status_perkawinan?->label() }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-status-keluarga">Hubungan Dalam Keluarga<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" id="add-petani-status-keluarga" name="status_keluarga" readonly
|
||||||
|
value="{{ $petani->status_keluarga?->label() }}" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 mb-4 form-control-validation">
|
||||||
|
<label class="form-label" for="add-petani-jumlah-anggota-keluarga">Jumlah Tanggungan</label>
|
||||||
|
<input type="number" step="1" min="0" class="form-control" id="add-petani-jumlah-anggota-keluarga" name="jumlah_tanggungan" readonly
|
||||||
|
value="{{ $petani->jumlah_tanggungan }}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4 text-end">
|
||||||
|
<a href="{{ route('petani-cpm.index') }}" class="btn btn-label-secondary me-2">Kembali</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
'use strict';
|
||||||
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
@@ -117,10 +117,13 @@ Route::middleware('auth')
|
|||||||
Route::put('tabel/{tabelId}/kolom/{id}/move-down', [App\Http\Controllers\Web\Ekosistem\KolomBasisDataController::class, 'moveDown'])->name('tabel.kolom.move-down');
|
Route::put('tabel/{tabelId}/kolom/{id}/move-down', [App\Http\Controllers\Web\Ekosistem\KolomBasisDataController::class, 'moveDown'])->name('tabel.kolom.move-down');
|
||||||
Route::resource('tabel.kolom', App\Http\Controllers\Web\Ekosistem\KolomBasisDataController::class)->only(['show', 'store', 'update', 'destroy']);
|
Route::resource('tabel.kolom', App\Http\Controllers\Web\Ekosistem\KolomBasisDataController::class)->only(['show', 'store', 'update', 'destroy']);
|
||||||
Route::resource('tabel.data', App\Http\Controllers\Web\Ekosistem\ValueBasisDataController::class);
|
Route::resource('tabel.data', App\Http\Controllers\Web\Ekosistem\ValueBasisDataController::class);
|
||||||
|
Route::resource('petani-cpm', App\Http\Controllers\Web\Ekosistem\PetaniCPMController::class);
|
||||||
|
|
||||||
// Monev
|
// Monev
|
||||||
Route::resource('framework', App\Http\Controllers\Web\Program\FrameworkController::class);
|
Route::resource('framework', App\Http\Controllers\Web\Program\FrameworkController::class);
|
||||||
Route::resource('framework.transformasi', App\Http\Controllers\Web\Program\TransformasiController::class)->only(['show', 'store', 'update', 'destroy']);
|
Route::resource('framework.transformasi', App\Http\Controllers\Web\Program\TransformasiController::class)->only(['show', 'store', 'update', 'destroy']);
|
||||||
Route::resource('framework.transformasi.aktivitas', App\Http\Controllers\Web\Program\AktivitasController::class)->only(['show', 'store', 'update', 'destroy']);
|
Route::resource('framework.transformasi.aktivitas', App\Http\Controllers\Web\Program\AktivitasController::class)->only(['show', 'store', 'update', 'destroy']);
|
||||||
Route::resource('framework.transformasi.aktivitas.target', App\Http\Controllers\Web\Program\TargetController::class)->only(['show', 'store', 'update', 'destroy']);
|
Route::resource('framework.transformasi.aktivitas.target', App\Http\Controllers\Web\Program\TargetController::class)->only(['show', 'store', 'update', 'destroy']);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user