api person create & update & add family
This commit is contained in:
65
Modules/Linksehat/Http/Requests/PersonRequest.php
Normal file
65
Modules/Linksehat/Http/Requests/PersonRequest.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PersonRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'string',
|
||||
'birth_place' => 'string',
|
||||
'birth_date' => 'date',
|
||||
'gender' => 'string',
|
||||
'phone' => 'numeric',
|
||||
'email' => 'email',
|
||||
'blood_type' => 'string',
|
||||
'weight' => 'string',
|
||||
'height' => 'string',
|
||||
'relation_with_owner' => 'string', // relasi family table
|
||||
'marital_status' => 'string',
|
||||
'religion' => 'string',
|
||||
'last_education' => 'string',
|
||||
'current_employment' => 'string',
|
||||
'nik' => 'string|min:16|max:16',
|
||||
'updated_by' => 'integer',
|
||||
'user_avatar' => 'file', // relasi file table
|
||||
'verification_file' => 'file', // relasi file table
|
||||
'is_ktp' => 'boolean',
|
||||
'citizenship' => 'string',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$citizenship = $this->is_ktp ? 'wni' : 'wna';
|
||||
|
||||
$this->merge([
|
||||
'birth_date' => empty($this->birth_date) ? $this->birth_date . " 00:00:00" : $this->birth_date,
|
||||
'updated_by' => auth()->user()->id,
|
||||
'citizenship' => $citizenship ? $citizenship : NULL
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user