public function createTerm(array $attributes, $batchId) { $batch = $this->findBatch($batchId); $attributes['start_date'] = toUTC($attributes['start_date']); $attributes['end_date'] = toUTC($attributes['end_date']); $attributes['batch_id'] = $batch->id; return Term::create($attributes); }
public function postBatchTermEdit(UpdateTermRequest $request, $batchId, $termId) { $this->authorize('add_edit_batch'); $attributes = $request->all(); $attributes['start_date'] = toUTC($attributes['start_date']); $attributes['end_date'] = toUTC($attributes['end_date']); $term = $this->classRepository->updateTerm($attributes, $termId, $batchId); return $this->printPartial(view('classes::partials.term', ['batch' => $this->classRepository->findBatch($batchId), 'term' => $term]), trans('classes::term.term_updated')); }
public function createStudent(array $attributes) { $student = null; $attributes['admitted_on'] = toUTC($attributes['admitted_on']); if (!isset($attributes['image_id'])) { $attributes['image_id'] = null; } $studentAttributes = $this->parseFillable($attributes, Student::class); DB::transaction(function () use($attributes, $studentAttributes, &$student) { $user = $this->userRepository->create($attributes); $student = Student::create(array_merge($studentAttributes, ['user_id' => $user->id])); $this->userRepository->addRoleToUser($user, $this->userRepository->getRoleByName('student')); }); return $student; }
public function createEmployee(array $attributes) { $employee = null; $attributes['joined_on'] = toUTC($attributes['joined_on']); if (!isset($attributes['image_id'])) { $attributes['image_id'] = null; } $attributes['employee_category_id'] = $this->findEmployeePosition($attributes['employee_position_id'])->employeeCategory->id; $employeeAttributes = $this->parseFillable($attributes, Employee::class); DB::transaction(function () use($attributes, $employeeAttributes, &$employee) { $user = $this->userRepository->create($attributes); $employee = Employee::create(array_merge($employeeAttributes, ['user_id' => $user->id])); $this->userRepository->addRoleToUser($user, $this->userRepository->getRoleByName('employee')); }); return $employee; }