Commit graph

11 commits

Author SHA1 Message Date
e4791de81a
implement ListFeaturedPosts use case 2026-05-06 22:30:49 +03:00
a8f59afc30
implement ClearFeaturedPost use case 2026-05-06 22:30:17 +03:00
ee95bcafc9
implement SetFeaturedPost use case 2026-05-06 22:29:34 +03:00
f73e5a1af5
extend Post entity with feature slot
Adds nullable feature_slot column (unique) plus repo
findByFeatureSlot/findFeatured/update methods so admins can
pin a post into one of two slots.
2026-05-06 22:28:45 +03:00
e9ac16377f
implement DeletePost use case 2026-05-06 21:58:25 +03:00
yisroel
7fda18dde3
implement GetPost use case
validates id > 0, delegates to PostRepository->find. 58 tests
pass.
2026-05-06 15:25:56 +03:00
yisroel
32cbf4229c
implement ListUserPosts use case
validates userId > 0, delegates to PostRepository->findByUserId.
54 tests pass.
2026-05-06 15:25:07 +03:00
yisroel
7ec46aa8f9
implement ListRecentPosts use case
validates limit > 0 (zero or negative -> BadRequest), then
delegates to PostRepository->findRecent. 49 tests pass.
2026-05-06 15:24:15 +03:00
yisroel
4a4e046de4
implement CreatePost use case
trims title and body, rejects empty (post-trim) values with
BadRequest. supplies createdAt from injected Clock. persists
through PostRepository->create and returns the resulting Post.
44 tests pass.
2026-05-06 15:23:21 +03:00
yisroel
e3dddc60aa
add Post persistence: model, migration, eloquent + fake repo
PostModel maps posts table (id, user_id fk, title, body text,
created_at indexed). EloquentPostRepository: create, find,
findByUserId (desc by created_at), findRecent (limit, desc),
delete - chain via ::query() to keep larastan happy.
FakePostRepository sorts on read (defensive copy each return).
cascade-on-delete on user_id so removing a user nukes their
posts.

phpstan.neon suppresses staticMethod.dynamicCall under
app/*/Eloquent*Repository.php - phpstan-strict-rules flags
Eloquent's fluent builder idiom (Model::query()->orderBy())
because the static methods become instance calls mid-chain.
suppression scoped to repo files only so the rule still
applies elsewhere.
2026-05-06 15:22:22 +03:00
yisroel
73a3acd39f
add Post entity, dto, repository interface
Post: id, userId (fk -> User), title, body, createdAt as
DateTimeImmutable. CreatePostDto readonly with explicit
createdAt (use case supplies it via Clock; entity remains pure).
PostRepository: create, find, findByUserId, findRecent (limit),
delete.
2026-05-06 15:19:00 +03:00