diff --git a/app/Models/Site.php b/app/Models/Site.php new file mode 100644 index 0000000..cd39e75 --- /dev/null +++ b/app/Models/Site.php @@ -0,0 +1,17 @@ + fake()->company(), + 'url' => fake()->url(), + 'description' => fake()->optional()->sentence(), + ]; + } +} diff --git a/database/migrations/2026_07_18_114506_create_sites_table.php b/database/migrations/2026_07_18_114506_create_sites_table.php new file mode 100644 index 0000000..8368372 --- /dev/null +++ b/database/migrations/2026_07_18_114506_create_sites_table.php @@ -0,0 +1,24 @@ +id(); + $table->string('name'); + $table->string('url'); + $table->text('description')->nullable(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('sites'); + } +}; diff --git a/tests/Feature/SiteModelTest.php b/tests/Feature/SiteModelTest.php new file mode 100644 index 0000000..889b0a9 --- /dev/null +++ b/tests/Feature/SiteModelTest.php @@ -0,0 +1,25 @@ + 'My Blog', + 'url' => 'https://example.com', + 'description' => 'A blog about things', + ]); + + expect($site->fresh()) + ->name->toBe('My Blog') + ->url->toBe('https://example.com') + ->description->toBe('A blog about things'); +}); + +test('a site can be created without a description', function () { + $site = Site::create([ + 'name' => 'My Blog', + 'url' => 'https://example.com', + ]); + + expect($site->fresh()->description)->toBeNull(); +});