<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;


class Pendaftar extends Model
{
    
    public $incrementing = false;
    protected $table = 'ms_pendaftar';
    public $timestamps = false;

    public static $rules = [
      'namapeserta' => 'required',
      'tempatlahir' => 'required|regex:/^[a-zA-z]+([\s][a-zA-Z]+)*$/',
      'kewarganegaraan' => 'required',
      'jenjang' => 'required',
      'nik' => 'required_if:kewarganegaraan,ID|digits:16|nullable',
      'tgllahir' => 'required|date|before:-13 years',
      'sex' => 'required',
      'kodeagama' => 'required',
      'id_prop_wil' => 'required_if:kewarganegaraan,ID',
      'id_kab_wil' => 'required_if:kewarganegaraan,ID',
      'id_kec_wil' => 'required_if:kewarganegaraan,ID',
      'alamat' => 'required',
      'desa' => 'required',
      'dusun' => 'required',
      'rt' => 'required',
      'rw' => 'required',
      'kodepos' => 'required',
      'email' => 'required',
      'hp' => 'min:10|required',
      'namaayah' => 'required|different:namaibu',
      'namaibu' => 'required|different:namaayah',
    //   'nik_ayah' => 'digits:16|required|different_if:nik_ibu,nik',
    //   'nik_ibu' => 'digits:16|required|different:nik_ayah,nik',
    //   'alamatsmu' => 'required', 
    //   'kodepossmu' => 'required', 
    //   'smukelas' => 'required', 
      'smutahun' => 'required',
    //   'kodejurusan' => 'required', 
      'sttbtahun' => 'required', 
      'iskebutuhankhusus' => 'required',
    //   'nisn' => 'digits:10|nullable',  
    //   'akreditasi_sekolah' => 'required', 
    //   'kodesmu' => 'required_if:kewarganegaraan,ID',
      'jenis_kebutuhankhusus' => 'required_if:iskebutuhankhusus,Y'
    ];

    public static $errormessage = [
      'required' => 'Form Input Ini Tidak Boleh Kosong / Harus Diisi',
      'digits' => 'NIK harus 16 digit',
      'regex' => 'Tidak Boleh Berisikan Angka',
      'before' => 'Minimal Usia 13 Tahun',
      'min' => 'Minimal 10 angka',
      'different' => 'Nama Ayah dan Ibu Harus Berbeda atau NIK Ayah dan NIK Ibu Harus Berbeda',
    ];
}
