From de657fcb3e8ceaebac904e417e34ea05521b9642 Mon Sep 17 00:00:00 2001 From: "Sebastian BURGIN-FIX (ext)" Date: Thu, 23 Jul 2026 01:06:25 +0200 Subject: [PATCH 1/2] wip --- database/seeders/Concerns/ReadsCsv.php | 24 ++++++++++++++++++++-- database/seeders/OpenSourceTableSeeder.php | 18 +++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/database/seeders/Concerns/ReadsCsv.php b/database/seeders/Concerns/ReadsCsv.php index af1ea11b..1af639bc 100644 --- a/database/seeders/Concerns/ReadsCsv.php +++ b/database/seeders/Concerns/ReadsCsv.php @@ -11,11 +11,26 @@ private function readCsv(string $filename): array { $handle = fopen(database_path("seeders/data/{$filename}"), 'r'); + if ($handle === false) { + throw new \RuntimeException("Unable to open seeders/data/{$filename}."); + } + $header = fgetcsv($handle, 0, ';'); + + if ($header === false || in_array(null, $header, true)) { + fclose($handle); + + throw new \RuntimeException("Missing CSV header in seeders/data/{$filename}."); + } + + /** @var list $header */ $rows = []; while (($row = fgetcsv($handle, 0, ';')) !== false) { - $rows[] = array_combine($header, $row); + $rows[] = array_combine( + $header, + array_map(fn (?string $value): string => (string) $value, $row), + ); } fclose($handle); @@ -23,8 +38,13 @@ private function readCsv(string $filename): array return $rows; } + /** + * @return array + */ private function decodeJson(string $value): array { - return $value === '' ? [] : json_decode($value, true); + $decoded = $value === '' ? [] : json_decode($value, true); + + return is_array($decoded) ? $decoded : []; } } diff --git a/database/seeders/OpenSourceTableSeeder.php b/database/seeders/OpenSourceTableSeeder.php index 618afb88..0cfec311 100644 --- a/database/seeders/OpenSourceTableSeeder.php +++ b/database/seeders/OpenSourceTableSeeder.php @@ -335,9 +335,18 @@ public function run(): void ); } - private function seed(string $sharedSlug, array $localizedData): void - { - $entries = collect($localizedData)->map(function ($data, $locale) use ($sharedSlug) { + /** + * @param array> $localizedData + */ + private function seed( + string $sharedSlug, + array $localizedData, + ?string $link = null, + int $downloads = 0, + string $version = '', + ?string $identifier = null, + ): void { + $entries = collect($localizedData)->map(function (array $data, string $locale) use ($sharedSlug, $link, $downloads, $version) { $slug = Str::slug($sharedSlug, '-', $locale); return OpenSource::updateOrCreate( @@ -352,6 +361,9 @@ private function seed(string $sharedSlug, array $localizedData): void 'image' => Arr::get($data, 'image', ''), 'tags' => Arr::get($data, 'tags', []), 'content' => Arr::get($data, 'content'), + 'link' => $link, + 'downloads' => $downloads, + 'version' => $version, ] ); }); From b765ddce4903fc18efe459530035672717519dff Mon Sep 17 00:00:00 2001 From: "Sebastian BURGIN-FIX (ext)" Date: Thu, 23 Jul 2026 01:08:07 +0200 Subject: [PATCH 2/2] wip --- config/cache.php | 2 +- config/database.php | 2 +- config/session.php | 2 +- database/factories/ActivityFactory.php | 22 ---------------------- database/factories/NetworkFactory.php | 2 +- database/factories/NewsFactory.php | 2 +- database/factories/OpenSourceFactory.php | 4 ++-- database/factories/ProductFactory.php | 4 ++-- database/factories/ServiceFactory.php | 4 ++-- database/factories/TechnologyFactory.php | 4 ++-- phpstan.neon.dist | 4 ++++ 11 files changed, 17 insertions(+), 35 deletions(-) delete mode 100644 database/factories/ActivityFactory.php diff --git a/config/cache.php b/config/cache.php index 24b0c2bf..8c222242 100644 --- a/config/cache.php +++ b/config/cache.php @@ -16,6 +16,6 @@ | */ - 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), + 'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel'), '_').'_cache_'), ]; diff --git a/config/database.php b/config/database.php index 3d8478a5..99c87a8d 100644 --- a/config/database.php +++ b/config/database.php @@ -105,7 +105,7 @@ 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), + 'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel'), '_').'_database_'), ], 'default' => [ diff --git a/config/session.php b/config/session.php index b224299f..1d1e28b3 100644 --- a/config/session.php +++ b/config/session.php @@ -16,7 +16,7 @@ 'cookie' => env( 'SESSION_COOKIE', - Str::slug(env('APP_NAME', 'laravel'), '_').'_session' + Str::slug((string) env('APP_NAME', 'laravel'), '_').'_session' ), ]; diff --git a/database/factories/ActivityFactory.php b/database/factories/ActivityFactory.php deleted file mode 100644 index d2144b97..00000000 --- a/database/factories/ActivityFactory.php +++ /dev/null @@ -1,22 +0,0 @@ - $this->faker->colorName(), - 'description' => $this->faker->text(), - 'subject_type' => User::class, - 'event' => $this->faker->colorName(), - 'subject_id' => User::factory(), - 'causer_type' => User::class, - 'causer_id' => User::factory(), - ]; - } -} diff --git a/database/factories/NetworkFactory.php b/database/factories/NetworkFactory.php index 80f9a1a7..e4b38de1 100644 --- a/database/factories/NetworkFactory.php +++ b/database/factories/NetworkFactory.php @@ -27,7 +27,7 @@ public function definition(): array 'key' => Str::slug($name), 'locale' => LocaleEnum::DE->value, 'name' => $name, - 'category' => $this->faker->randomElement(NetworkCategoryEnum::cases())->value, + 'category' => collect(NetworkCategoryEnum::cases())->random()->value, 'status' => NetworkStatusEnum::ACTIVE->value, 'cover_url' => null, 'tier_label' => null, diff --git a/database/factories/NewsFactory.php b/database/factories/NewsFactory.php index 72cdd281..1d077889 100644 --- a/database/factories/NewsFactory.php +++ b/database/factories/NewsFactory.php @@ -21,7 +21,7 @@ public function definition(): array $title = fake()->unique()->sentence(); return [ - 'locale' => fake()->randomElement(LocaleEnum::cases())->value, + 'locale' => collect(LocaleEnum::cases())->random()->value, 'title' => $title, 'slug' => str($title)->slug(), 'teaser' => fake()->sentence(), diff --git a/database/factories/OpenSourceFactory.php b/database/factories/OpenSourceFactory.php index 29494e63..b63ee498 100644 --- a/database/factories/OpenSourceFactory.php +++ b/database/factories/OpenSourceFactory.php @@ -18,11 +18,11 @@ class OpenSourceFactory extends Factory */ public function definition(): array { - $title = fake()->unique()->words(3, true); + $title = (string) fake()->unique()->words(3, true); return [ 'published' => true, - 'locale' => fake()->randomElement(LocaleEnum::cases())->value, + 'locale' => collect(LocaleEnum::cases())->random()->value, 'title' => $title, 'slug' => str($title)->slug(), 'teaser' => fake()->sentence(), diff --git a/database/factories/ProductFactory.php b/database/factories/ProductFactory.php index dc11b9c9..2e20bbc8 100644 --- a/database/factories/ProductFactory.php +++ b/database/factories/ProductFactory.php @@ -18,11 +18,11 @@ class ProductFactory extends Factory */ public function definition(): array { - $name = fake()->unique()->words(3, true); + $name = (string) fake()->unique()->words(3, true); return [ 'published' => true, - 'locale' => fake()->randomElement(LocaleEnum::cases())->value, + 'locale' => collect(LocaleEnum::cases())->random()->value, 'order' => fake()->numberBetween(1, 100), 'name' => $name, 'teaser' => fake()->sentence(), diff --git a/database/factories/ServiceFactory.php b/database/factories/ServiceFactory.php index fc26e373..b12f152b 100644 --- a/database/factories/ServiceFactory.php +++ b/database/factories/ServiceFactory.php @@ -18,11 +18,11 @@ class ServiceFactory extends Factory */ public function definition(): array { - $name = fake()->unique()->words(3, true); + $name = (string) fake()->unique()->words(3, true); return [ 'published' => true, - 'locale' => fake()->randomElement(LocaleEnum::cases())->value, + 'locale' => collect(LocaleEnum::cases())->random()->value, 'group' => fake()->word(), 'order' => fake()->numberBetween(1, 100), 'name' => $name, diff --git a/database/factories/TechnologyFactory.php b/database/factories/TechnologyFactory.php index 9b9bf727..156fc7bc 100644 --- a/database/factories/TechnologyFactory.php +++ b/database/factories/TechnologyFactory.php @@ -18,11 +18,11 @@ class TechnologyFactory extends Factory */ public function definition(): array { - $title = fake()->unique()->words(3, true); + $title = (string) fake()->unique()->words(3, true); return [ 'published' => true, - 'locale' => fake()->randomElement(LocaleEnum::cases())->value, + 'locale' => collect(LocaleEnum::cases())->random()->value, 'group' => fake()->word(), 'order' => fake()->numberBetween(1, 100), 'title' => $title, diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 40da7268..db410862 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -12,3 +12,7 @@ parameters: ignoreErrors: excludePaths: + # Vendor-published migration (spatie/laravel-permission) — not our code. + - database/migrations/2024_06_06_100452_create_permission_tables.php + # Nova is not installed; this config references Laravel\Nova classes. + - config/nova.php