get('data'); $rows = json_decode($data); Clause::truncate(); //Should we truncate related data? StatTree::truncate(); StatTreeLine::truncate(); StatTreeLineClause::truncate(); for($i = 0; $i < count($rows); $i++){ $row = $rows[$i]; $clause = new Clause(); $nextId = DB::select("select nextval('clause_id_seq')"); $clause->id = $nextId[0]->nextval; $clause->uid = Uuid::uuid4(); $clause->model = $row[0]; $clause->question = $row[1]; $clause->answer = $row[2]; $clause->label = $row[1] . ($row[2] && $row[2] != '-' ? ' ' . $row[2] : ''); $clause->clause_text = $row[3]; $clause->position_index = $i; $clause->save(); } return $this->pass(); } }