Skip to content

Commit

Permalink
Update pages factory and seeder (#29)
Browse files Browse the repository at this point in the history
* Refactor image field and update PHP version requirements.

Renamed the `image` field to `feature_image` in seeders and factories for improved clarity. Updated `composer.json` to drop support for PHP 8.1, ensuring compatibility with newer versions.

* Update image field and add slug to fillable array

Renamed `image` to `feature_image` for better clarity and added `slug` to the fillable attributes. Adjusted the `getDynamicSEOData` method to reflect these changes. This ensures alignment between database fields and application logic.
  • Loading branch information
thejmitchener authored Feb 12, 2025
1 parent 14704c6 commit 1ba1c67
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": "^8.1||^8.2||^8.3||^8.4",
"php": "^8.2||^8.3||^8.4",
"spatie/laravel-package-tools": "^1.16",
"spatie/laravel-google-fonts": ">=1.4.1",
"ralphjsmit/laravel-seo": ">=1.6.7",
Expand Down
2 changes: 1 addition & 1 deletion database/factories/PageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function definition(): array
'slug' => $this->faker->slug(),
'title' => $this->faker->word(),
'description' => $this->faker->text(),
'image' => $this->faker->word(),
'feature_image' => $this->faker->word(),
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
'registerMediaConversionsUsingModelInstance' => $this->faker->boolean(),
Expand Down
2 changes: 1 addition & 1 deletion database/seeders/PageTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function run(): void
'slug' => 'home',
'title' => 'home page',
'description' => 'This is the home page description.',
'image' => 'images/logo.png',
'feature_image' => 'images/logo.png',
],

];
Expand Down
5 changes: 3 additions & 2 deletions src/Models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ class Page extends Model

protected $fillable = [
'title',
'slug',
'description',
'image',
'feature_image',
];

public function getDynamicSEOData(): SEOData
{
return new SEOData(
title: ucwords($this->title),
description: ucfirst($this->description),
image: $this->image,
image: $this->feature_image,
);
}
}

0 comments on commit 1ba1c67

Please sign in to comment.