diff --git a/app/Http/Controllers/Web/Produktivitas/PetaniController.php b/app/Http/Controllers/Web/Produktivitas/PetaniController.php index 4723bfc..70109f3 100644 --- a/app/Http/Controllers/Web/Produktivitas/PetaniController.php +++ b/app/Http/Controllers/Web/Produktivitas/PetaniController.php @@ -80,7 +80,9 @@ class PetaniController extends Controller 'kk' => ['nullable', 'min:16', 'max:16'], 'file_kk' => ['nullable', 'image', 'mimes:jpeg,jpg,png', 'max:2048'], 'foto' => ['nullable', 'image', 'mimes:jpeg,jpg,png', 'max:2048'], - 'nomor_telepon' => ['nullable', 'numeric', 'max:20'], + 'nomor_telepon' => ['nullable', 'digits_between:11,13'], + ], [ + 'nomor_telepon.digits_between' => 'Nomor telepon harus berupa angka 11 sampai 13 digit.', ]); if ($request->hasFile('file_ktp')) { @@ -162,7 +164,9 @@ class PetaniController extends Controller 'kk' => ['nullable', 'min:16', 'max:16'], 'file_kk' => ['nullable', 'file', 'mimes:jpeg,jpg,png,pdf', 'max:2048'], 'foto' => ['nullable', 'file', 'mimes:jpeg,jpg,png', 'max:2048'], - 'nomor_telepon' => ['nullable', 'numeric', 'max:20'], + 'nomor_telepon' => ['nullable', 'digits_between:11,13'], + ], [ + 'nomor_telepon.digits_between' => 'Nomor telepon harus berupa angka 11 sampai 13 digit.', ]); if ($request->hasFile('file_ktp')) { diff --git a/app/Models/Pertanian/Petani.php b/app/Models/Pertanian/Petani.php index 54668c2..5a55294 100644 --- a/app/Models/Pertanian/Petani.php +++ b/app/Models/Pertanian/Petani.php @@ -22,7 +22,7 @@ class Petani extends Model 'uid', 'nama', - 'telepon', + 'nomor_telepon', 'alamat', 'kk', diff --git a/resources/views/produktivitas/petani/add.blade.php b/resources/views/produktivitas/petani/add.blade.php index c42e23a..0a1aa2d 100644 --- a/resources/views/produktivitas/petani/add.blade.php +++ b/resources/views/produktivitas/petani/add.blade.php @@ -12,16 +12,13 @@ @endif
- - - @include('produktivitas.petani.header', ['petani' => null]) - -
-
- +
+
Tambah Petani Baru
+
+
@csrf
@@ -35,7 +32,7 @@ width="120" alt="User avatar" />
@@ -157,7 +154,7 @@
+ placeholder="Cth: 081234567890" value="{{ old('nomor_telepon') }}" minlength="11" maxlength="13" /> @error('nomor_telepon')
{{ $message }}
@enderror
@@ -183,7 +180,7 @@
- +
@@ -191,7 +188,6 @@
-
@endsection @@ -278,7 +274,7 @@ status_perkawinan: { required: true }, file_ktp: { accept: "image/png, image/jpeg, image/jpg" }, file_kk: { accept: "image/png, image/jpeg, image/jpg" }, - nomor_telepon: { required: false, digits: true, maxlength: 20 } + nomor_telepon: { required: false, digits: true, minlength: 11, maxlength: 13 } }, messages: { nama: { required: "Nama petani wajib diisi" }, @@ -296,7 +292,11 @@ status_perkawinan: { required: "Status perkawinan wajib diisi" }, file_ktp: { accept: "Format file tidak valid. Harap unggah file berupa gambar (PNG, JPEG, JPG)" }, file_kk: { accept: "Format file tidak valid. Harap unggah file berupa gambar (PNG, JPEG, JPG)" }, - nomor_telepon: { digits: "Nomor telepon harus berupa angka", maxlength: "Nomor telepon maksimal 20 digit" } + nomor_telepon: { + digits: "Nomor telepon harus berupa angka", + minlength: "Nomor telepon minimal 11 digit", + maxlength: "Nomor telepon maksimal 13 digit" + } }, errorElement: 'div', errorPlacement: function (error, element) { @@ -312,4 +312,4 @@ }); }); -@endpush \ No newline at end of file +@endpush diff --git a/resources/views/produktivitas/petani/edit.blade.php b/resources/views/produktivitas/petani/edit.blade.php index 2848cba..a61b21c 100644 --- a/resources/views/produktivitas/petani/edit.blade.php +++ b/resources/views/produktivitas/petani/edit.blade.php @@ -159,7 +159,7 @@
+ placeholder="Cth: 081234567890" value="{{ old('nomor_telepon', $petani->nomor_telepon) }}" minlength="11" maxlength="13" /> @error('nomor_telepon')
{{ $message }}
@enderror
@@ -303,7 +303,7 @@ status_perkawinan: { required: true }, file_ktp: { accept: "image/png, image/jpeg, image/jpg" }, file_kk: { accept: "image/png, image/jpeg, image/jpg" }, - nomor_telepon: { required: false, digits: true, maxlength: 20 } + nomor_telepon: { required: false, digits: true, minlength: 11, maxlength: 13 } }, messages: { nama: { required: "Nama petani wajib diisi" }, @@ -321,7 +321,11 @@ status_perkawinan: { required: "Status perkawinan wajib diisi" }, file_ktp: { accept: "Format file tidak valid. Harap unggah file berupa gambar (PNG, JPEG, JPG)" }, file_kk: { accept: "Format file tidak valid. Harap unggah file berupa gambar (PNG, JPEG, JPG)" }, - nomor_telepon: { digits: "Nomor telepon harus berupa angka", maxlength: "Nomor telepon maksimal 20 digit" } + nomor_telepon: { + digits: "Nomor telepon harus berupa angka", + minlength: "Nomor telepon minimal 11 digit", + maxlength: "Nomor telepon maksimal 13 digit" + } }, errorElement: 'div', @@ -338,4 +342,4 @@ }); }); -@endpush \ No newline at end of file +@endpush