in app/Http/Controllers/Contacts/RelationshipsController.php [175:218]
private function validateAndGetDatas(Request $request)
{
$validator = Validator::make($request->all(), [
'first_name' => 'required|max:255',
'last_name' => 'max:255',
'gender_id' => 'nullable|integer',
'birthdayDate' => 'date_format:Y-m-d',
]);
if ($validator->fails()) {
return $validator;
}
// this is really ugly. it should be changed
if ($request->input('birthdate') == 'exact') {
$birthdate = $request->input('birthdayDate');
$birthdate = DateHelper::parseDate($birthdate);
$day = $birthdate->day;
$month = $birthdate->month;
$year = $birthdate->year;
} else {
$day = $request->input('day');
$month = $request->input('month');
$year = $request->input('year');
}
return [
'account_id' => auth()->user()->account_id,
'author_id' => auth()->user()->id,
'first_name' => $request->input('first_name'),
'last_name' => $request->input('last_name'),
'gender_id' => $request->input('gender_id'),
'is_birthdate_known' => ! empty($request->input('birthdate')) && $request->input('birthdate') !== 'unknown',
'birthdate_day' => $day,
'birthdate_month' => $month,
'birthdate_year' => $year,
'birthdate_is_age_based' => $request->input('birthdate') === 'approximate',
'birthdate_age' => $request->input('age'),
'birthdate_add_reminder' => ! empty($request->input('addReminder')),
'is_partial' => ! $request->input('realContact'),
'is_deceased' => false,
'is_deceased_date_known' => false,
];
}