/** * Creates a New Question. * * @param $name * @param $question_type * @param $group * @param array $options * @param array $choices * @param null $team_id * @return mixed */ public function createQuestion($name, $question_type, $group, $options = [], $choices = [], $team_id = null) { $group = Group::resolveSelf($group); $question_type = QuestionType::resolveSelf($question_type); $question = Question::create(['name' => $name, 'slug' => str_slug($name . '_' . str_random(6), '_'), 'question_type_id' => $question_type->id, 'group_id' => $group->id, 'team_id' => $team_id]); $question = $question->syncOptions($options); $question = $question->addMultipleChoiceOption($choices); return $question; }