Feed::factory(), 'platform_channel_id' => PlatformChannel::factory(), 'article_id' => Article::factory(), 'approval_status' => ApprovalStatusEnum::PENDING, 'validated_at' => null, ]; } public function configure(): static { return $this->afterMaking(function (RouteArticle $routeArticle) { // Ensure a route exists for this feed+channel combination Route::firstOrCreate( [ 'feed_id' => $routeArticle->feed_id, 'platform_channel_id' => $routeArticle->platform_channel_id, ], [ 'is_active' => true, 'priority' => 50, ] ); // Ensure the article belongs to the same feed if ($routeArticle->article_id) { $article = Article::find($routeArticle->article_id); if ($article && $article->feed_id !== $routeArticle->feed_id) { $article->update(['feed_id' => $routeArticle->feed_id]); } } }); } public function forRoute(Route $route): static { return $this->state(fn (array $attributes) => [ 'feed_id' => $route->feed_id, 'platform_channel_id' => $route->platform_channel_id, ]); } public function pending(): static { return $this->state(fn (array $attributes) => [ 'approval_status' => ApprovalStatusEnum::PENDING, ]); } public function approved(): static { return $this->state(fn (array $attributes) => [ 'approval_status' => ApprovalStatusEnum::APPROVED, 'validated_at' => now(), ]); } public function rejected(): static { return $this->state(fn (array $attributes) => [ 'approval_status' => ApprovalStatusEnum::REJECTED, 'validated_at' => now(), ]); } }