Skip to content

Refactor BlogDatabaseSeeder and Taskfile for consistency and efficiency - #5

Merged
roble merged 4 commits into
mainfrom
dev-v2
Jun 11, 2026
Merged

Refactor BlogDatabaseSeeder and Taskfile for consistency and efficiency#5
roble merged 4 commits into
mainfrom
dev-v2

Conversation

@roble

@roble roble commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

This pull request improves the seeding process for the Blog module to make it more robust and idempotent, and updates the way images are referenced and stored. It also updates the Taskfile.yml to ensure that database seeding and TypeScript type generation commands use the correct application context.

Seeder Improvements:

  • Changed category and post creation in BlogDatabaseSeeder.php to use firstOrCreate, preventing duplicate entries if the seeder is run multiple times. [1] [2]
  • Updated image file path handling by introducing an $image helper function, ensuring images are referenced from the correct location. [1] [2] [3] [4] [5] [6] [7]
  • Modified media upload to specify the 'public' disk when adding cover images, ensuring images are stored and served correctly.

Taskfile Updates:

  • Updated db:seed and types:generate commands in Taskfile.yml to run under the correct application context using the {{.APP}} variable.
  • Fixed quoting in the test:php command to ensure the test filter is parsed correctly.

Copilot AI review requested due to automatic review settings June 11, 2026 19:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Blog module’s database seeding and developer Taskfile commands to be more consistent and safer to re-run, while updating how cover images are located and stored.

Changes:

  • Made Blog category and post seeding idempotent via firstOrCreate.
  • Switched seeded cover images to be sourced from resources/assets/images and stored on the public disk.
  • Updated Taskfile commands for seeding and type generation to run under an application context prefix, and adjusted PHPUnit filter quoting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
Taskfile.yml Updates task commands (tests, seeding, TS type generation) for consistent execution context.
database/seeders/BlogDatabaseSeeder.php Makes seeding re-runnable without duplicates and updates cover image path/disk handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Taskfile.yml
db:seed:
desc: Seed the Blog module database
cmd: php artisan modules:seed --module=blog
cmd: '{{.APP}} php artisan modules:seed --module=blog'
Comment thread Taskfile.yml
types:generate:
desc: Generate TypeScript types from PHP DTOs and enums
cmd: php artisan module:generate-types blog
cmd: '{{.APP}} php artisan module:generate-types blog'
Comment on lines 21 to +22
$content = fn (string $file): string => file_get_contents(__DIR__.'/content/'.$file);
$image = fn (string $file): string => __DIR__.'/../../resources/assets/images/'.$file;
@roble
roble merged commit 908e9ac into main Jun 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants