diff --git a/database/migrations/2025_06_26_000000_create_articles_table.php b/database/migrations/2025_06_26_000000_create_articles_table.php index fb4ad1c..3564fbe 100644 --- a/database/migrations/2025_06_26_000000_create_articles_table.php +++ b/database/migrations/2025_06_26_000000_create_articles_table.php @@ -9,9 +9,7 @@ public function up(): void { Capsule::schema()->create('articles', function (Blueprint $table) { $table->id(); $table->string('url')->unique(); - $table->string('title')->nullable(); - $table->json('data')->nullable(); - $table->timestamp('seen_at')->useCurrent(); + $table->timestamp('created_at')->useCurrent(); }); } diff --git a/database/migrations/2025_06_26_000001_create_articles_posted_table.php b/database/migrations/2025_06_26_000001_create_articles_posted_table.php index 26e1a09..1fd9200 100644 --- a/database/migrations/2025_06_26_000001_create_articles_posted_table.php +++ b/database/migrations/2025_06_26_000001_create_articles_posted_table.php @@ -11,7 +11,6 @@ public function up(): void { $table->foreignId('article_id')->constrained('articles')->onDelete('cascade'); $table->string('community'); $table->timestamp('posted_at')->useCurrent(); - $table->json('response')->nullable(); }); } diff --git a/src/Domain/Articles/Article.php b/src/Domain/Articles/Article.php new file mode 100644 index 0000000..8f2b3e3 --- /dev/null +++ b/src/Domain/Articles/Article.php @@ -0,0 +1,39 @@ + 'datetime', + 'data' => 'array', + ]; + + public function posts(): HasMany + { + return $this->hasMany(ArticlePosted::class); + } + + public function publish(string $community = 'default'): void + { + ArticlePosted::create([ + 'article_id' => $this->id, + 'community' => $community, + 'posted_at' => now(), + ]); + } +} diff --git a/src/Domain/Articles/ArticlePosted.php b/src/Domain/Articles/ArticlePosted.php new file mode 100644 index 0000000..05adbcd --- /dev/null +++ b/src/Domain/Articles/ArticlePosted.php @@ -0,0 +1,30 @@ + 'datetime', + 'response' => 'array', + ]; + + public function article(): BelongsTo + { + return $this->belongsTo(Article::class); + } +}