$data['email'], 'password' => $data['password'], ]); $teacher = Teacher::create([ 'name' => $data['name'], 'last_name' => $data['last_name'], 'middle_name' => $data['middle_name'], 'birthday' => $data['birthday'], ]); $teacher->user()->save($user); return $teacher; } public function update(Teacher $teacher, array $data): Teacher { $teacher->user()->update([ 'email' => $data['email'], 'password' => $data['password'], ]); $teacher->update([ 'name' => $data['name'], 'last_name' => $data['last_name'], 'middle_name' => $data['middle_name'], 'birthday' => $data['birthday'], ]); return $teacher; } public function delete(Teacher $teacher): void { $teacher->user()->delete(); $teacher->delete(); } }