/** * Execute the console command. * * @return void */ public function handle() { $filename = $this->argument('fileName'); $surveyJSON = file_get_contents($filename); $parser = new \App\Twilio\SurveyParser($surveyJSON); $survey = new \App\Survey(); $survey->title = $parser->title(); $survey->save(); $parser->questions()->each(function ($question) use($survey) { $questionToSave = new \App\Question($question); $questionToSave->survey()->associate($survey); $questionToSave->save(); }); }
/** * Run the database seeds. * * @return void */ public function run() { $survey = App\Survey::create(['name' => 'Survey 1']); for ($j = 1; $j <= 10; $j++) { $question = $survey->questions()->save(factory(App\SurveyQuestion::class)->make()); for ($k = 1; $k <= 4; $k++) { $question->answers()->save(factory(App\SurveyAnswer::class)->make()); } } }
<form name="form-ticket-begin" id="form-ticket-begin" class="form form-horizontal ajax-form-ticket-begin" role="form" action="/tickets/{{ $ticket->id }}/begin" > <input type="hidden" name="_method" id="_method" value="POST"> <input type="hidden" name="ticket_id" id="ticket_id" value="{{ $ticket->id }}" > <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">Select Survey </h4> </div> <div class="modal-body"> <div class="form-group"> <label class="col-sm-3 control-label" for="name">Survey:</label> <div class="col-sm-8"> <?php $Surveys = App\Survey::where('active', 1)->orderBy('name')->get(); ?> <select name="survey_id" id="survey_id" required class="form-control"> <option value="">-select survey-</option> @foreach( $Surveys as $Survey ) <option value="{{$Survey->id}}">{{$Survey->name}}</option> @endforeach </select> </div> </div> <span class="showError alert-danger"></span> </div> <div class="modal-footer"> <button type="button" class="btn btn-link btn-sm btn-circle" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary btn-sm " data-loading-text="Loading...">Start</button>