Skip to content

Instantly share code, notes, and snippets.

@erowsika
Created May 22, 2018 14:43
Show Gist options
  • Save erowsika/e27ab9fe4a1d25a32c352ead3fa24bbc to your computer and use it in GitHub Desktop.
Save erowsika/e27ab9fe4a1d25a32c352ead3fa24bbc to your computer and use it in GitHub Desktop.
<?php
namespace AMS\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreRegistrasiSuratMagang extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'no-surat-masuk' => 'required',
'asal-surat' => 'required',
'perihal-surat-masuk' => 'required|min:2',
'no-surat-keluar' => 'required',
'perihal-surat-keluar' => 'required',
'tujuan-surat-keluar-kantor' => 'required',
'tujuan-surat-keluar-kepala-kantor' => 'required',
'jenis-pengabdian' => 'required',
'penandatangan' => 'required',
'jenjang-peserta' => 'required'
];
if (request()->has([
'r_nama',
'r_jenis_kelamin',
'r_stambuk',
'r_jurusan'
])){
foreach($this->request->get('r_nama') as $key => $val)
{
$rules['r_nama.'.$key] = 'required';
}
foreach($this->request->get('r_jenis_kelamin') as $key => $val)
{
$rules['r_jenis_kelamin.'.$key] = 'required';
}
foreach($this->request->get('r_stambuk') as $key => $val)
{
$rules['r_stambuk.'.$key] = 'required';
}
foreach($this->request->get('r_jurusan') as $key => $val)
{
$rules['r_jurusan.'.$key] = 'required';
}
}
return $rules;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment