Fix Missing Data

This commit is contained in:
R
2022-11-15 16:06:09 +07:00
parent 81f25f31de
commit cf32be8dd5
2 changed files with 5 additions and 16 deletions

View File

@@ -94,6 +94,7 @@ class PersonController extends Controller
*/ */
public function update(PersonRequest $request, Person $family) public function update(PersonRequest $request, Person $family)
{ {
dd($request->toArray());
if (Gate::forUser(auth()->user())->allows('update-person', $family)) { if (Gate::forUser(auth()->user())->allows('update-person', $family)) {
$personData = $request->only([ $personData = $request->only([
'owner_user_id', 'owner_user_id',

View File

@@ -24,7 +24,9 @@ class PersonRequest extends FormRequest
public function rules() public function rules()
{ {
return [ return [
'name_prefix' => 'string',
'name' => 'string', 'name' => 'string',
'name_suffix' => 'string',
'birth_place' => 'string', 'birth_place' => 'string',
'birth_date' => 'date', 'birth_date' => 'date',
'gender' => 'string', 'gender' => 'string',
@@ -44,22 +46,8 @@ class PersonRequest extends FormRequest
'verification_file' => 'file', // relasi file table 'verification_file' => 'file', // relasi file table
'is_ktp' => 'boolean', 'is_ktp' => 'boolean',
'citizenship' => 'string', 'citizenship' => 'string',
'main_address_id' => 'numeric',
'domicile_address_id' => 'numeric',
]; ];
} }
/**
* 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
]);
}
} }