1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1, ]; /** * Constructor for the class */ public function __construct() { $this->middleware('auth'); $this->middleware('role:Admin'); } public function ImportMoonSurveyData(Request $request) { //Declare variables $added = 0; $updated = 0; $moon = null; $newMoon = false; $num = 0; $planet = null; $moonNumber = null; foreach(explode("\n", $request->input('data')) as $row) { $cols = explode("\t", $row); dd($cols); } return redirect('/admin/dashboard')->with('success', 'Import done: ' . $added . ' moons added ' . $updated . ' moons updated.'); } private function romanNumberToInteger($roman) { $result = 0; foreach($this->romans as $key => $value) { while(strpos($roman, $key) === 0) { $result += $value; $roman = substr($roman, strlen($key)); } } return $result; } private function integerToRomanNumber($number) { $returnValue = ''; while($number > 0) { foreach($this->romans as $roman => $int) { if($number >= $int) { $number -= $int; $returnValue .= $roman; break; } } } return $returnValue; } private function arrayToCsv(array $rows) { //Declare needed variable as text null $result = ''; //Open the temp file $fp = fopen('php://temp', 'w'); //Process the file foreach($rows as $fields) { fputcsv($fp, $fields, ';', '"'); } //Go back to the beginning of the file rewind($fp); //Continue through the buffer until the end while(($buffer = fgets($fp, 4096)) !== false) { $result .= $buffer; } //Close the temp file fclose($fp); //Return the result return $result; } }