getTable())->truncate(); File::deleteDirectory(\storage_path('app/public/modelfiles/' . (new Game())->getTable())); $publish_at = now()->addMonth(); $unpublish_at = $publish_at->copy()->addDays(rand(10, 20)); for ($i = 0; $i < 5; $i++) { Game::factory(1)->make()->each( function (Game $game) use ($i, $publish_at, $unpublish_at) { $game->published = $i === 0 ? true : false; $game->publish_at = $publish_at->subMonths(); $game->unpublish_at = $unpublish_at->subMonths(); $game->picture = FileStorageHelper::storeFile( new Game(), new \SplFileInfo( \resource_path('../database/factories/assets/games/default-picture-585x415.png') ) ); $game->saveQuietly(); } ); } } }