Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Dan b #114 api#124

Open
danut3101 wants to merge 2 commits intocode4romania:masterfrom
danut3101:DanB_#114_API
Open

Dan b #114 api#124
danut3101 wants to merge 2 commits intocode4romania:masterfrom
danut3101:DanB_#114_API

Conversation

@danut3101
Copy link

No description provided.

Comment on lines +29 to +30
// $exist = Volunteer::query()->where('ssn', '=', $value)->first();
// if (strlen($value) === 13 && !$exist) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete the lines that are no longer needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. I will remove

$rules = [
'organisation_id' => 'required',
'email' => 'required|string|email|max:255|unique:volunteers.volunteers',
// 'email' => 'required|string|email|max:255|unique:volunteers.volunteers',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove old line and a comment to explain what the login of "VolunteerEmail" rule.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment on lines +298 to +327
/** if is specified only a course */
$course_name_id = $request->has('course_name_id') ? $request->course_name_id : '';
if (trim($course_name_id)!='') {
$course_name = CourseName::find($course_name_id);
if ($course_name) {
/** Create a new course. */
$newCourse = [
'course_name' => [
'_id' => $course_name['_id'],
'name' => $course_name['name'],
'slug' => removeDiacritics($course_name['name'])],
'obtained' => Carbon::parse($request->get('obtained',''))->format('Y-m-d H:i:s')
];
/** Check if the accreditor already exists in DB. */
$courseAccreditor = CourseAccreditor::query()->where('name', '=', $request->get('accredited_by',''))->first();
if (!$courseAccreditor) {
$courseAccreditor = CourseAccreditor::create(['name' => $request->get('accredited_by',''), 'courses' => [$course_name['_id']]]);
} else {
if (is_array($courseAccreditor->courses) && !in_array($course_name['_id'], $courseAccreditor->courses)) {
$courseAccreditor->courses = array_merge( $courseAccreditor->courses, [$course_name['_id']]);
$courseAccreditor->save();
}
}
/** Save the accreditor and add the course to the volunteer. */
$newCourse['accredited'] = ['_id' => $courseAccreditor->_id,'name' => $courseAccreditor->name];
$data['courses'][] = $newCourse;
$volunteer->courses = $data['courses'];
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this?
So in case only one course was added to a volunteer, that course was ignored?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants