get('per_page', 15), 100); // Max 100 items per page $articles = Article::with(['feed', 'articlePublication']) ->orderBy('created_at', 'desc') ->paginate($perPage); $publishingApprovalsEnabled = Setting::isPublishingApprovalsEnabled(); return $this->sendResponse([ 'articles' => ArticleResource::collection($articles->items()), 'pagination' => [ 'current_page' => $articles->currentPage(), 'last_page' => $articles->lastPage(), 'per_page' => $articles->perPage(), 'total' => $articles->total(), 'from' => $articles->firstItem(), 'to' => $articles->lastItem(), ], 'settings' => [ 'publishing_approvals_enabled' => $publishingApprovalsEnabled, ], ]); } /** * Approve an article */ public function approve(Article $article): JsonResponse { try { $article->approve('manual'); return $this->sendResponse( new ArticleResource($article->fresh(['feed', 'articlePublication'])), 'Article approved and queued for publishing.' ); } catch (\Exception $e) { return $this->sendError('Failed to approve article: ' . $e->getMessage(), [], 500); } } /** * Reject an article */ public function reject(Article $article): JsonResponse { try { $article->reject('manual'); return $this->sendResponse( new ArticleResource($article->fresh(['feed', 'articlePublication'])), 'Article rejected.' ); } catch (\Exception $e) { return $this->sendError('Failed to reject article: ' . $e->getMessage(), [], 500); } } /** * Manually refresh articles from all active feeds */ public function refresh(): JsonResponse { try { // Dispatch the article discovery job ArticleDiscoveryJob::dispatch(); return $this->sendResponse( null, 'Article refresh started. New articles will appear shortly.' ); } catch (\Exception $e) { return $this->sendError('Failed to start article refresh: ' . $e->getMessage(), [], 500); } } }