public function run() { // Models $data = ['Abnmt\\Theater\\Models\\Person' => $this->MultiSort(require_once 'data/people.php', ['family_name' => [SORT_ASC, SORT_STRING]]), 'Abnmt\\Theater\\Models\\Performance' => $this->MultiSort(require_once 'data/performances.php', ['premiere_date' => [SORT_ASC, SORT_NUMERIC]])]; $path = "./storage/app/images"; $fileData = $this->fillArrayWithFileNodes(new \DirectoryIterator($path), ["jpg", "png"]); // print_r($fileData); foreach ($data as $modelName => $models) { foreach ($models as $model) { $model = $this->createModel($modelName, $model); $this->assignImages($model, $fileData); } } // Participations $participations = (require_once 'data/participations.php'); foreach ($participations as $participation) { $performance_id = $this->findPerformance($participation['title'])->id; $this->createParticipation($participation, $performance_id); } // Events $events = (require_once 'data/events.php'); foreach ($events as $event) { $relation = $this->findModel($event['title']); if (!is_null($relation)) { $this->createEvent($event, $relation); } } // Sort files $files = File::get(); $files->each(function ($file) { preg_match("~^(\\d+)~", $file->file_name, $matches); if (count($matches) > 0) { $file->sort_order = intval($matches[0], 10); // print_r($file); $file->save(); } }); // print_r($files); }