public function run() { // Layouts $layouts = (require_once 'data/backgrounds.php'); $path = "./storage/app/media/backgrounds"; $fileData = $this->fillArrayWithFileNodes(new \DirectoryIterator($path), ["jpg"]); foreach ($layouts as $layout) { $model = Background::create($layout); $this->assignImages($model, $fileData); } }