Compare commits
474 Commits
1e57fc1046
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9409e961d | ||
|
|
1f9a43806a | ||
|
|
e3bb1642db | ||
|
|
83cf863548 | ||
|
|
6cc463fc70 | ||
|
|
c0c082975e | ||
|
|
64b3bf3ed4 | ||
|
|
922da46331 | ||
|
|
ddbfa38db1 | ||
|
|
3ba4d11d92 | ||
|
|
d2808ffa4f | ||
|
|
8cc0918881 | ||
|
|
fb45d1f6ab | ||
|
|
1d2242fb4d | ||
|
|
36bed12ff9 | ||
|
|
df00deb0df | ||
|
|
0291d537fb | ||
|
|
fa114ac0dc | ||
|
|
61d1bbc707 | ||
|
|
0a08f2704f | ||
|
|
b14435df8b | ||
|
|
18b4f36fcf | ||
|
|
c6aaf859f5 | ||
|
|
ba56cb4e61 | ||
|
|
5f75c7ca6a | ||
|
|
4e0d156065 | ||
|
|
fa630e335d | ||
|
|
6eafec2128 | ||
|
|
04c399aeb6 | ||
|
|
7262617897 | ||
|
|
0d7a861875 | ||
|
|
c43327af74 | ||
|
|
e911c2bd16 | ||
|
|
beaff1c4e9 | ||
|
|
eee58f2d0c | ||
|
|
1cb150b819 | ||
|
|
17025df47b | ||
|
|
7025418d9e | ||
|
|
5c78ac00dd | ||
|
|
66c7131d79 | ||
|
|
239f55f9c5 | ||
|
|
fc5dfb272c | ||
|
|
56a39d0535 | ||
|
|
0eacb5646c | ||
|
|
b6d7118772 | ||
|
|
8d7a1d80c2 | ||
|
|
35f68e68d8 | ||
|
|
4be01d77ee | ||
|
|
197e9c988b | ||
|
|
ba8890839b | ||
|
|
6c12d73d68 | ||
|
|
c59f9ae994 | ||
|
|
f2d7ed6646 | ||
|
|
17d979e3c3 | ||
|
|
fc1149118c | ||
|
|
8cee7ef004 | ||
|
|
1b131851fb | ||
|
|
7980980bed | ||
|
|
c6a7f31ea0 | ||
|
|
c4ccfa1353 | ||
|
|
b38b63e04a | ||
|
|
25e3d5ef7d | ||
|
|
1119adcfe9 | ||
|
|
c91480a870 | ||
|
|
7f1e6c06fb | ||
|
|
a820ef2e8b | ||
|
|
a0ef90e13a | ||
|
|
2f4ebfefd4 | ||
|
|
f161366119 | ||
|
|
6bc73637b1 | ||
|
|
7ee56cefe4 | ||
|
|
38f89be99e | ||
|
|
6e19c3d7b6 | ||
|
|
b3bf45482a | ||
|
|
d4162dd105 | ||
|
|
2270462ecb | ||
|
|
af4685f703 | ||
|
|
43dc71815f | ||
|
|
f5f6555b09 | ||
|
|
0e2638c0f8 | ||
|
|
798fa5e9f5 | ||
|
|
802a3fe132 | ||
|
|
303a33dd2e | ||
|
|
074cd0f431 | ||
|
|
bca2e90b54 | ||
|
|
bd3a96a58a | ||
|
|
876731b051 | ||
|
|
93efb78091 | ||
|
|
68f2eb871b | ||
|
|
1ca2cdf2a8 | ||
|
|
0ad8b9d8a9 | ||
|
|
779dd520ad | ||
|
|
061ad6cf24 | ||
|
|
f707feb45e | ||
|
|
93ea12fa04 | ||
|
|
f56b2b81ed | ||
|
|
4ce64f0a35 | ||
|
|
dd2997808b | ||
|
|
19f5e60870 | ||
|
|
b4a2e39903 | ||
|
|
d8f67522ee | ||
|
|
e2948c0388 | ||
|
|
594c3b1772 | ||
|
|
59cedf216a | ||
|
|
4e2ab9e589 | ||
|
|
6c857b5765 | ||
|
|
4e65fe1d5f | ||
|
|
86b7eddd47 | ||
|
|
975e257c44 | ||
|
|
3115a6461d | ||
|
|
d93e6475a4 | ||
|
|
a9c7242e15 | ||
|
|
8887d8e16c | ||
|
|
684f54f58f | ||
|
|
b17dd655db | ||
|
|
3255917201 | ||
|
|
29453089cc | ||
|
|
0f4d7450ff | ||
|
|
6c83f4ee4e | ||
|
|
e8bd962a55 | ||
|
|
7f7bebcfde | ||
|
|
d9aea9a6ca | ||
|
|
9ab230f5b7 | ||
|
|
7ee91ff7d7 | ||
|
|
6a056b199c | ||
|
|
6701b48cc8 | ||
|
|
0caed3cc56 | ||
|
|
ab7881077b | ||
|
|
67948cb4f8 | ||
|
|
8c507b8b13 | ||
|
|
f19a83d4ee | ||
|
|
531c666cf0 | ||
|
|
d9c842a7d4 | ||
|
|
c6293628e7 | ||
|
|
d5a447fb28 | ||
|
|
352cfdb69c | ||
|
|
c234b1a1cc | ||
|
|
233a2b224c | ||
|
|
bb462a1709 | ||
|
|
8d140ff86f | ||
|
|
d7a8120ffe | ||
|
|
335087b20f | ||
|
|
564e1dbcf4 | ||
|
|
a35b32892a | ||
|
|
86971bbf0e | ||
|
|
a8edba85df | ||
|
|
1089b09412 | ||
|
|
06f8d892ef | ||
|
|
d47b1deada | ||
|
|
0b9c1a520d | ||
|
|
cedfa28d00 | ||
|
|
f861ea6b07 | ||
|
|
b81be20d60 | ||
|
|
7cde7293cb | ||
|
|
6f9bfd0601 | ||
|
|
8ddc361c91 | ||
|
|
2c55857699 | ||
|
|
458d39a41f | ||
|
|
ff84f9c1e9 | ||
|
|
0207056ec7 | ||
|
|
026259c199 | ||
|
|
e175cc7dde | ||
|
|
086b12b4a5 | ||
|
|
3d59e73b5f | ||
|
|
606c152603 | ||
|
|
bc73884a6d | ||
|
|
b1a7cdbe09 | ||
|
|
34bc7f25d3 | ||
|
|
d773aafdcc | ||
|
|
ab8bd6b10b | ||
|
|
9b5c71cd8b | ||
|
|
cf04988fc2 | ||
|
|
7ed4e581f7 | ||
|
|
20f60e9277 | ||
|
|
549611fb1c | ||
|
|
eb8201ec56 | ||
|
|
91bb09248a | ||
|
|
b6e0005734 | ||
|
|
42b61b122f | ||
|
|
66eb4edd2c | ||
|
|
bc62154bfb | ||
|
|
ddf0c4c389 | ||
|
|
0b352eba12 | ||
|
|
9d2294de5a | ||
|
|
effddf5ab0 | ||
|
|
e709337df2 | ||
|
|
0a03ea71a1 | ||
|
|
3a81c0991b | ||
|
|
32f3696ffb | ||
|
|
901419798d | ||
|
|
82e41790d9 | ||
|
|
ff34175dc3 | ||
|
|
80dd12bb92 | ||
|
|
a01a7ec399 | ||
|
|
5eb0941512 | ||
|
|
e6d1414353 | ||
|
|
9313605c20 | ||
|
|
47fcd72cce | ||
|
|
6481e980c8 | ||
|
|
7e488a865e | ||
|
|
39016f669a | ||
|
|
b39bbfad87 | ||
|
|
683939a354 | ||
|
|
13af8005b8 | ||
|
|
aac4744cb3 | ||
|
|
ffc7a4e80d | ||
|
|
3b35024d23 | ||
|
|
df11a5e37c | ||
|
|
9b7dd0b8ef | ||
|
|
a4abe51c2a | ||
|
|
d186dbad4d | ||
|
|
b6fa8f437f | ||
|
|
09132125c6 | ||
|
|
a70a842778 | ||
|
|
417c9d2615 | ||
|
|
1ce0fad720 | ||
|
|
620dfa415a | ||
|
|
8a456d2c0d | ||
|
|
ddd61e8165 | ||
|
|
0ef8508414 | ||
|
|
3761c92c3f | ||
|
|
1b80c7b3ee | ||
|
|
acd19ccfa0 | ||
|
|
d365536b7d | ||
|
|
d03f7252df | ||
|
|
790ffc5157 | ||
|
|
cb9d40055d | ||
|
|
a7df624865 | ||
|
|
c46f113011 | ||
|
|
845471394c | ||
|
|
43d78dc37d | ||
|
|
7ac33769d2 | ||
|
|
edd17f17e3 | ||
|
|
8141518cfa | ||
|
|
b6102c4ec3 | ||
|
|
cb8e119ef1 | ||
|
|
5a974b25b6 | ||
|
|
84777d7192 | ||
|
|
e253e47943 | ||
|
|
53319922e9 | ||
|
|
7573c58552 | ||
|
|
a59b2c30bc | ||
|
|
782712451f | ||
|
|
323ddea72d | ||
|
|
d6ee372671 | ||
|
|
b53f809769 | ||
|
|
39d568adbd | ||
|
|
6059cb85e1 | ||
|
|
d69cf0e7f4 | ||
|
|
9599a28b95 | ||
|
|
e8ea663da8 | ||
|
|
ada69133a6 | ||
|
|
c27038b741 | ||
|
|
cb9a456b49 | ||
|
|
7bb911b3eb | ||
|
|
1974e31211 | ||
|
|
3b3aee1703 | ||
|
|
bc4142de4d | ||
|
|
c124fee659 | ||
|
|
1239f2b526 | ||
|
|
8655322495 | ||
|
|
8ac0220f5d | ||
|
|
c533d43c0f | ||
|
|
8941860140 | ||
|
|
2945c710e3 | ||
|
|
7b88c1d365 | ||
|
|
b732f88b0e | ||
|
|
7095afa43e | ||
|
|
eb4ec94e01 | ||
|
|
94b736d6ae | ||
|
|
8f556a5678 | ||
|
|
6e8d871d4b | ||
|
|
caaa1eba4b | ||
|
|
9d1cf016d3 | ||
|
|
738af5f76f | ||
|
|
14acce0f4b | ||
|
|
115422e51e | ||
|
|
c7e42c1bf1 | ||
|
|
b09c80ee8d | ||
|
|
2b187e7864 | ||
|
|
b0ba29fcb6 | ||
|
|
a1f37bb491 | ||
|
|
53096fbf29 | ||
|
|
5c19cfb80a | ||
|
|
caba9e77c9 | ||
|
|
d60bdaaf01 | ||
|
|
22931f1500 | ||
|
|
d3ef54a410 | ||
|
|
318f812adf | ||
|
|
2016c32dbb | ||
|
|
00b3132d31 | ||
|
|
0486aaaf88 | ||
|
|
5388a051cb | ||
|
|
7614d896aa | ||
|
|
736ea322dd | ||
|
|
9506affdc3 | ||
|
|
c53a1448d9 | ||
|
|
99a02b991c | ||
|
|
6f49564e1b | ||
|
|
c9000f8f8c | ||
|
|
00fdfa2948 | ||
|
|
387c1cb71b | ||
|
|
7712d2940c | ||
|
|
c4d274c614 | ||
|
|
c4e155fc02 | ||
|
|
e07322d3d3 | ||
|
|
d27dd5aa48 | ||
|
|
c78ac978a1 | ||
|
|
59c7b18ccc | ||
|
|
5da553ae54 | ||
|
|
1918c1c101 | ||
|
|
e084049891 | ||
|
|
003f48addb | ||
|
|
0f9fc76711 | ||
|
|
8944710e22 | ||
|
|
92870b3b8c | ||
|
|
bd2064a19a | ||
|
|
bd804f373b | ||
|
|
249a5639a9 | ||
|
|
5f3d6af9f0 | ||
|
|
775786c6f1 | ||
|
|
3546802921 | ||
|
|
7ab6cd2125 | ||
|
|
6dddf6e2f0 | ||
|
|
1de338620c | ||
|
|
ab74ae723d | ||
|
|
412931d755 | ||
|
|
3c11aebdbc | ||
|
|
fd24014852 | ||
|
|
19c8a67ce0 | ||
|
|
8df6511b18 | ||
|
|
e668f75633 | ||
|
|
6c121fc8ba | ||
|
|
27dff67b69 | ||
|
|
c76081de05 | ||
|
|
307521c12b | ||
|
|
5d3c0f8dc9 | ||
|
|
a7abf4636f | ||
|
|
e31a581a50 | ||
|
|
f2cd027472 | ||
|
|
feff332357 | ||
|
|
678de91446 | ||
|
|
ec78da9f17 | ||
|
|
dc5e5181b6 | ||
|
|
7a205b11ec | ||
|
|
4cd9c62fb9 | ||
|
|
fc2a14d78d | ||
|
|
0a42a1b2cd | ||
|
|
2b1b9e30a3 | ||
|
|
6e5e3f5ecc | ||
|
|
6e74d8f06f | ||
|
|
2d81a3a319 | ||
|
|
c90066408d | ||
|
|
dea5656e62 | ||
|
|
37e20ed32f | ||
|
|
749cb04cec | ||
|
|
f452c486d4 | ||
|
|
9d737cd743 | ||
|
|
1ddabe4f0e | ||
|
|
bb7fc84363 | ||
|
|
253bda2f16 | ||
|
|
a251740aff | ||
|
|
47f6343347 | ||
|
|
ad336f5e18 | ||
|
|
c08fbf2e45 | ||
|
|
0f20052db7 | ||
|
|
f303e31fad | ||
|
|
9201207dc9 | ||
|
|
2070e518af | ||
|
|
66f1935c2e | ||
|
|
a860285132 | ||
|
|
b23331d069 | ||
|
|
2cb5171420 | ||
|
|
78f2dc4e74 | ||
|
|
44f4a7656b | ||
|
|
5866a0826c | ||
|
|
8e1031fff0 | ||
|
|
1ec4987b38 | ||
|
|
6542ac66f1 | ||
|
|
9bf4e8894f | ||
|
|
704683421f | ||
|
|
9e9e04b97e | ||
|
|
59c463dbd3 | ||
|
|
8af2db2976 | ||
|
|
a22bff1879 | ||
|
|
5009697f7b | ||
|
|
a8b9c3623a | ||
|
|
d5d53b563c | ||
|
|
c4fa0fc06e | ||
|
|
ee3e9737c4 | ||
|
|
322cafa3c2 | ||
|
|
232302eb6f | ||
|
|
ef1773d966 | ||
|
|
e3deec9741 | ||
|
|
10fbee4e6e | ||
|
|
4fe589f0e2 | ||
|
|
a3538f6470 | ||
|
|
e82a10cb8b | ||
|
|
cc89cc667a | ||
|
|
a796973861 | ||
|
|
eba212a056 | ||
|
|
54b3fa0d87 | ||
|
|
51e8beb46c | ||
|
|
33af04db1b | ||
|
|
29c3c42134 | ||
|
|
f89f6d6223 | ||
|
|
34eb2b94b3 | ||
|
|
88012c35bd | ||
|
|
3f3061a899 | ||
|
|
53eb560aa5 | ||
|
|
11dc0d77b4 | ||
|
|
35ef8f1586 | ||
|
|
15be3b847c | ||
|
|
7bbce79394 | ||
|
|
99186e8e2f | ||
|
|
148c075d58 | ||
|
|
e3b7271f69 | ||
|
|
7802bed394 | ||
|
|
2abd1d113f | ||
|
|
4718998e07 | ||
|
|
c07687102e | ||
|
|
8805c8264c | ||
|
|
15e19d4e8b | ||
|
|
48b1cfde09 | ||
|
|
540bb97f31 | ||
|
|
cbb010acca | ||
|
|
1afd49bd24 | ||
|
|
fae5ec26fb | ||
|
|
103c8d4dfd | ||
|
|
69fc869990 | ||
|
|
76c04f6873 | ||
|
|
6f5aa5e09b | ||
|
|
8764915fcd | ||
|
|
bd6a8b9c7c | ||
|
|
eb6c8857d1 | ||
|
|
a35808ac15 | ||
|
|
ef05822b70 | ||
|
|
4f1fbcc98b | ||
|
|
43b626cbfc | ||
|
|
3d0ff40382 | ||
|
|
f41578905f | ||
|
|
08fe64b965 | ||
|
|
7ea34b3b20 | ||
|
|
030a00ba46 | ||
|
|
41ed682fbe | ||
|
|
75d862748b | ||
|
|
66bf9e4a8c | ||
|
|
dfdbf09bf8 | ||
|
|
3c0e7afeb2 | ||
|
|
bb67d68eba | ||
|
|
0430f0b1cc | ||
|
|
8b445ae998 | ||
|
|
77b7af13d4 | ||
|
|
3e9f09571b | ||
|
|
eed7699549 | ||
|
|
5fd546c428 | ||
|
|
fc3e6715db | ||
|
|
9057a4cd15 | ||
|
|
bc99929040 | ||
|
|
8f13465415 | ||
|
|
412ecbe691 | ||
|
|
8b4950c79d | ||
|
|
2fc8232d57 | ||
|
|
6ca3c03179 | ||
|
|
cc25c2b506 | ||
|
|
c180b37760 | ||
|
|
25d464215e | ||
|
|
da06db2d3b | ||
|
|
117250879b | ||
|
|
4fbd0815a4 | ||
|
|
fdd707de67 | ||
|
|
73ce8608ec | ||
|
|
22f600bf44 | ||
|
|
405a4b7340 |
20
.beads/.gitignore
vendored
20
.beads/.gitignore
vendored
@@ -10,6 +10,13 @@ daemon.lock
|
|||||||
daemon.log
|
daemon.log
|
||||||
daemon.pid
|
daemon.pid
|
||||||
bd.sock
|
bd.sock
|
||||||
|
sync-state.json
|
||||||
|
.sync.lock
|
||||||
|
last-touched
|
||||||
|
sync_base.jsonl
|
||||||
|
.sync.lock
|
||||||
|
last-touched
|
||||||
|
sync_base.jsonl
|
||||||
|
|
||||||
# Local version tracking (prevents upgrade notification spam after git ops)
|
# Local version tracking (prevents upgrade notification spam after git ops)
|
||||||
.local_version
|
.local_version
|
||||||
@@ -18,6 +25,10 @@ bd.sock
|
|||||||
db.sqlite
|
db.sqlite
|
||||||
bd.db
|
bd.db
|
||||||
|
|
||||||
|
# Worktree redirect file (contains relative path to main repo's .beads/)
|
||||||
|
# Must not be committed as paths would be wrong in other clones
|
||||||
|
redirect
|
||||||
|
|
||||||
# Merge artifacts (temporary files from 3-way merge)
|
# Merge artifacts (temporary files from 3-way merge)
|
||||||
beads.base.jsonl
|
beads.base.jsonl
|
||||||
beads.base.meta.json
|
beads.base.meta.json
|
||||||
@@ -26,7 +37,8 @@ beads.left.meta.json
|
|||||||
beads.right.jsonl
|
beads.right.jsonl
|
||||||
beads.right.meta.json
|
beads.right.meta.json
|
||||||
|
|
||||||
# Keep JSONL exports and config (source of truth for git)
|
# NOTE: Do NOT add negation patterns (e.g., !issues.jsonl) here.
|
||||||
!issues.jsonl
|
# They would override fork protection in .git/info/exclude, allowing
|
||||||
!metadata.json
|
# contributors to accidentally commit upstream issue databases.
|
||||||
!config.json
|
# The JSONL files (issues.jsonl, interactions.jsonl) and config files
|
||||||
|
# are tracked by git by default since no pattern above ignores them.
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
# This setting persists across clones (unlike database config which is gitignored).
|
# This setting persists across clones (unlike database config which is gitignored).
|
||||||
# Can also use BEADS_SYNC_BRANCH env var for local override.
|
# Can also use BEADS_SYNC_BRANCH env var for local override.
|
||||||
# If not set, bd sync will require you to run 'bd config set sync.branch <branch>'.
|
# If not set, bd sync will require you to run 'bd config set sync.branch <branch>'.
|
||||||
# sync-branch: "beads-sync"
|
sync-branch: "beads-sync"
|
||||||
|
|
||||||
# Multi-repo configuration (experimental - bd-307)
|
# Multi-repo configuration (experimental - bd-307)
|
||||||
# Allows hydrating from multiple repositories and routing writes to the correct JSONL
|
# Allows hydrating from multiple repositories and routing writes to the correct JSONL
|
||||||
@@ -59,4 +59,4 @@
|
|||||||
# - linear.url
|
# - linear.url
|
||||||
# - linear.api-key
|
# - linear.api-key
|
||||||
# - github.org
|
# - github.org
|
||||||
# - github.repo
|
# - github.repo
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{"id":"--stealth-d39","title":"Superadmin control surface spec and access matrix","description":"Define the minimal superadmin control surface, permissions, and mapping to tenant/guest responsibilities. Document scope and non-goals.","status":"closed","priority":2,"issue_type":"task","created_at":"2026-01-01T14:16:06.994379577+01:00","updated_at":"2026-01-01T14:20:43.080701114+01:00","closed_at":"2026-01-01T14:20:43.080701114+01:00","close_reason":"Duplicate of fotospiel-app-ihd after beads re-init"}
|
||||||
|
{"id":"fotospiel-app-097","title":"Tenant announcements / release notes","description":"Broadcast announcements to tenants/admins with targeting and scheduling.","status":"open","priority":3,"issue_type":"feature","created_at":"2026-01-01T14:20:21.68206312+01:00","updated_at":"2026-01-01T14:20:21.68206312+01:00"}
|
||||||
|
{"id":"fotospiel-app-arp","title":"Guest policy settings (toggles, rate limits, retention defaults)","description":"Global guest feature toggles, rate limits, and retention defaults. Settings page + persistence.","status":"open","priority":2,"issue_type":"feature","created_at":"2026-01-01T14:18:52.931017783+01:00","updated_at":"2026-01-01T14:18:52.931017783+01:00"}
|
||||||
|
{"id":"fotospiel-app-bit","title":"Superadmin control surface roadmap","description":"Roadmap to implement practical superadmin control over tenant admin + guest experience. Tracks lifecycle, moderation, policies, ops health, compliance, audit, announcements, integrations.","status":"open","priority":1,"issue_type":"epic","created_at":"2026-01-01T14:21:01.852988935+01:00","updated_at":"2026-01-01T14:21:01.852988935+01:00","dependencies":[{"issue_id":"fotospiel-app-bit","depends_on_id":"fotospiel-app-ihd","type":"blocks","created_at":"2026-01-01T14:21:14.445938122+01:00","created_by":"soeren"},{"issue_id":"fotospiel-app-bit","depends_on_id":"fotospiel-app-wde","type":"blocks","created_at":"2026-01-01T14:21:16.788922347+01:00","created_by":"soeren"},{"issue_id":"fotospiel-app-bit","depends_on_id":"fotospiel-app-hbt","type":"blocks","created_at":"2026-01-01T14:21:18.300493488+01:00","created_by":"soeren"},{"issue_id":"fotospiel-app-bit","depends_on_id":"fotospiel-app-arp","type":"blocks","created_at":"2026-01-01T14:21:20.731646568+01:00","created_by":"soeren"},{"issue_id":"fotospiel-app-bit","depends_on_id":"fotospiel-app-tym","type":"blocks","created_at":"2026-01-01T14:21:23.219093242+01:00","created_by":"soeren"},{"issue_id":"fotospiel-app-bit","depends_on_id":"fotospiel-app-sbs","type":"blocks","created_at":"2026-01-01T14:21:24.67996941+01:00","created_by":"soeren"},{"issue_id":"fotospiel-app-bit","depends_on_id":"fotospiel-app-iyc","type":"blocks","created_at":"2026-01-01T14:21:27.027185624+01:00","created_by":"soeren"},{"issue_id":"fotospiel-app-bit","depends_on_id":"fotospiel-app-097","type":"blocks","created_at":"2026-01-01T14:21:29.668197239+01:00","created_by":"soeren"},{"issue_id":"fotospiel-app-bit","depends_on_id":"fotospiel-app-lqp","type":"blocks","created_at":"2026-01-01T14:21:31.238481004+01:00","created_by":"soeren"}]}
|
||||||
|
{"id":"fotospiel-app-hbt","title":"Moderation queue for guest content","description":"Queue for flagged guest content (photos, feedback). Bulk actions to hide/delete/resolve with audit.","status":"open","priority":1,"issue_type":"feature","created_at":"2026-01-01T14:18:37.777772819+01:00","updated_at":"2026-01-01T14:18:37.777772819+01:00"}
|
||||||
|
{"id":"fotospiel-app-ihd","title":"Superadmin control surface spec and access matrix","description":"Define the minimal superadmin control surface, permissions, and mapping to tenant/guest responsibilities. Document scope and non-goals.","status":"open","priority":2,"issue_type":"task","created_at":"2026-01-01T14:18:10.789147344+01:00","updated_at":"2026-01-01T14:18:10.789147344+01:00"}
|
||||||
|
{"id":"fotospiel-app-iyc","title":"Superadmin audit log for admin actions","description":"Audit trail for superadmin actions without PII payloads.","status":"open","priority":2,"issue_type":"feature","created_at":"2026-01-01T14:20:19.043695952+01:00","updated_at":"2026-01-01T14:20:19.043695952+01:00"}
|
||||||
|
{"id":"fotospiel-app-lqp","title":"Integrations health (Paddle/RevenueCat/webhooks)","description":"Health/status dashboard for payment and webhook integrations.","status":"open","priority":3,"issue_type":"feature","created_at":"2026-01-01T14:20:25.197673148+01:00","updated_at":"2026-01-01T14:20:25.197673148+01:00"}
|
||||||
|
{"id":"fotospiel-app-sbs","title":"Compliance tools: data export + retention overrides","description":"GDPR-compliant export requests and retention override workflows for tenants/events.","status":"open","priority":3,"issue_type":"feature","created_at":"2026-01-01T14:20:16.530289009+01:00","updated_at":"2026-01-01T14:20:16.530289009+01:00"}
|
||||||
|
{"id":"fotospiel-app-tym","title":"Ops health dashboard (queues, storage, upload pipeline)","description":"Superadmin ops dashboard showing queue backlog, failed jobs, storage thresholds, and upload pipeline health.","status":"open","priority":2,"issue_type":"feature","created_at":"2026-01-01T14:20:04.991351193+01:00","updated_at":"2026-01-01T14:20:04.991351193+01:00"}
|
||||||
|
{"id":"fotospiel-app-wde","title":"Tenant lifecycle controls (status, limits, suspend/grace)","description":"Superadmin controls for tenant status, grace periods, and hard limits (uploads/storage/events). Includes UI, policy checks, and audit events.","status":"open","priority":1,"issue_type":"feature","created_at":"2026-01-01T14:18:23.062036821+01:00","updated_at":"2026-01-01T14:18:23.062036821+01:00"}
|
||||||
|
|||||||
172
.beads/issues.jsonl
Normal file
172
.beads/issues.jsonl
Normal file
File diff suppressed because one or more lines are too long
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"database": "beads.db",
|
"database": "beads.db",
|
||||||
"jsonl_export": "interactions.jsonl"
|
"jsonl_export": "issues.jsonl",
|
||||||
|
"last_bd_version": "0.49.0"
|
||||||
}
|
}
|
||||||
33
.env.example
33
.env.example
@@ -97,6 +97,11 @@ GOOGLE_CLIENT_ID=
|
|||||||
GOOGLE_CLIENT_SECRET=
|
GOOGLE_CLIENT_SECRET=
|
||||||
GOOGLE_REDIRECT_URI=${APP_URL}/checkout/auth/google/callback
|
GOOGLE_REDIRECT_URI=${APP_URL}/checkout/auth/google/callback
|
||||||
|
|
||||||
|
# Facebook OAuth (Checkout comfort login)
|
||||||
|
FACEBOOK_CLIENT_ID=
|
||||||
|
FACEBOOK_CLIENT_SECRET=
|
||||||
|
FACEBOOK_REDIRECT_URI=${APP_URL}/checkout/auth/facebook/callback
|
||||||
|
|
||||||
VITE_APP_NAME="${APP_NAME}"
|
VITE_APP_NAME="${APP_NAME}"
|
||||||
VITE_ENABLE_TENANT_SWITCHER=false
|
VITE_ENABLE_TENANT_SWITCHER=false
|
||||||
REVENUECAT_WEBHOOK_SECRET=
|
REVENUECAT_WEBHOOK_SECRET=
|
||||||
@@ -112,14 +117,22 @@ PAYPAL_CLIENT_ID=
|
|||||||
PAYPAL_SECRET=
|
PAYPAL_SECRET=
|
||||||
PAYPAL_SANDBOX=true
|
PAYPAL_SANDBOX=true
|
||||||
|
|
||||||
# Paddle Billing
|
# Lemon Squeezy Billing
|
||||||
PADDLE_SANDBOX=true
|
LEMONSQUEEZY_STORE_ID=284860
|
||||||
PADDLE_API_KEY=
|
LEMONSQUEEZY_API_KEY=
|
||||||
PADDLE_CLIENT_ID=
|
LEMONSQUEEZY_WEBHOOK_SECRET=
|
||||||
PADDLE_WEBHOOK_SECRET=
|
LEMONSQUEEZY_WEBHOOK_EVENTS=
|
||||||
PADDLE_PUBLIC_KEY=
|
LEMONSQUEEZY_TEST_MODE=false
|
||||||
PADDLE_BASE_URL=
|
LEMONSQUEEZY_BASE_URL=https://api.lemonsqueezy.com/v1
|
||||||
PADDLE_CONSOLE_URL=
|
LEMONSQUEEZY_GIFT_VARIANT_STARTER=
|
||||||
|
LEMONSQUEEZY_GIFT_VARIANT_STARTER_USD=
|
||||||
|
LEMONSQUEEZY_GIFT_VARIANT_STARTER_GBP=
|
||||||
|
LEMONSQUEEZY_GIFT_VARIANT_STANDARD=
|
||||||
|
LEMONSQUEEZY_GIFT_VARIANT_STANDARD_USD=
|
||||||
|
LEMONSQUEEZY_GIFT_VARIANT_STANDARD_GBP=
|
||||||
|
LEMONSQUEEZY_GIFT_VARIANT_PREMIUM=
|
||||||
|
LEMONSQUEEZY_GIFT_VARIANT_PREMIUM_USD=
|
||||||
|
LEMONSQUEEZY_GIFT_VARIANT_PREMIUM_GBP=
|
||||||
|
|
||||||
# Sanctum / SPA auth
|
# Sanctum / SPA auth
|
||||||
SANCTUM_STATEFUL_DOMAINS=localhost,localhost:3000
|
SANCTUM_STATEFUL_DOMAINS=localhost,localhost:3000
|
||||||
@@ -187,5 +200,9 @@ STORAGE_QUEUE_PENDING_EVENT_MINUTES=8
|
|||||||
STORAGE_QUEUE_FAILED_EVENT_THRESHOLD=2
|
STORAGE_QUEUE_FAILED_EVENT_THRESHOLD=2
|
||||||
STORAGE_QUEUE_FAILED_EVENT_MINUTES=30
|
STORAGE_QUEUE_FAILED_EVENT_MINUTES=30
|
||||||
STORAGE_QUEUE_GUEST_ALERT_TTL=30
|
STORAGE_QUEUE_GUEST_ALERT_TTL=30
|
||||||
|
STORAGE_CHECKSUM_VALIDATION=true
|
||||||
|
STORAGE_CHECKSUM_ALERT_WINDOW_MINUTES=60
|
||||||
|
STORAGE_CHECKSUM_WARNING=1
|
||||||
|
STORAGE_CHECKSUM_CRITICAL=5
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
13
.gitignore
vendored
13
.gitignore
vendored
@@ -12,7 +12,10 @@ fotospiel-tenant-app
|
|||||||
/resources/js/wayfinder
|
/resources/js/wayfinder
|
||||||
/storage/*.key
|
/storage/*.key
|
||||||
/storage/pail
|
/storage/pail
|
||||||
|
/C:\\wwwroot\\fotospiel-app\\storage\\app/
|
||||||
/vendor
|
/vendor
|
||||||
|
/clients/photobooth-uploader/**/bin
|
||||||
|
/clients/photobooth-uploader/**/obj
|
||||||
.env
|
.env
|
||||||
.env.backup
|
.env.backup
|
||||||
.env.production
|
.env.production
|
||||||
@@ -23,11 +26,9 @@ Homestead.yaml
|
|||||||
npm-debug.log
|
npm-debug.log
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
/auth.json
|
/auth.json
|
||||||
/.fleet
|
|
||||||
/.idea
|
|
||||||
/.nova
|
|
||||||
/.vscode
|
/.vscode
|
||||||
/.zed
|
|
||||||
tools/git-askpass.ps1
|
|
||||||
podman-compose.dev.yml
|
|
||||||
test-results
|
test-results
|
||||||
|
GEMINI.md
|
||||||
|
.beads/.sync.lock
|
||||||
|
.beads/daemon-error
|
||||||
|
.beads/sync_base.jsonl
|
||||||
|
|||||||
@@ -337,8 +337,8 @@ Tokens are design system values that can be referenced using the `$` prefix.
|
|||||||
|
|
||||||
### Color Tokens
|
### Color Tokens
|
||||||
|
|
||||||
- `accent`: #FFB6C1
|
- `accent`: #3D5AFE
|
||||||
- `accentSoft`: #FFE5EC
|
- `accentSoft`: #E8ECFF
|
||||||
- `blue10Dark`: hsl(209, 100%, 60.6%)
|
- `blue10Dark`: hsl(209, 100%, 60.6%)
|
||||||
- `blue10Light`: hsl(208, 100%, 47.3%)
|
- `blue10Light`: hsl(208, 100%, 47.3%)
|
||||||
- `blue11Dark`: hsl(210, 100%, 66.1%)
|
- `blue11Dark`: hsl(210, 100%, 66.1%)
|
||||||
@@ -363,8 +363,8 @@ Tokens are design system values that can be referenced using the `$` prefix.
|
|||||||
- `blue8Light`: hsl(206, 81.9%, 65.3%)
|
- `blue8Light`: hsl(206, 81.9%, 65.3%)
|
||||||
- `blue9Dark`: hsl(206, 100%, 50.0%)
|
- `blue9Dark`: hsl(206, 100%, 50.0%)
|
||||||
- `blue9Light`: hsl(206, 100%, 50.0%)
|
- `blue9Light`: hsl(206, 100%, 50.0%)
|
||||||
- `border`: #F2E4DA
|
- `border`: #F3D6C9
|
||||||
- `danger`: #E04848
|
- `danger`: #EF4444
|
||||||
- `gray10Dark`: hsl(0, 0%, 49.4%)
|
- `gray10Dark`: hsl(0, 0%, 49.4%)
|
||||||
- `gray10Light`: hsl(0, 0%, 52.3%)
|
- `gray10Light`: hsl(0, 0%, 52.3%)
|
||||||
- `gray11Dark`: hsl(0, 0%, 62.8%)
|
- `gray11Dark`: hsl(0, 0%, 62.8%)
|
||||||
@@ -413,7 +413,7 @@ Tokens are design system values that can be referenced using the `$` prefix.
|
|||||||
- `green8Light`: hsl(151, 40.2%, 54.1%)
|
- `green8Light`: hsl(151, 40.2%, 54.1%)
|
||||||
- `green9Dark`: hsl(151, 55.0%, 41.5%)
|
- `green9Dark`: hsl(151, 55.0%, 41.5%)
|
||||||
- `green9Light`: hsl(151, 55.0%, 41.5%)
|
- `green9Light`: hsl(151, 55.0%, 41.5%)
|
||||||
- `muted`: #F4ECE8
|
- `muted`: #FFF6F0
|
||||||
- `orange10Dark`: hsl(24, 100%, 58.5%)
|
- `orange10Dark`: hsl(24, 100%, 58.5%)
|
||||||
- `orange10Light`: hsl(24, 100%, 46.5%)
|
- `orange10Light`: hsl(24, 100%, 46.5%)
|
||||||
- `orange11Dark`: hsl(24, 100%, 62.2%)
|
- `orange11Dark`: hsl(24, 100%, 62.2%)
|
||||||
@@ -462,7 +462,7 @@ Tokens are design system values that can be referenced using the `$` prefix.
|
|||||||
- `pink8Light`: hsl(323, 60.3%, 72.4%)
|
- `pink8Light`: hsl(323, 60.3%, 72.4%)
|
||||||
- `pink9Dark`: hsl(322, 65.0%, 54.5%)
|
- `pink9Dark`: hsl(322, 65.0%, 54.5%)
|
||||||
- `pink9Light`: hsl(322, 65.0%, 54.5%)
|
- `pink9Light`: hsl(322, 65.0%, 54.5%)
|
||||||
- `primary`: #FF5A5F
|
- `primary`: #FF5C5C
|
||||||
- `purple10Dark`: hsl(273, 57.3%, 59.1%)
|
- `purple10Dark`: hsl(273, 57.3%, 59.1%)
|
||||||
- `purple10Light`: hsl(272, 46.8%, 50.3%)
|
- `purple10Light`: hsl(272, 46.8%, 50.3%)
|
||||||
- `purple11Dark`: hsl(275, 80.0%, 71.0%)
|
- `purple11Dark`: hsl(275, 80.0%, 71.0%)
|
||||||
@@ -511,10 +511,10 @@ Tokens are design system values that can be referenced using the `$` prefix.
|
|||||||
- `red8Light`: hsl(359, 69.5%, 74.3%)
|
- `red8Light`: hsl(359, 69.5%, 74.3%)
|
||||||
- `red9Dark`: hsl(358, 75.0%, 59.0%)
|
- `red9Dark`: hsl(358, 75.0%, 59.0%)
|
||||||
- `red9Light`: hsl(358, 75.0%, 59.0%)
|
- `red9Light`: hsl(358, 75.0%, 59.0%)
|
||||||
- `success`: #06D6A0
|
- `success`: #22C55E
|
||||||
- `surface`: #ffffff
|
- `surface`: #ffffff
|
||||||
- `text`: #1F2937
|
- `text`: #0B132B
|
||||||
- `warning`: #F5C542
|
- `warning`: #FBBF24
|
||||||
- `yellow10Dark`: hsl(54, 100%, 68.0%)
|
- `yellow10Dark`: hsl(54, 100%, 68.0%)
|
||||||
- `yellow10Light`: hsl(50, 100%, 48.5%)
|
- `yellow10Light`: hsl(50, 100%, 48.5%)
|
||||||
- `yellow11Dark`: hsl(48, 100%, 47.0%)
|
- `yellow11Dark`: hsl(48, 100%, 47.0%)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
868074
.tamagui/tamagui.config.json
868074
.tamagui/tamagui.config.json
File diff suppressed because it is too large
Load Diff
@@ -118,319 +118,8 @@ var isWindowDefined = typeof window < "u";
|
|||||||
var isClient = isWeb && isWindowDefined;
|
var isClient = isWeb && isWindowDefined;
|
||||||
var isChrome = typeof navigator < "u" && /Chrome/.test(navigator.userAgent || "");
|
var isChrome = typeof navigator < "u" && /Chrome/.test(navigator.userAgent || "");
|
||||||
var isWebTouchable = isClient && ("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
var isWebTouchable = isClient && ("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
||||||
var isAndroid = false;
|
|
||||||
var isIos = process.env.TEST_NATIVE_PLATFORM === "ios";
|
var isIos = process.env.TEST_NATIVE_PLATFORM === "ios";
|
||||||
|
|
||||||
// node_modules/@tamagui/helpers/dist/esm/validStyleProps.mjs
|
|
||||||
var textColors = {
|
|
||||||
color: true,
|
|
||||||
textDecorationColor: true,
|
|
||||||
textShadowColor: true
|
|
||||||
};
|
|
||||||
var tokenCategories = {
|
|
||||||
radius: {
|
|
||||||
borderRadius: true,
|
|
||||||
borderTopLeftRadius: true,
|
|
||||||
borderTopRightRadius: true,
|
|
||||||
borderBottomLeftRadius: true,
|
|
||||||
borderBottomRightRadius: true,
|
|
||||||
// logical
|
|
||||||
borderStartStartRadius: true,
|
|
||||||
borderStartEndRadius: true,
|
|
||||||
borderEndStartRadius: true,
|
|
||||||
borderEndEndRadius: true
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
width: true,
|
|
||||||
height: true,
|
|
||||||
minWidth: true,
|
|
||||||
minHeight: true,
|
|
||||||
maxWidth: true,
|
|
||||||
maxHeight: true,
|
|
||||||
blockSize: true,
|
|
||||||
minBlockSize: true,
|
|
||||||
maxBlockSize: true,
|
|
||||||
inlineSize: true,
|
|
||||||
minInlineSize: true,
|
|
||||||
maxInlineSize: true
|
|
||||||
},
|
|
||||||
zIndex: {
|
|
||||||
zIndex: true
|
|
||||||
},
|
|
||||||
color: {
|
|
||||||
backgroundColor: true,
|
|
||||||
borderColor: true,
|
|
||||||
borderBlockStartColor: true,
|
|
||||||
borderBlockEndColor: true,
|
|
||||||
borderBlockColor: true,
|
|
||||||
borderBottomColor: true,
|
|
||||||
borderInlineColor: true,
|
|
||||||
borderInlineStartColor: true,
|
|
||||||
borderInlineEndColor: true,
|
|
||||||
borderTopColor: true,
|
|
||||||
borderLeftColor: true,
|
|
||||||
borderRightColor: true,
|
|
||||||
borderEndColor: true,
|
|
||||||
borderStartColor: true,
|
|
||||||
shadowColor: true,
|
|
||||||
...textColors,
|
|
||||||
outlineColor: true,
|
|
||||||
caretColor: true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var stylePropsUnitless = {
|
|
||||||
WebkitLineClamp: true,
|
|
||||||
animationIterationCount: true,
|
|
||||||
aspectRatio: true,
|
|
||||||
borderImageOutset: true,
|
|
||||||
borderImageSlice: true,
|
|
||||||
borderImageWidth: true,
|
|
||||||
columnCount: true,
|
|
||||||
flex: true,
|
|
||||||
flexGrow: true,
|
|
||||||
flexOrder: true,
|
|
||||||
flexPositive: true,
|
|
||||||
flexShrink: true,
|
|
||||||
flexNegative: true,
|
|
||||||
fontWeight: true,
|
|
||||||
gridRow: true,
|
|
||||||
gridRowEnd: true,
|
|
||||||
gridRowGap: true,
|
|
||||||
gridRowStart: true,
|
|
||||||
gridColumn: true,
|
|
||||||
gridColumnEnd: true,
|
|
||||||
gridColumnGap: true,
|
|
||||||
gridColumnStart: true,
|
|
||||||
gridTemplateColumns: true,
|
|
||||||
gridTemplateAreas: true,
|
|
||||||
lineClamp: true,
|
|
||||||
opacity: true,
|
|
||||||
order: true,
|
|
||||||
orphans: true,
|
|
||||||
tabSize: true,
|
|
||||||
widows: true,
|
|
||||||
zIndex: true,
|
|
||||||
zoom: true,
|
|
||||||
scale: true,
|
|
||||||
scaleX: true,
|
|
||||||
scaleY: true,
|
|
||||||
scaleZ: true,
|
|
||||||
shadowOpacity: true
|
|
||||||
};
|
|
||||||
var stylePropsTransform = {
|
|
||||||
x: true,
|
|
||||||
y: true,
|
|
||||||
scale: true,
|
|
||||||
perspective: true,
|
|
||||||
scaleX: true,
|
|
||||||
scaleY: true,
|
|
||||||
skewX: true,
|
|
||||||
skewY: true,
|
|
||||||
matrix: true,
|
|
||||||
rotate: true,
|
|
||||||
rotateY: true,
|
|
||||||
rotateX: true,
|
|
||||||
rotateZ: true
|
|
||||||
};
|
|
||||||
var stylePropsView = {
|
|
||||||
backfaceVisibility: true,
|
|
||||||
borderBottomEndRadius: true,
|
|
||||||
borderBottomStartRadius: true,
|
|
||||||
borderBottomWidth: true,
|
|
||||||
borderLeftWidth: true,
|
|
||||||
borderRightWidth: true,
|
|
||||||
borderBlockWidth: true,
|
|
||||||
borderBlockEndWidth: true,
|
|
||||||
borderBlockStartWidth: true,
|
|
||||||
borderInlineWidth: true,
|
|
||||||
borderInlineEndWidth: true,
|
|
||||||
borderInlineStartWidth: true,
|
|
||||||
borderStyle: true,
|
|
||||||
borderBlockStyle: true,
|
|
||||||
borderBlockEndStyle: true,
|
|
||||||
borderBlockStartStyle: true,
|
|
||||||
borderInlineStyle: true,
|
|
||||||
borderInlineEndStyle: true,
|
|
||||||
borderInlineStartStyle: true,
|
|
||||||
borderTopEndRadius: true,
|
|
||||||
borderTopStartRadius: true,
|
|
||||||
borderTopWidth: true,
|
|
||||||
borderWidth: true,
|
|
||||||
transform: true,
|
|
||||||
transformOrigin: true,
|
|
||||||
alignContent: true,
|
|
||||||
alignItems: true,
|
|
||||||
alignSelf: true,
|
|
||||||
borderEndWidth: true,
|
|
||||||
borderStartWidth: true,
|
|
||||||
bottom: true,
|
|
||||||
display: true,
|
|
||||||
end: true,
|
|
||||||
flexBasis: true,
|
|
||||||
flexDirection: true,
|
|
||||||
flexWrap: true,
|
|
||||||
gap: true,
|
|
||||||
columnGap: true,
|
|
||||||
rowGap: true,
|
|
||||||
justifyContent: true,
|
|
||||||
left: true,
|
|
||||||
margin: true,
|
|
||||||
marginBlock: true,
|
|
||||||
marginBlockEnd: true,
|
|
||||||
marginBlockStart: true,
|
|
||||||
marginInline: true,
|
|
||||||
marginInlineStart: true,
|
|
||||||
marginInlineEnd: true,
|
|
||||||
marginBottom: true,
|
|
||||||
marginEnd: true,
|
|
||||||
marginHorizontal: true,
|
|
||||||
marginLeft: true,
|
|
||||||
marginRight: true,
|
|
||||||
marginStart: true,
|
|
||||||
marginTop: true,
|
|
||||||
marginVertical: true,
|
|
||||||
overflow: true,
|
|
||||||
padding: true,
|
|
||||||
paddingBottom: true,
|
|
||||||
paddingInline: true,
|
|
||||||
paddingBlock: true,
|
|
||||||
paddingBlockStart: true,
|
|
||||||
paddingInlineEnd: true,
|
|
||||||
paddingInlineStart: true,
|
|
||||||
paddingEnd: true,
|
|
||||||
paddingHorizontal: true,
|
|
||||||
paddingLeft: true,
|
|
||||||
paddingRight: true,
|
|
||||||
paddingStart: true,
|
|
||||||
paddingTop: true,
|
|
||||||
paddingVertical: true,
|
|
||||||
position: true,
|
|
||||||
right: true,
|
|
||||||
start: true,
|
|
||||||
top: true,
|
|
||||||
inset: true,
|
|
||||||
insetBlock: true,
|
|
||||||
insetBlockEnd: true,
|
|
||||||
insetBlockStart: true,
|
|
||||||
insetInline: true,
|
|
||||||
insetInlineEnd: true,
|
|
||||||
insetInlineStart: true,
|
|
||||||
direction: true,
|
|
||||||
shadowOffset: true,
|
|
||||||
shadowRadius: true,
|
|
||||||
...tokenCategories.color,
|
|
||||||
...tokenCategories.radius,
|
|
||||||
...tokenCategories.size,
|
|
||||||
...tokenCategories.radius,
|
|
||||||
...stylePropsTransform,
|
|
||||||
...stylePropsUnitless,
|
|
||||||
boxShadow: true,
|
|
||||||
filter: true,
|
|
||||||
// RN 0.77+ style props (set REACT_NATIVE_PRE_77=1 for older RN)
|
|
||||||
...!process.env.REACT_NATIVE_PRE_77 && {
|
|
||||||
boxSizing: true,
|
|
||||||
mixBlendMode: true,
|
|
||||||
outlineColor: true,
|
|
||||||
outlineSpread: true,
|
|
||||||
outlineStyle: true,
|
|
||||||
outlineWidth: true
|
|
||||||
},
|
|
||||||
// RN doesn't support specific border styles per-edge
|
|
||||||
transition: true,
|
|
||||||
textWrap: true,
|
|
||||||
backdropFilter: true,
|
|
||||||
WebkitBackdropFilter: true,
|
|
||||||
background: true,
|
|
||||||
backgroundAttachment: true,
|
|
||||||
backgroundBlendMode: true,
|
|
||||||
backgroundClip: true,
|
|
||||||
backgroundColor: true,
|
|
||||||
backgroundImage: true,
|
|
||||||
backgroundOrigin: true,
|
|
||||||
backgroundPosition: true,
|
|
||||||
backgroundRepeat: true,
|
|
||||||
backgroundSize: true,
|
|
||||||
borderBottomStyle: true,
|
|
||||||
borderImage: true,
|
|
||||||
borderLeftStyle: true,
|
|
||||||
borderRightStyle: true,
|
|
||||||
borderTopStyle: true,
|
|
||||||
caretColor: true,
|
|
||||||
clipPath: true,
|
|
||||||
contain: true,
|
|
||||||
containerType: true,
|
|
||||||
content: true,
|
|
||||||
cursor: true,
|
|
||||||
float: true,
|
|
||||||
mask: true,
|
|
||||||
maskBorder: true,
|
|
||||||
maskBorderMode: true,
|
|
||||||
maskBorderOutset: true,
|
|
||||||
maskBorderRepeat: true,
|
|
||||||
maskBorderSlice: true,
|
|
||||||
maskBorderSource: true,
|
|
||||||
maskBorderWidth: true,
|
|
||||||
maskClip: true,
|
|
||||||
maskComposite: true,
|
|
||||||
maskImage: true,
|
|
||||||
maskMode: true,
|
|
||||||
maskOrigin: true,
|
|
||||||
maskPosition: true,
|
|
||||||
maskRepeat: true,
|
|
||||||
maskSize: true,
|
|
||||||
maskType: true,
|
|
||||||
objectFit: true,
|
|
||||||
objectPosition: true,
|
|
||||||
outlineOffset: true,
|
|
||||||
overflowBlock: true,
|
|
||||||
overflowInline: true,
|
|
||||||
overflowX: true,
|
|
||||||
overflowY: true,
|
|
||||||
pointerEvents: true,
|
|
||||||
scrollbarWidth: true,
|
|
||||||
textEmphasis: true,
|
|
||||||
touchAction: true,
|
|
||||||
transformStyle: true,
|
|
||||||
userSelect: true,
|
|
||||||
willChange: true,
|
|
||||||
...isAndroid ? {
|
|
||||||
elevationAndroid: true
|
|
||||||
} : {}
|
|
||||||
};
|
|
||||||
var stylePropsFont = {
|
|
||||||
fontFamily: true,
|
|
||||||
fontSize: true,
|
|
||||||
fontStyle: true,
|
|
||||||
fontWeight: true,
|
|
||||||
fontVariant: true,
|
|
||||||
letterSpacing: true,
|
|
||||||
lineHeight: true,
|
|
||||||
textTransform: true
|
|
||||||
};
|
|
||||||
var stylePropsTextOnly = {
|
|
||||||
...stylePropsFont,
|
|
||||||
textAlign: true,
|
|
||||||
textDecorationLine: true,
|
|
||||||
textDecorationStyle: true,
|
|
||||||
...textColors,
|
|
||||||
textShadowOffset: true,
|
|
||||||
textShadowRadius: true,
|
|
||||||
userSelect: true,
|
|
||||||
selectable: true,
|
|
||||||
verticalAlign: true,
|
|
||||||
whiteSpace: true,
|
|
||||||
wordWrap: true,
|
|
||||||
textOverflow: true,
|
|
||||||
textDecorationDistance: true,
|
|
||||||
cursor: true,
|
|
||||||
WebkitLineClamp: true,
|
|
||||||
WebkitBoxOrient: true
|
|
||||||
};
|
|
||||||
var stylePropsText = {
|
|
||||||
...stylePropsView,
|
|
||||||
...stylePropsTextOnly
|
|
||||||
};
|
|
||||||
|
|
||||||
// node_modules/@tamagui/helpers/dist/esm/withStaticProperties.mjs
|
// node_modules/@tamagui/helpers/dist/esm/withStaticProperties.mjs
|
||||||
var import_react2 = __toESM(require("react"), 1);
|
var import_react2 = __toESM(require("react"), 1);
|
||||||
var Decorated = Symbol();
|
var Decorated = Symbol();
|
||||||
@@ -755,7 +444,10 @@ var SizableText2 = (0, import_web4.styled)(import_web4.Text, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
SizableText2.staticConfig.variants.fontFamily = {
|
SizableText2.staticConfig.variants.fontFamily = {
|
||||||
"...": /* @__PURE__ */ __name((_val, extras) => {
|
"...": /* @__PURE__ */ __name((val, extras) => {
|
||||||
|
if (val === "inherit") return {
|
||||||
|
fontFamily: "inherit"
|
||||||
|
};
|
||||||
const sizeProp = extras.props.size, fontSizeProp = extras.props.fontSize, size = sizeProp === "$true" && fontSizeProp ? fontSizeProp : extras.props.size || "$true";
|
const sizeProp = extras.props.size, fontSizeProp = extras.props.fontSize, size = sizeProp === "$true" && fontSizeProp ? fontSizeProp : extras.props.size || "$true";
|
||||||
return getFontSized(size, extras);
|
return getFontSized(size, extras);
|
||||||
}, "...")
|
}, "...")
|
||||||
|
|||||||
@@ -112,7 +112,10 @@ var SizableText2 = (0, import_web2.styled)(import_web2.Text, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
SizableText2.staticConfig.variants.fontFamily = {
|
SizableText2.staticConfig.variants.fontFamily = {
|
||||||
"...": /* @__PURE__ */ __name((_val, extras) => {
|
"...": /* @__PURE__ */ __name((val, extras) => {
|
||||||
|
if (val === "inherit") return {
|
||||||
|
fontFamily: "inherit"
|
||||||
|
};
|
||||||
const sizeProp = extras.props.size, fontSizeProp = extras.props.fontSize, size = sizeProp === "$true" && fontSizeProp ? fontSizeProp : extras.props.size || "$true";
|
const sizeProp = extras.props.size, fontSizeProp = extras.props.fontSize, size = sizeProp === "$true" && fontSizeProp ? fontSizeProp : extras.props.size || "$true";
|
||||||
return getFontSized(size, extras);
|
return getFontSized(size, extras);
|
||||||
}, "...")
|
}, "...")
|
||||||
|
|||||||
353
AGENTS.md
353
AGENTS.md
@@ -27,18 +27,20 @@ This repository hosts a multi-tenant event photo platform (Laravel 12, PHP 8.3,
|
|||||||
- Languages/Frameworks: PHP 8.2+ (Laravel 12), TypeScript/JavaScript (React 19/Vite 7/Tailwind 4), Filament 4.
|
- Languages/Frameworks: PHP 8.2+ (Laravel 12), TypeScript/JavaScript (React 19/Vite 7/Tailwind 4), Filament 4.
|
||||||
- Dev Commands: composer, npm, vite, artisan, PHPUnit, Pint/ESLint, Docker/Compose (for dev), Playwright, Vitest, TypeScript.
|
- Dev Commands: composer, npm, vite, artisan, PHPUnit, Pint/ESLint, Docker/Compose (for dev), Playwright, Vitest, TypeScript.
|
||||||
|
|
||||||
- Libraries: simplesoftwareio/simple-qrcode for server-side QR generation; Paddle API client (custom service) for payments; dompdf for PDF generation; spatie/laravel-translatable for i18n; minishlink/web-push for web push; firebase/php-jwt for JWT; Sentry (Laravel + Vite); Stripe (PHP + JS); Tamagui (design system); i18next (frontend i18n); vite-plugin-pwa for PWA builds.
|
- Libraries: simplesoftwareio/simple-qrcode for server-side QR generation; Lemon Squeezy API client (custom service) for payments; dompdf for PDF generation; spatie/laravel-translatable for i18n; minishlink/web-push for web push; firebase/php-jwt for JWT; Sentry (Laravel + Vite); Stripe (PHP + JS); Tamagui (design system); i18next (frontend i18n); vite-plugin-pwa for PWA builds.
|
||||||
- Payment Systems: Paddle (subscriptions and one-time payments), RevenueCat (mobile app subscriptions), Stripe (legacy/integration use).
|
- Payment Systems: Lemon Squeezy (subscriptions and one-time payments), RevenueCat (mobile app subscriptions), Stripe (legacy/integration use).
|
||||||
- PWA Technologies: React 19, Vite 7, Capacitor (iOS), Trusted Web Activity (Android), Service Workers, Background Sync.
|
- PWA Technologies: React 19, Vite 7, Capacitor (iOS), Trusted Web Activity (Android), Service Workers, Background Sync.
|
||||||
|
|
||||||
## Repo Structure (high-level)
|
## Repo Structure (high-level)
|
||||||
- docs/archive/prp/ — split PRP (authoritative). Start at docs/archive/prp/README.md.
|
- docs/archive/prp/ — split PRP (authoritative). Start at docs/archive/prp/README.md.
|
||||||
- docs/process/changes/ — session change logs.
|
- .beads/ — bd issue tracker data (source of truth for backlog and progress).
|
||||||
- docs/process/todo/ — prioritized backlog items (replaces single TODO.md file).
|
|
||||||
- resources/js/guest/ — Guest PWA source (React 19, offline-first, installable).
|
- resources/js/guest/ — Guest PWA source (React 19, offline-first, installable).
|
||||||
- resources/js/admin/ — Tenant Admin PWA source (React 19, Capacitor/TWA ready).
|
- resources/js/admin/ — Tenant Admin PWA source (React 19, Capacitor/TWA ready).
|
||||||
- resources/js/pages/ — Inertia pages (React).
|
- resources/js/pages/ — Inertia pages (React).
|
||||||
- docs/archive/README.md — historical PRP context.
|
- docs/archive/README.md — historical PRP context.
|
||||||
|
- Marketing frontend language files:
|
||||||
|
- Source translations: `resources/lang/{de,en}/marketing.php` and `resources/lang/{de,en}/marketing.json`.
|
||||||
|
- Runtime i18next JSON served to the frontend: `public/lang/{de,en}/marketing.json` (must stay in sync with the source files).
|
||||||
|
|
||||||
## Standard Workflows
|
## Standard Workflows
|
||||||
- Coding tasks (Codegen Agent):
|
- Coding tasks (Codegen Agent):
|
||||||
@@ -48,7 +50,7 @@ This repository hosts a multi-tenant event photo platform (Laravel 12, PHP 8.3,
|
|||||||
4) Update docs when public surfaces change (PRP, docs/*).
|
4) Update docs when public surfaces change (PRP, docs/*).
|
||||||
5) Propose follow-ups as Issues if out of scope.
|
5) Propose follow-ups as Issues if out of scope.
|
||||||
- Issue hygiene (Ops Agent):
|
- Issue hygiene (Ops Agent):
|
||||||
- Import docs/process/todo/ tasks as Issues with label TODO; group by Milestone (e.g., Now, Security & Compliance).
|
- Track backlog and follow-ups in bd; avoid duplicates by checking existing titles before creating new issues.
|
||||||
- Avoid duplicates by checking existing titles.
|
- Avoid duplicates by checking existing titles.
|
||||||
- Releases (Ops Agent):
|
- Releases (Ops Agent):
|
||||||
- Tag with semantic version; generate changelog from commits/PRs; ensure legal pages and migration notes are updated.
|
- Tag with semantic version; generate changelog from commits/PRs; ensure legal pages and migration notes are updated.
|
||||||
@@ -59,7 +61,7 @@ This repository hosts a multi-tenant event photo platform (Laravel 12, PHP 8.3,
|
|||||||
#### Billing & Packages
|
#### Billing & Packages
|
||||||
- package:check-status — check event package status.
|
- package:check-status — check event package status.
|
||||||
- packages:migrate-legacy — migrate legacy package purchases.
|
- packages:migrate-legacy — migrate legacy package purchases.
|
||||||
- paddle:sync-packages — sync packages with Paddle (push/pull/queue/dry-run).
|
- lemonsqueezy:sync-packages — sync packages with Lemon Squeezy (push/pull/queue/dry-run).
|
||||||
- coupons:export — export coupon redemptions.
|
- coupons:export — export coupon redemptions.
|
||||||
- checkout:send-reminders — send abandoned checkout reminders (dry-run supported).
|
- checkout:send-reminders — send abandoned checkout reminders (dry-run supported).
|
||||||
|
|
||||||
@@ -94,7 +96,7 @@ This repository hosts a multi-tenant event photo platform (Laravel 12, PHP 8.3,
|
|||||||
- metrics:package-limits — inspect/reset package limit metrics (routes/console.php).
|
- metrics:package-limits — inspect/reset package limit metrics (routes/console.php).
|
||||||
- inspire — inspiring quote (routes/console.php).
|
- inspire — inspiring quote (routes/console.php).
|
||||||
- Public APIs for Guest PWA: stats/photos endpoints with ETag; likes; uploads; see docs/archive/prp/03-api.md.
|
- Public APIs for Guest PWA: stats/photos endpoints with ETag; likes; uploads; see docs/archive/prp/03-api.md.
|
||||||
- Payment Integration: Paddle webhooks, RevenueCat mobile subscriptions.
|
- Payment Integration: Lemon Squeezy webhooks, RevenueCat mobile subscriptions.
|
||||||
|
|
||||||
## PWA Architecture
|
## PWA Architecture
|
||||||
- Guest PWA: Offline-first photo sharing app for event attendees (installable, background sync, no account required).
|
- Guest PWA: Offline-first photo sharing app for event attendees (installable, background sync, no account required).
|
||||||
@@ -130,7 +132,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
|
|||||||
## Foundational Context
|
## Foundational Context
|
||||||
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
|
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
|
||||||
|
|
||||||
- php - 8.3.24
|
- php - 8.3.6
|
||||||
- filament/filament (FILAMENT) - v4
|
- filament/filament (FILAMENT) - v4
|
||||||
- inertiajs/inertia-laravel (INERTIA) - v2
|
- inertiajs/inertia-laravel (INERTIA) - v2
|
||||||
- laravel/framework (LARAVEL) - v12
|
- laravel/framework (LARAVEL) - v12
|
||||||
@@ -152,7 +154,7 @@ This application is a Laravel application and its main Laravel ecosystems packag
|
|||||||
- prettier (PRETTIER) - v3
|
- prettier (PRETTIER) - v3
|
||||||
|
|
||||||
## Conventions
|
## Conventions
|
||||||
- You must follow all existing code conventions used in this application. When creating or editing a file, check sibling files for the correct structure, approach, naming.
|
- You must follow all existing code conventions used in this application. When creating or editing a file, check sibling files for the correct structure, approach, and naming.
|
||||||
- Use descriptive names for variables and methods. For example, `isRegisteredForDiscounts`, not `discount()`.
|
- Use descriptive names for variables and methods. For example, `isRegisteredForDiscounts`, not `discount()`.
|
||||||
- Check for existing components to reuse before writing a new one.
|
- Check for existing components to reuse before writing a new one.
|
||||||
|
|
||||||
@@ -160,7 +162,7 @@ This application is a Laravel application and its main Laravel ecosystems packag
|
|||||||
- Do not create verification scripts or tinker when tests cover that functionality and prove it works. Unit and feature tests are more important.
|
- Do not create verification scripts or tinker when tests cover that functionality and prove it works. Unit and feature tests are more important.
|
||||||
|
|
||||||
## Application Structure & Architecture
|
## Application Structure & Architecture
|
||||||
- Stick to existing directory structure - don't create new base folders without approval.
|
- Stick to existing directory structure; don't create new base folders without approval.
|
||||||
- Do not change the application's dependencies without approval.
|
- Do not change the application's dependencies without approval.
|
||||||
|
|
||||||
## Frontend Bundling
|
## Frontend Bundling
|
||||||
@@ -172,17 +174,16 @@ This application is a Laravel application and its main Laravel ecosystems packag
|
|||||||
## Documentation Files
|
## Documentation Files
|
||||||
- You must only create documentation files if explicitly requested by the user.
|
- You must only create documentation files if explicitly requested by the user.
|
||||||
|
|
||||||
|
|
||||||
=== boost rules ===
|
=== boost rules ===
|
||||||
|
|
||||||
## Laravel Boost
|
## Laravel Boost
|
||||||
- Laravel Boost is an MCP server that comes with powerful tools designed specifically for this application. Use them.
|
- Laravel Boost is an MCP server that comes with powerful tools designed specifically for this application. Use them.
|
||||||
|
|
||||||
## Artisan
|
## Artisan
|
||||||
- Use the `list-artisan-commands` tool when you need to call an Artisan command to double check the available parameters.
|
- Use the `list-artisan-commands` tool when you need to call an Artisan command to double-check the available parameters.
|
||||||
|
|
||||||
## URLs
|
## URLs
|
||||||
- Whenever you share a project URL with the user you should use the `get-absolute-url` tool to ensure you're using the correct scheme, domain / IP, and port.
|
- Whenever you share a project URL with the user, you should use the `get-absolute-url` tool to ensure you're using the correct scheme, domain/IP, and port.
|
||||||
|
|
||||||
## Tinker / Debugging
|
## Tinker / Debugging
|
||||||
- You should use the `tinker` tool when you need to execute PHP to debug code or query Eloquent models directly.
|
- You should use the `tinker` tool when you need to execute PHP to debug code or query Eloquent models directly.
|
||||||
@@ -193,22 +194,21 @@ This application is a Laravel application and its main Laravel ecosystems packag
|
|||||||
- Only recent browser logs will be useful - ignore old logs.
|
- Only recent browser logs will be useful - ignore old logs.
|
||||||
|
|
||||||
## Searching Documentation (Critically Important)
|
## Searching Documentation (Critically Important)
|
||||||
- Boost comes with a powerful `search-docs` tool you should use before any other approaches. This tool automatically passes a list of installed packages and their versions to the remote Boost API, so it returns only version-specific documentation specific for the user's circumstance. You should pass an array of packages to filter on if you know you need docs for particular packages.
|
- Boost comes with a powerful `search-docs` tool you should use before any other approaches when dealing with Laravel or Laravel ecosystem packages. This tool automatically passes a list of installed packages and their versions to the remote Boost API, so it returns only version-specific documentation for the user's circumstance. You should pass an array of packages to filter on if you know you need docs for particular packages.
|
||||||
- The 'search-docs' tool is perfect for all Laravel related packages, including Laravel, Inertia, Livewire, Filament, Tailwind, Pest, Nova, Nightwatch, etc.
|
- The `search-docs` tool is perfect for all Laravel-related packages, including Laravel, Inertia, Livewire, Filament, Tailwind, Pest, Nova, Nightwatch, etc.
|
||||||
- You must use this tool to search for Laravel-ecosystem documentation before falling back to other approaches.
|
- You must use this tool to search for Laravel ecosystem documentation before falling back to other approaches.
|
||||||
- Search the documentation before making code changes to ensure we are taking the correct approach.
|
- Search the documentation before making code changes to ensure we are taking the correct approach.
|
||||||
- Use multiple, broad, simple, topic based queries to start. For example: `['rate limiting', 'routing rate limiting', 'routing']`.
|
- Use multiple, broad, simple, topic-based queries to start. For example: `['rate limiting', 'routing rate limiting', 'routing']`.
|
||||||
- Do not add package names to queries - package information is already shared. For example, use `test resource table`, not `filament 4 test resource table`.
|
- Do not add package names to queries; package information is already shared. For example, use `test resource table`, not `filament 4 test resource table`.
|
||||||
|
|
||||||
### Available Search Syntax
|
### Available Search Syntax
|
||||||
- You can and should pass multiple queries at once. The most relevant results will be returned first.
|
- You can and should pass multiple queries at once. The most relevant results will be returned first.
|
||||||
|
|
||||||
1. Simple Word Searches with auto-stemming - query=authentication - finds 'authenticate' and 'auth'
|
1. Simple Word Searches with auto-stemming - query=authentication - finds 'authenticate' and 'auth'.
|
||||||
2. Multiple Words (AND Logic) - query=rate limit - finds knowledge containing both "rate" AND "limit"
|
2. Multiple Words (AND Logic) - query=rate limit - finds knowledge containing both "rate" AND "limit".
|
||||||
3. Quoted Phrases (Exact Position) - query="infinite scroll" - Words must be adjacent and in that order
|
3. Quoted Phrases (Exact Position) - query="infinite scroll" - words must be adjacent and in that order.
|
||||||
4. Mixed Queries - query=middleware "rate limit" - "middleware" AND exact phrase "rate limit"
|
4. Mixed Queries - query=middleware "rate limit" - "middleware" AND exact phrase "rate limit".
|
||||||
5. Multiple Queries - queries=["authentication", "middleware"] - ANY of these terms
|
5. Multiple Queries - queries=["authentication", "middleware"] - ANY of these terms.
|
||||||
|
|
||||||
|
|
||||||
=== php rules ===
|
=== php rules ===
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ This application is a Laravel application and its main Laravel ecosystems packag
|
|||||||
### Constructors
|
### Constructors
|
||||||
- Use PHP 8 constructor property promotion in `__construct()`.
|
- Use PHP 8 constructor property promotion in `__construct()`.
|
||||||
- <code-snippet>public function __construct(public GitHub $github) { }</code-snippet>
|
- <code-snippet>public function __construct(public GitHub $github) { }</code-snippet>
|
||||||
- Do not allow empty `__construct()` methods with zero parameters.
|
- Do not allow empty `__construct()` methods with zero parameters unless the constructor is private.
|
||||||
|
|
||||||
### Type Declarations
|
### Type Declarations
|
||||||
- Always use explicit return type declarations for methods and functions.
|
- Always use explicit return type declarations for methods and functions.
|
||||||
@@ -233,7 +233,7 @@ protected function isAccessible(User $user, ?string $path = null): bool
|
|||||||
</code-snippet>
|
</code-snippet>
|
||||||
|
|
||||||
## Comments
|
## Comments
|
||||||
- Prefer PHPDoc blocks over comments. Never use comments within the code itself unless there is something _very_ complex going on.
|
- Prefer PHPDoc blocks over inline comments. Never use comments within the code itself unless there is something very complex going on.
|
||||||
|
|
||||||
## PHPDoc Blocks
|
## PHPDoc Blocks
|
||||||
- Add useful array shape type definitions for arrays when appropriate.
|
- Add useful array shape type definitions for arrays when appropriate.
|
||||||
@@ -241,32 +241,22 @@ protected function isAccessible(User $user, ?string $path = null): bool
|
|||||||
## Enums
|
## Enums
|
||||||
- Typically, keys in an Enum should be TitleCase. For example: `FavoritePerson`, `BestLake`, `Monthly`.
|
- Typically, keys in an Enum should be TitleCase. For example: `FavoritePerson`, `BestLake`, `Monthly`.
|
||||||
|
|
||||||
|
|
||||||
=== herd rules ===
|
|
||||||
|
|
||||||
## Laravel Herd
|
|
||||||
|
|
||||||
- The application is served by Laravel Herd and will be available at: https?://[kebab-case-project-dir].test. Use the `get-absolute-url` tool to generate URLs for the user to ensure valid URLs.
|
|
||||||
- You must not run any commands to make the site available via HTTP(s). It is _always_ available through Laravel Herd.
|
|
||||||
|
|
||||||
|
|
||||||
=== tests rules ===
|
=== tests rules ===
|
||||||
|
|
||||||
## Test Enforcement
|
## Test Enforcement
|
||||||
|
|
||||||
- Every change must be programmatically tested. Write a new test or update an existing test, then run the affected tests to make sure they pass.
|
- Every change must be programmatically tested. Write a new test or update an existing test, then run the affected tests to make sure they pass.
|
||||||
- Run the minimum number of tests needed to ensure code quality and speed. Use `php artisan test` with a specific filename or filter.
|
- Run the minimum number of tests needed to ensure code quality and speed. Use `php artisan test --compact` with a specific filename or filter.
|
||||||
|
|
||||||
|
|
||||||
=== inertia-laravel/core rules ===
|
=== inertia-laravel/core rules ===
|
||||||
|
|
||||||
## Inertia Core
|
## Inertia
|
||||||
|
|
||||||
- Inertia.js components should be placed in the `resources/js/pages` directory unless specified differently in the JS bundler (vite.config.js).
|
- Inertia.js components should be placed in the `resources/js/Pages` directory unless specified differently in the JS bundler (`vite.config.js`).
|
||||||
- Use `Inertia::render()` for server-side routing instead of traditional Blade views.
|
- Use `Inertia::render()` for server-side routing instead of traditional Blade views.
|
||||||
- Use `search-docs` for accurate guidance on all things Inertia.
|
- Use the `search-docs` tool for accurate guidance on all things Inertia.
|
||||||
|
|
||||||
<code-snippet lang="php" name="Inertia::render Example">
|
<code-snippet name="Inertia Render Example" lang="php">
|
||||||
// routes/web.php example
|
// routes/web.php example
|
||||||
Route::get('/users', function () {
|
Route::get('/users', function () {
|
||||||
return Inertia::render('Users/Index', [
|
return Inertia::render('Users/Index', [
|
||||||
@@ -275,28 +265,26 @@ Route::get('/users', function () {
|
|||||||
});
|
});
|
||||||
</code-snippet>
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
=== inertia-laravel/v2 rules ===
|
=== inertia-laravel/v2 rules ===
|
||||||
|
|
||||||
## Inertia v2
|
## Inertia v2
|
||||||
|
|
||||||
- Make use of all Inertia features from v1 & v2. Check the documentation before making any changes to ensure we are taking the correct approach.
|
- Make use of all Inertia features from v1 and v2. Check the documentation before making any changes to ensure we are taking the correct approach.
|
||||||
|
|
||||||
### Inertia v2 New Features
|
### Inertia v2 New Features
|
||||||
- Polling
|
- Deferred props.
|
||||||
- Prefetching
|
- Infinite scrolling using merging props and `WhenVisible`.
|
||||||
- Deferred props
|
- Lazy loading data on scroll.
|
||||||
- Infinite scrolling using merging props and `WhenVisible`
|
- Polling.
|
||||||
- Lazy loading data on scroll
|
- Prefetching.
|
||||||
|
|
||||||
### Deferred Props & Empty States
|
### Deferred Props & Empty States
|
||||||
- When using deferred props on the frontend, you should add a nice empty state with pulsing / animated skeleton.
|
- When using deferred props on the frontend, you should add a nice empty state with pulsing/animated skeleton.
|
||||||
|
|
||||||
### Inertia Form General Guidance
|
### Inertia Form General Guidance
|
||||||
- The recommended way to build forms when using Inertia is with the `<Form>` component - a useful example is below. Use `search-docs` with a query of `form component` for guidance.
|
- The recommended way to build forms when using Inertia is with the `<Form>` component - a useful example is below. Use the `search-docs` tool with a query of `form component` for guidance.
|
||||||
- Forms can also be built using the `useForm` helper for more programmatic control, or to follow existing conventions. Use `search-docs` with a query of `useForm helper` for guidance.
|
- Forms can also be built using the `useForm` helper for more programmatic control, or to follow existing conventions. Use the `search-docs` tool with a query of `useForm helper` for guidance.
|
||||||
- `resetOnError`, `resetOnSuccess`, and `setDefaultsOnSuccess` are available on the `<Form>` component. Use `search-docs` with a query of 'form component resetting' for guidance.
|
- `resetOnError`, `resetOnSuccess`, and `setDefaultsOnSuccess` are available on the `<Form>` component. Use the `search-docs` tool with a query of `form component resetting` for guidance.
|
||||||
|
|
||||||
|
|
||||||
=== laravel/core rules ===
|
=== laravel/core rules ===
|
||||||
|
|
||||||
@@ -308,7 +296,7 @@ Route::get('/users', function () {
|
|||||||
|
|
||||||
### Database
|
### Database
|
||||||
- Always use proper Eloquent relationship methods with return type hints. Prefer relationship methods over raw queries or manual joins.
|
- Always use proper Eloquent relationship methods with return type hints. Prefer relationship methods over raw queries or manual joins.
|
||||||
- Use Eloquent models and relationships before suggesting raw database queries
|
- Use Eloquent models and relationships before suggesting raw database queries.
|
||||||
- Avoid `DB::`; prefer `Model::query()`. Generate code that leverages Laravel's ORM capabilities rather than bypassing them.
|
- Avoid `DB::`; prefer `Model::query()`. Generate code that leverages Laravel's ORM capabilities rather than bypassing them.
|
||||||
- Generate code that prevents N+1 query problems by using eager loading.
|
- Generate code that prevents N+1 query problems by using eager loading.
|
||||||
- Use Laravel's query builder for very complex database operations.
|
- Use Laravel's query builder for very complex database operations.
|
||||||
@@ -343,52 +331,56 @@ Route::get('/users', function () {
|
|||||||
### Vite Error
|
### Vite Error
|
||||||
- If you receive an "Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest" error, you can run `npm run build` or ask the user to run `npm run dev` or `composer run dev`.
|
- If you receive an "Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest" error, you can run `npm run build` or ask the user to run `npm run dev` or `composer run dev`.
|
||||||
|
|
||||||
|
|
||||||
=== laravel/v12 rules ===
|
=== laravel/v12 rules ===
|
||||||
|
|
||||||
## Laravel 12
|
## Laravel 12
|
||||||
|
|
||||||
- Use the `search-docs` tool to get version specific documentation.
|
- Use the `search-docs` tool to get version-specific documentation.
|
||||||
- This project upgraded from Laravel 10 without migrating to the new streamlined Laravel file structure.
|
- This project upgraded from Laravel 10 without migrating to the new streamlined Laravel file structure.
|
||||||
- This is **perfectly fine** and recommended by Laravel. Follow the existing structure from Laravel 10. We do not to need migrate to the new Laravel structure unless the user explicitly requests that.
|
- This is **perfectly fine** and recommended by Laravel. Follow the existing structure from Laravel 10. We do not need to migrate to the new Laravel structure unless the user explicitly requests it.
|
||||||
|
|
||||||
|
|
||||||
|
### Laravel 10 Structure
|
||||||
|
- Middleware typically lives in `app/Http/Middleware/` and service providers in `app/Providers/`.
|
||||||
|
- There is no `bootstrap/app.php` application configuration in a Laravel 10 structure:
|
||||||
|
- Middleware registration happens in `app/Http/Kernel.php`
|
||||||
|
- Exception handling is in `app/Exceptions/Handler.php`
|
||||||
|
- Console commands and schedule register in `app/Console/Kernel.php`
|
||||||
|
- Rate limits likely exist in `RouteServiceProvider` or `app/Http/Kernel.php`
|
||||||
|
|
||||||
### Database
|
### Database
|
||||||
- When modifying a column, the migration must include all of the attributes that were previously defined on the column. Otherwise, they will be dropped and lost.
|
- When modifying a column, the migration must include all of the attributes that were previously defined on the column. Otherwise, they will be dropped and lost.
|
||||||
- Laravel 11 allows limiting eagerly loaded records natively, without external packages: `$query->latest()->limit(10);`.
|
- Laravel 12 allows limiting eagerly loaded records natively, without external packages: `$query->latest()->limit(10);`.
|
||||||
|
|
||||||
### Models
|
### Models
|
||||||
- Casts can and likely should be set in a `casts()` method on a model rather than the `$casts` property. Follow existing conventions from other models.
|
- Casts can and likely should be set in a `casts()` method on a model rather than the `$casts` property. Follow existing conventions from other models.
|
||||||
|
|
||||||
|
|
||||||
=== wayfinder/core rules ===
|
=== wayfinder/core rules ===
|
||||||
|
|
||||||
## Laravel Wayfinder
|
## Laravel Wayfinder
|
||||||
|
|
||||||
Wayfinder generates TypeScript functions and types for Laravel controllers and routes which you can import into your client side code. It provides type safety and automatic synchronization between backend routes and frontend code.
|
Wayfinder generates TypeScript functions and types for Laravel controllers and routes which you can import into your client-side code. It provides type safety and automatic synchronization between backend routes and frontend code.
|
||||||
|
|
||||||
### Development Guidelines
|
### Development Guidelines
|
||||||
- Always use `search-docs` to check wayfinder correct usage before implementing any features.
|
- Always use the `search-docs` tool to check Wayfinder correct usage before implementing any features.
|
||||||
- Always Prefer named imports for tree-shaking (e.g., `import { show } from '@/actions/...'`)
|
- Always prefer named imports for tree-shaking (e.g., `import { show } from '@/actions/...'`).
|
||||||
- Avoid default controller imports (prevents tree-shaking)
|
- Avoid default controller imports (prevents tree-shaking).
|
||||||
- Run `php artisan wayfinder:generate` after route changes if Vite plugin isn't installed
|
- Run `php artisan wayfinder:generate` after route changes if Vite plugin isn't installed.
|
||||||
|
|
||||||
### Feature Overview
|
### Feature Overview
|
||||||
- Form Support: Use `.form()` with `--with-form` flag for HTML form attributes — `<form {...store.form()}>` → `action="/posts" method="post"`
|
- Form Support: Use `.form()` with `--with-form` flag for HTML form attributes — `<form {...store.form()}>` → `action="/posts" method="post"`.
|
||||||
- HTTP Methods: Call `.get()`, `.post()`, `.patch()`, `.put()`, `.delete()` for specific methods — `show.head(1)` → `{ url: "/posts/1", method: "head" }`
|
- HTTP Methods: Call `.get()`, `.post()`, `.patch()`, `.put()`, `.delete()` for specific methods — `show.head(1)` → `{ url: "/posts/1", method: "head" }`.
|
||||||
- Invokable Controllers: Import and invoke directly as functions. For example, `import StorePost from '@/actions/.../StorePostController'; StorePost()`
|
- Invokable Controllers: Import and invoke directly as functions. For example, `import StorePost from '@/actions/.../StorePostController'; StorePost()`.
|
||||||
- Named Routes: Import from `@/routes/` for non-controller routes. For example, `import { show } from '@/routes/post'; show(1)` for route name `post.show`
|
- Named Routes: Import from `@/routes/` for non-controller routes. For example, `import { show } from '@/routes/post'; show(1)` for route name `post.show`.
|
||||||
- Parameter Binding: Detects route keys (e.g., `{post:slug}`) and accepts matching object properties — `show("my-post")` or `show({ slug: "my-post" })`
|
- Parameter Binding: Detects route keys (e.g., `{post:slug}`) and accepts matching object properties — `show("my-post")` or `show({ slug: "my-post" })`.
|
||||||
- Query Merging: Use `mergeQuery` to merge with `window.location.search`, set values to `null` to remove — `show(1, { mergeQuery: { page: 2, sort: null } })`
|
- Query Merging: Use `mergeQuery` to merge with `window.location.search`, set values to `null` to remove — `show(1, { mergeQuery: { page: 2, sort: null } })`.
|
||||||
- Query Parameters: Pass `{ query: {...} }` in options to append params — `show(1, { query: { page: 1 } })` → `"/posts/1?page=1"`
|
- Query Parameters: Pass `{ query: {...} }` in options to append params — `show(1, { query: { page: 1 } })` → `"/posts/1?page=1"`.
|
||||||
- Route Objects: Functions return `{ url, method }` shaped objects — `show(1)` → `{ url: "/posts/1", method: "get" }`
|
- Route Objects: Functions return `{ url, method }` shaped objects — `show(1)` → `{ url: "/posts/1", method: "get" }`.
|
||||||
- URL Extraction: Use `.url()` to get URL string — `show.url(1)` → `"/posts/1"`
|
- URL Extraction: Use `.url()` to get URL string — `show.url(1)` → `"/posts/1"`.
|
||||||
|
|
||||||
### Example Usage
|
### Example Usage
|
||||||
|
|
||||||
<code-snippet name="Wayfinder Basic Usage" lang="typescript">
|
<code-snippet name="Wayfinder Basic Usage" lang="typescript">
|
||||||
// Import controller methods (tree-shakable)
|
// Import controller methods (tree-shakable)...
|
||||||
import { show, store, update } from '@/actions/App/Http/Controllers/PostController'
|
import { show, store, update } from '@/actions/App/Http/Controllers/PostController'
|
||||||
|
|
||||||
// Get route object with URL and method...
|
// Get route object with URL and method...
|
||||||
@@ -406,7 +398,6 @@ Wayfinder generates TypeScript functions and types for Laravel controllers and r
|
|||||||
postShow(1) // { url: "/posts/1", method: "get" }
|
postShow(1) // { url: "/posts/1", method: "get" }
|
||||||
</code-snippet>
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
### Wayfinder + Inertia
|
### Wayfinder + Inertia
|
||||||
If your application uses the `<Form>` component from Inertia, you can use Wayfinder to generate form action and method automatically.
|
If your application uses the `<Form>` component from Inertia, you can use Wayfinder to generate form action and method automatically.
|
||||||
<code-snippet name="Wayfinder Form Component (React)" lang="typescript">
|
<code-snippet name="Wayfinder Form Component (React)" lang="typescript">
|
||||||
@@ -415,14 +406,14 @@ If your application uses the `<Form>` component from Inertia, you can use Wayfin
|
|||||||
|
|
||||||
</code-snippet>
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
=== livewire/core rules ===
|
=== livewire/core rules ===
|
||||||
|
|
||||||
## Livewire Core
|
## Livewire
|
||||||
- Use the `search-docs` tool to find exact version specific documentation for how to write Livewire & Livewire tests.
|
|
||||||
- Use the `php artisan make:livewire [Posts\CreatePost]` artisan command to create new components
|
- Use the `search-docs` tool to find exact version-specific documentation for how to write Livewire and Livewire tests.
|
||||||
|
- Use the `php artisan make:livewire [Posts\CreatePost]` Artisan command to create new components.
|
||||||
- State should live on the server, with the UI reflecting it.
|
- State should live on the server, with the UI reflecting it.
|
||||||
- All Livewire requests hit the Laravel backend, they're like regular HTTP requests. Always validate form data, and run authorization checks in Livewire actions.
|
- All Livewire requests hit the Laravel backend; they're like regular HTTP requests. Always validate form data and run authorization checks in Livewire actions.
|
||||||
|
|
||||||
## Livewire Best Practices
|
## Livewire Best Practices
|
||||||
- Livewire components require a single root element.
|
- Livewire components require a single root element.
|
||||||
@@ -439,15 +430,14 @@ If your application uses the `<Form>` component from Inertia, you can use Wayfin
|
|||||||
|
|
||||||
- Prefer lifecycle hooks like `mount()`, `updatedFoo()` for initialization and reactive side effects:
|
- Prefer lifecycle hooks like `mount()`, `updatedFoo()` for initialization and reactive side effects:
|
||||||
|
|
||||||
<code-snippet name="Lifecycle hook examples" lang="php">
|
<code-snippet name="Lifecycle Hook Examples" lang="php">
|
||||||
public function mount(User $user) { $this->user = $user; }
|
public function mount(User $user) { $this->user = $user; }
|
||||||
public function updatedSearch() { $this->resetPage(); }
|
public function updatedSearch() { $this->resetPage(); }
|
||||||
</code-snippet>
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
## Testing Livewire
|
## Testing Livewire
|
||||||
|
|
||||||
<code-snippet name="Example Livewire component test" lang="php">
|
<code-snippet name="Example Livewire Component Test" lang="php">
|
||||||
Livewire::test(Counter::class)
|
Livewire::test(Counter::class)
|
||||||
->assertSet('count', 0)
|
->assertSet('count', 0)
|
||||||
->call('increment')
|
->call('increment')
|
||||||
@@ -456,19 +446,17 @@ If your application uses the `<Form>` component from Inertia, you can use Wayfin
|
|||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
</code-snippet>
|
</code-snippet>
|
||||||
|
|
||||||
|
<code-snippet name="Testing Livewire Component Exists on Page" lang="php">
|
||||||
<code-snippet name="Testing a Livewire component exists within a page" lang="php">
|
$this->get('/posts/create')
|
||||||
$this->get('/posts/create')
|
->assertSeeLivewire(CreatePost::class);
|
||||||
->assertSeeLivewire(CreatePost::class);
|
</code-snippet>
|
||||||
</code-snippet>
|
|
||||||
|
|
||||||
|
|
||||||
=== livewire/v3 rules ===
|
=== livewire/v3 rules ===
|
||||||
|
|
||||||
## Livewire 3
|
## Livewire 3
|
||||||
|
|
||||||
### Key Changes From Livewire 2
|
### Key Changes From Livewire 2
|
||||||
- These things changed in Livewire 2, but may not have been updated in this application. Verify this application's setup to ensure you conform with application conventions.
|
- These things changed in Livewire 3, but may not have been updated in this application. Verify this application's setup to ensure you conform with application conventions.
|
||||||
- Use `wire:model.live` for real-time updates, `wire:model` is now deferred by default.
|
- Use `wire:model.live` for real-time updates, `wire:model` is now deferred by default.
|
||||||
- Components now use the `App\Livewire` namespace (not `App\Http\Livewire`).
|
- Components now use the `App\Livewire` namespace (not `App\Http\Livewire`).
|
||||||
- Use `$this->dispatch()` to dispatch events (not `emit` or `dispatchBrowserEvent`).
|
- Use `$this->dispatch()` to dispatch events (not `emit` or `dispatchBrowserEvent`).
|
||||||
@@ -478,13 +466,13 @@ If your application uses the `<Form>` component from Inertia, you can use Wayfin
|
|||||||
- `wire:show`, `wire:transition`, `wire:cloak`, `wire:offline`, `wire:target` are available for use. Use the documentation to find usage examples.
|
- `wire:show`, `wire:transition`, `wire:cloak`, `wire:offline`, `wire:target` are available for use. Use the documentation to find usage examples.
|
||||||
|
|
||||||
### Alpine
|
### Alpine
|
||||||
- Alpine is now included with Livewire, don't manually include Alpine.js.
|
- Alpine is now included with Livewire; don't manually include Alpine.js.
|
||||||
- Plugins included with Alpine: persist, intersect, collapse, and focus.
|
- Plugins included with Alpine: persist, intersect, collapse, and focus.
|
||||||
|
|
||||||
### Lifecycle Hooks
|
### Lifecycle Hooks
|
||||||
- You can listen for `livewire:init` to hook into Livewire initialization, and `fail.status === 419` for the page expiring:
|
- You can listen for `livewire:init` to hook into Livewire initialization, and `fail.status === 419` for the page expiring:
|
||||||
|
|
||||||
<code-snippet name="livewire:load example" lang="js">
|
<code-snippet name="Livewire Init Hook Example" lang="js">
|
||||||
document.addEventListener('livewire:init', function () {
|
document.addEventListener('livewire:init', function () {
|
||||||
Livewire.hook('request', ({ fail }) => {
|
Livewire.hook('request', ({ fail }) => {
|
||||||
if (fail && fail.status === 419) {
|
if (fail && fail.status === 419) {
|
||||||
@@ -498,7 +486,6 @@ document.addEventListener('livewire:init', function () {
|
|||||||
});
|
});
|
||||||
</code-snippet>
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
=== pint/core rules ===
|
=== pint/core rules ===
|
||||||
|
|
||||||
## Laravel Pint Code Formatter
|
## Laravel Pint Code Formatter
|
||||||
@@ -506,24 +493,22 @@ document.addEventListener('livewire:init', function () {
|
|||||||
- You must run `vendor/bin/pint --dirty` before finalizing changes to ensure your code matches the project's expected style.
|
- You must run `vendor/bin/pint --dirty` before finalizing changes to ensure your code matches the project's expected style.
|
||||||
- Do not run `vendor/bin/pint --test`, simply run `vendor/bin/pint` to fix any formatting issues.
|
- Do not run `vendor/bin/pint --test`, simply run `vendor/bin/pint` to fix any formatting issues.
|
||||||
|
|
||||||
|
|
||||||
=== phpunit/core rules ===
|
=== phpunit/core rules ===
|
||||||
|
|
||||||
## PHPUnit Core
|
## PHPUnit
|
||||||
|
|
||||||
- This application uses PHPUnit for testing. All tests must be written as PHPUnit classes. Use `php artisan make:test --phpunit {name}` to create a new test.
|
- This application uses PHPUnit for testing. All tests must be written as PHPUnit classes. Use `php artisan make:test --phpunit {name}` to create a new test.
|
||||||
- If you see a test using "Pest", convert it to PHPUnit.
|
- If you see a test using "Pest", convert it to PHPUnit.
|
||||||
- Every time a test has been updated, run that singular test.
|
- Every time a test has been updated, run that singular test.
|
||||||
- When the tests relating to your feature are passing, ask the user if they would like to also run the entire test suite to make sure everything is still passing.
|
- When the tests relating to your feature are passing, ask the user if they would like to also run the entire test suite to make sure everything is still passing.
|
||||||
- Tests should test all of the happy paths, failure paths, and weird paths.
|
- Tests should test all of the happy paths, failure paths, and weird paths.
|
||||||
- You must not remove any tests or test files from the tests directory without approval. These are not temporary or helper files, these are core to the application.
|
- You must not remove any tests or test files from the tests directory without approval. These are not temporary or helper files; these are core to the application.
|
||||||
|
|
||||||
### Running Tests
|
### Running Tests
|
||||||
- Run the minimal number of tests, using an appropriate filter, before finalizing.
|
- Run the minimal number of tests, using an appropriate filter, before finalizing.
|
||||||
- To run all tests: `php artisan test`.
|
- To run all tests: `php artisan test --compact`.
|
||||||
- To run all tests in a file: `php artisan test tests/Feature/ExampleTest.php`.
|
- To run all tests in a file: `php artisan test --compact tests/Feature/ExampleTest.php`.
|
||||||
- To filter on a particular test name: `php artisan test --filter=testName` (recommended after making a change to a related file).
|
- To filter on a particular test name: `php artisan test --compact --filter=testName` (recommended after making a change to a related file).
|
||||||
|
|
||||||
|
|
||||||
=== inertia-react/core rules ===
|
=== inertia-react/core rules ===
|
||||||
|
|
||||||
@@ -538,10 +523,9 @@ import { Link } from '@inertiajs/react'
|
|||||||
|
|
||||||
</code-snippet>
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
=== inertia-react/v2/forms rules ===
|
=== inertia-react/v2/forms rules ===
|
||||||
|
|
||||||
## Inertia + React Forms
|
## Inertia v2 + React Forms
|
||||||
|
|
||||||
<code-snippet name="`<Form>` Component Example" lang="react">
|
<code-snippet name="`<Form>` Component Example" lang="react">
|
||||||
|
|
||||||
@@ -576,39 +560,37 @@ export default () => (
|
|||||||
|
|
||||||
</code-snippet>
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
=== tailwindcss/core rules ===
|
=== tailwindcss/core rules ===
|
||||||
|
|
||||||
## Tailwind Core
|
## Tailwind CSS
|
||||||
|
|
||||||
- Use Tailwind CSS classes to style HTML, check and use existing tailwind conventions within the project before writing your own.
|
- Use Tailwind CSS classes to style HTML; check and use existing Tailwind conventions within the project before writing your own.
|
||||||
- Offer to extract repeated patterns into components that match the project's conventions (i.e. Blade, JSX, Vue, etc..)
|
- Offer to extract repeated patterns into components that match the project's conventions (i.e. Blade, JSX, Vue, etc.).
|
||||||
- Think through class placement, order, priority, and defaults - remove redundant classes, add classes to parent or child carefully to limit repetition, group elements logically
|
- Think through class placement, order, priority, and defaults. Remove redundant classes, add classes to parent or child carefully to limit repetition, and group elements logically.
|
||||||
- You can use the `search-docs` tool to get exact examples from the official documentation when needed.
|
- You can use the `search-docs` tool to get exact examples from the official documentation when needed.
|
||||||
|
|
||||||
### Spacing
|
### Spacing
|
||||||
- When listing items, use gap utilities for spacing, don't use margins.
|
- When listing items, use gap utilities for spacing; don't use margins.
|
||||||
|
|
||||||
<code-snippet name="Valid Flex Gap Spacing Example" lang="html">
|
|
||||||
<div class="flex gap-8">
|
|
||||||
<div>Superior</div>
|
|
||||||
<div>Michigan</div>
|
|
||||||
<div>Erie</div>
|
|
||||||
</div>
|
|
||||||
</code-snippet>
|
|
||||||
|
|
||||||
|
<code-snippet name="Valid Flex Gap Spacing Example" lang="html">
|
||||||
|
<div class="flex gap-8">
|
||||||
|
<div>Superior</div>
|
||||||
|
<div>Michigan</div>
|
||||||
|
<div>Erie</div>
|
||||||
|
</div>
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
### Dark Mode
|
### Dark Mode
|
||||||
- If existing pages and components support dark mode, new pages and components must support dark mode in a similar way, typically using `dark:`.
|
- If existing pages and components support dark mode, new pages and components must support dark mode in a similar way, typically using `dark:`.
|
||||||
|
|
||||||
|
|
||||||
=== tailwindcss/v4 rules ===
|
=== tailwindcss/v4 rules ===
|
||||||
|
|
||||||
## Tailwind 4
|
## Tailwind CSS 4
|
||||||
|
|
||||||
- Always use Tailwind CSS v4 - do not use the deprecated utilities.
|
- Always use Tailwind CSS v4; do not use the deprecated utilities.
|
||||||
- `corePlugins` is not supported in Tailwind v4.
|
- `corePlugins` is not supported in Tailwind v4.
|
||||||
- In Tailwind v4, configuration is CSS-first using the `@theme` directive — no separate `tailwind.config.js` file is needed.
|
- In Tailwind v4, configuration is CSS-first using the `@theme` directive — no separate `tailwind.config.js` file is needed.
|
||||||
|
|
||||||
<code-snippet name="Extending Theme in CSS" lang="css">
|
<code-snippet name="Extending Theme in CSS" lang="css">
|
||||||
@theme {
|
@theme {
|
||||||
--color-brand: oklch(0.72 0.11 178);
|
--color-brand: oklch(0.72 0.11 178);
|
||||||
@@ -624,9 +606,8 @@ export default () => (
|
|||||||
+ @import "tailwindcss";
|
+ @import "tailwindcss";
|
||||||
</code-snippet>
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
### Replaced Utilities
|
### Replaced Utilities
|
||||||
- Tailwind v4 removed deprecated utilities. Do not use the deprecated option - use the replacement.
|
- Tailwind v4 removed deprecated utilities. Do not use the deprecated option; use the replacement.
|
||||||
- Opacity values are still numeric.
|
- Opacity values are still numeric.
|
||||||
|
|
||||||
| Deprecated | Replacement |
|
| Deprecated | Replacement |
|
||||||
@@ -642,6 +623,134 @@ export default () => (
|
|||||||
| overflow-ellipsis | text-ellipsis |
|
| overflow-ellipsis | text-ellipsis |
|
||||||
| decoration-slice | box-decoration-slice |
|
| decoration-slice | box-decoration-slice |
|
||||||
| decoration-clone | box-decoration-clone |
|
| decoration-clone | box-decoration-clone |
|
||||||
|
|
||||||
|
=== filament/filament rules ===
|
||||||
|
|
||||||
|
## Filament
|
||||||
|
|
||||||
|
- Filament is used by this application. Follow existing conventions for how and where it's implemented.
|
||||||
|
- Filament is a Server-Driven UI (SDUI) framework for Laravel that lets you define user interfaces in PHP using structured configuration objects. Built on Livewire, Alpine.js, and Tailwind CSS.
|
||||||
|
- Use the `search-docs` tool for official documentation on Artisan commands, code examples, testing, relationships, and idiomatic practices.
|
||||||
|
|
||||||
|
### Artisan
|
||||||
|
|
||||||
|
- Use Filament-specific Artisan commands to create files. Find them with `list-artisan-commands` or `php artisan --help`.
|
||||||
|
- Inspect required options and always pass `--no-interaction`.
|
||||||
|
|
||||||
|
### Patterns
|
||||||
|
|
||||||
|
Use static `make()` methods to initialize components. Most configuration methods accept a `Closure` for dynamic values.
|
||||||
|
|
||||||
|
Use `Get $get` to read other form field values for conditional logic:
|
||||||
|
|
||||||
|
<code-snippet name="Conditional form field" lang="php">
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
|
||||||
|
Select::make('type')
|
||||||
|
->options(CompanyType::class)
|
||||||
|
->required()
|
||||||
|
->live(),
|
||||||
|
|
||||||
|
TextInput::make('company_name')
|
||||||
|
->required()
|
||||||
|
->visible(fn (Get $get): bool => $get('type') === 'business'),
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
Use `state()` with a `Closure` to compute derived column values:
|
||||||
|
|
||||||
|
<code-snippet name="Computed table column" lang="php">
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
|
||||||
|
TextColumn::make('full_name')
|
||||||
|
->state(fn (User $record): string => "{$record->first_name} {$record->last_name}"),
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
Actions encapsulate a button with optional modal form and logic:
|
||||||
|
|
||||||
|
<code-snippet name="Action with modal form" lang="php">
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
|
||||||
|
Action::make('updateEmail')
|
||||||
|
->form([
|
||||||
|
TextInput::make('email')->email()->required(),
|
||||||
|
])
|
||||||
|
->action(fn (array $data, User $record): void => $record->update($data)),
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
Authenticate before testing panel functionality. Filament uses Livewire, so use `livewire()` or `Livewire::test()`:
|
||||||
|
|
||||||
|
<code-snippet name="Filament Table Test" lang="php">
|
||||||
|
livewire(ListUsers::class)
|
||||||
|
->assertCanSeeTableRecords($users)
|
||||||
|
->searchTable($users->first()->name)
|
||||||
|
->assertCanSeeTableRecords($users->take(1))
|
||||||
|
->assertCanNotSeeTableRecords($users->skip(1));
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
<code-snippet name="Filament Create Resource Test" lang="php">
|
||||||
|
livewire(CreateUser::class)
|
||||||
|
->fillForm([
|
||||||
|
'name' => 'Test',
|
||||||
|
'email' => 'test@example.com',
|
||||||
|
])
|
||||||
|
->call('create')
|
||||||
|
->assertNotified()
|
||||||
|
->assertRedirect();
|
||||||
|
|
||||||
|
assertDatabaseHas(User::class, [
|
||||||
|
'name' => 'Test',
|
||||||
|
'email' => 'test@example.com',
|
||||||
|
]);
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
<code-snippet name="Testing Validation" lang="php">
|
||||||
|
livewire(CreateUser::class)
|
||||||
|
->fillForm([
|
||||||
|
'name' => null,
|
||||||
|
'email' => 'invalid-email',
|
||||||
|
])
|
||||||
|
->call('create')
|
||||||
|
->assertHasFormErrors([
|
||||||
|
'name' => 'required',
|
||||||
|
'email' => 'email',
|
||||||
|
])
|
||||||
|
->assertNotNotified();
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
<code-snippet name="Calling Actions" lang="php">
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
|
use Filament\Actions\Testing\TestAction;
|
||||||
|
|
||||||
|
livewire(EditUser::class, ['record' => $user->id])
|
||||||
|
->callAction(DeleteAction::class)
|
||||||
|
->assertNotified()
|
||||||
|
->assertRedirect();
|
||||||
|
|
||||||
|
livewire(ListUsers::class)
|
||||||
|
->callAction(TestAction::make('promote')->table($user), [
|
||||||
|
'role' => 'admin',
|
||||||
|
])
|
||||||
|
->assertNotified();
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
### Common Mistakes
|
||||||
|
|
||||||
|
**Commonly Incorrect Namespaces:**
|
||||||
|
- Form fields (TextInput, Select, etc.): `Filament\Forms\Components\`
|
||||||
|
- Infolist entries (for read-only views) (TextEntry, IconEntry, etc.): `Filament\Forms\Components\`
|
||||||
|
- Layout components (Grid, Section, Fieldset, Tabs, Wizard, etc.): `Filament\Schemas\Components\`
|
||||||
|
- Schema utilities (Get, Set, etc.): `Filament\Schemas\Components\Utilities\`
|
||||||
|
- Actions: `Filament\Actions\` (no `Filament\Tables\Actions\` etc.)
|
||||||
|
- Icons: `Filament\Support\Icons\Heroicon` enum (e.g., `Heroicon::PencilSquare`)
|
||||||
|
|
||||||
|
**Recent breaking changes to Filament:**
|
||||||
|
- File visibility is `private` by default. Use `->visibility('public')` for public access.
|
||||||
|
- `Grid`, `Section`, and `Fieldset` no longer span all columns by default.
|
||||||
</laravel-boost-guidelines>
|
</laravel-boost-guidelines>
|
||||||
|
|
||||||
## Issue Tracking
|
## Issue Tracking
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ COPY . .
|
|||||||
COPY --from=vendor /var/www/html/vendor ./vendor
|
COPY --from=vendor /var/www/html/vendor ./vendor
|
||||||
COPY --from=node_builder /var/www/html/public/build ./public/build
|
COPY --from=node_builder /var/www/html/public/build ./public/build
|
||||||
|
|
||||||
|
RUN php artisan vendor:publish --tag=livewire:assets --force --no-interaction
|
||||||
|
|
||||||
RUN php artisan config:clear \
|
RUN php artisan config:clear \
|
||||||
&& php artisan config:cache \
|
&& php artisan config:cache \
|
||||||
&& php artisan route:clear \
|
&& php artisan route:clear \
|
||||||
|
|||||||
144
app/Console/Commands/AiEditsBackfillStorageCommand.php
Normal file
144
app/Console/Commands/AiEditsBackfillStorageCommand.php
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\AiEditOutput;
|
||||||
|
use App\Models\AiEditRequest;
|
||||||
|
use App\Services\AiEditing\AiEditOutputStorageService;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class AiEditsBackfillStorageCommand extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'ai-edits:backfill-storage
|
||||||
|
{--request-id= : Restrict backfill to one AI edit request id}
|
||||||
|
{--limit=200 : Maximum outputs to process}
|
||||||
|
{--pretend : Dry run without writing changes}';
|
||||||
|
|
||||||
|
protected $description = 'Backfill local storage paths for AI outputs that only have provider URLs.';
|
||||||
|
|
||||||
|
public function __construct(private readonly AiEditOutputStorageService $outputStorage)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$limit = max(1, (int) $this->option('limit'));
|
||||||
|
$requestId = $this->normalizeRequestId($this->option('request-id'));
|
||||||
|
$pretend = (bool) $this->option('pretend');
|
||||||
|
|
||||||
|
$query = AiEditOutput::query()
|
||||||
|
->with('request')
|
||||||
|
->whereNotNull('provider_url')
|
||||||
|
->where(function (Builder $builder): void {
|
||||||
|
$builder
|
||||||
|
->whereNull('storage_path')
|
||||||
|
->orWhere('storage_path', '');
|
||||||
|
})
|
||||||
|
->orderBy('id');
|
||||||
|
|
||||||
|
if ($requestId !== null) {
|
||||||
|
$query->where('request_id', $requestId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$candidateCount = (clone $query)->count();
|
||||||
|
$outputs = $query->limit($limit)->get();
|
||||||
|
|
||||||
|
if ($outputs->isEmpty()) {
|
||||||
|
$this->info('No AI outputs require storage backfill.');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->line(sprintf(
|
||||||
|
'AI output backfill candidates: %d (processing up to %d).',
|
||||||
|
$candidateCount,
|
||||||
|
$limit
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($pretend) {
|
||||||
|
$this->table(
|
||||||
|
['Output ID', 'Request ID', 'Provider URL'],
|
||||||
|
$outputs->map(static fn (AiEditOutput $output): array => [
|
||||||
|
(string) $output->id,
|
||||||
|
(string) $output->request_id,
|
||||||
|
(string) $output->provider_url,
|
||||||
|
])->all()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->info('Pretend mode enabled. No records were changed.');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
$processed = 0;
|
||||||
|
$stored = 0;
|
||||||
|
$failed = 0;
|
||||||
|
|
||||||
|
foreach ($outputs as $output) {
|
||||||
|
$processed++;
|
||||||
|
|
||||||
|
$request = $output->request;
|
||||||
|
if (! $request instanceof AiEditRequest) {
|
||||||
|
$failed++;
|
||||||
|
$this->warn(sprintf('Output %d skipped: missing request relation.', $output->id));
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$persisted = $this->outputStorage->persist($request, [
|
||||||
|
'provider_url' => $output->provider_url,
|
||||||
|
'provider_asset_id' => $output->provider_asset_id,
|
||||||
|
'storage_disk' => $output->storage_disk,
|
||||||
|
'storage_path' => $output->storage_path,
|
||||||
|
'mime_type' => $output->mime_type,
|
||||||
|
'width' => $output->width,
|
||||||
|
'height' => $output->height,
|
||||||
|
'bytes' => $output->bytes,
|
||||||
|
'checksum' => $output->checksum,
|
||||||
|
'metadata' => $output->metadata,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$output->forceFill([
|
||||||
|
'provider_url' => $persisted['provider_url'] ?? $output->provider_url,
|
||||||
|
'storage_disk' => $persisted['storage_disk'] ?? $output->storage_disk,
|
||||||
|
'storage_path' => $persisted['storage_path'] ?? $output->storage_path,
|
||||||
|
'mime_type' => $persisted['mime_type'] ?? $output->mime_type,
|
||||||
|
'width' => array_key_exists('width', $persisted) ? $persisted['width'] : $output->width,
|
||||||
|
'height' => array_key_exists('height', $persisted) ? $persisted['height'] : $output->height,
|
||||||
|
'bytes' => array_key_exists('bytes', $persisted) ? $persisted['bytes'] : $output->bytes,
|
||||||
|
'checksum' => $persisted['checksum'] ?? $output->checksum,
|
||||||
|
'metadata' => is_array($persisted['metadata'] ?? null) ? $persisted['metadata'] : $output->metadata,
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
$storagePath = trim((string) ($output->storage_path ?? ''));
|
||||||
|
if ($storagePath !== '') {
|
||||||
|
$stored++;
|
||||||
|
} else {
|
||||||
|
$failed++;
|
||||||
|
$this->warn(sprintf('Output %d could not be persisted locally.', $output->id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info(sprintf(
|
||||||
|
'AI output backfill complete: processed=%d stored=%d failed=%d.',
|
||||||
|
$processed,
|
||||||
|
$stored,
|
||||||
|
$failed
|
||||||
|
));
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function normalizeRequestId(mixed $value): ?int
|
||||||
|
{
|
||||||
|
if (! is_numeric($value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$requestId = (int) $value;
|
||||||
|
|
||||||
|
return $requestId > 0 ? $requestId : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
69
app/Console/Commands/AiEditsPruneCommand.php
Normal file
69
app/Console/Commands/AiEditsPruneCommand.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\AiEditRequest;
|
||||||
|
use App\Models\AiUsageLedger;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class AiEditsPruneCommand extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'ai-edits:prune
|
||||||
|
{--request-days= : Override AI request retention days}
|
||||||
|
{--ledger-days= : Override usage ledger retention days}
|
||||||
|
{--pretend : Report counts without deleting data}';
|
||||||
|
|
||||||
|
protected $description = 'Prune stale AI edit requests and usage ledgers based on retention settings.';
|
||||||
|
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$requestRetentionDays = max(1, (int) ($this->option('request-days') ?: config('ai-editing.retention.request_days', 90)));
|
||||||
|
$ledgerRetentionDays = max(1, (int) ($this->option('ledger-days') ?: config('ai-editing.retention.usage_ledger_days', 365)));
|
||||||
|
$pretend = (bool) $this->option('pretend');
|
||||||
|
|
||||||
|
$requestCutoff = now()->subDays($requestRetentionDays);
|
||||||
|
$ledgerCutoff = now()->subDays($ledgerRetentionDays);
|
||||||
|
|
||||||
|
$requestQuery = AiEditRequest::query()
|
||||||
|
->where(function (Builder $query) use ($requestCutoff): void {
|
||||||
|
$query->where(function (Builder $completedQuery) use ($requestCutoff): void {
|
||||||
|
$completedQuery->whereNotNull('completed_at')
|
||||||
|
->where('completed_at', '<=', $requestCutoff);
|
||||||
|
})->orWhere(function (Builder $expiredQuery): void {
|
||||||
|
$expiredQuery->whereNotNull('expires_at')
|
||||||
|
->where('expires_at', '<=', now());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$ledgerQuery = AiUsageLedger::query()
|
||||||
|
->where('recorded_at', '<=', $ledgerCutoff);
|
||||||
|
|
||||||
|
$requestCount = (clone $requestQuery)->count();
|
||||||
|
$ledgerCount = (clone $ledgerQuery)->count();
|
||||||
|
|
||||||
|
$this->line(sprintf(
|
||||||
|
'AI prune candidates -> requests: %d (<= %s), ledgers: %d (<= %s)',
|
||||||
|
$requestCount,
|
||||||
|
$requestCutoff->toDateString(),
|
||||||
|
$ledgerCount,
|
||||||
|
$ledgerCutoff->toDateString()
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($pretend) {
|
||||||
|
$this->info('Pretend mode enabled. No records were deleted.');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
$deletedRequests = $requestQuery->delete();
|
||||||
|
$deletedLedgers = $ledgerQuery->delete();
|
||||||
|
|
||||||
|
$this->info(sprintf(
|
||||||
|
'Pruned AI data -> requests: %d, ledgers: %d.',
|
||||||
|
$deletedRequests,
|
||||||
|
$deletedLedgers
|
||||||
|
));
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
179
app/Console/Commands/AiEditsRecoverStuckCommand.php
Normal file
179
app/Console/Commands/AiEditsRecoverStuckCommand.php
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Jobs\PollAiEditRequest;
|
||||||
|
use App\Jobs\ProcessAiEditRequest;
|
||||||
|
use App\Models\AiEditRequest;
|
||||||
|
use App\Services\AiEditing\AiEditingRuntimeConfig;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class AiEditsRecoverStuckCommand extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'ai-edits:recover-stuck
|
||||||
|
{--minutes=30 : Minimum age in minutes for queued/processing requests}
|
||||||
|
{--requeue : Re-dispatch stuck requests back to the queue}
|
||||||
|
{--fail : Mark stuck requests as failed}';
|
||||||
|
|
||||||
|
protected $description = 'Inspect stuck AI edit requests and optionally recover them by requeueing or failing.';
|
||||||
|
|
||||||
|
public function __construct(private readonly AiEditingRuntimeConfig $runtimeConfig)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$minutes = max(1, (int) $this->option('minutes'));
|
||||||
|
$shouldRequeue = (bool) $this->option('requeue');
|
||||||
|
$shouldFail = (bool) $this->option('fail');
|
||||||
|
|
||||||
|
if ($shouldRequeue && $shouldFail) {
|
||||||
|
$this->error('Use either --requeue or --fail, not both.');
|
||||||
|
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cutoff = now()->subMinutes($minutes);
|
||||||
|
$requests = AiEditRequest::query()
|
||||||
|
->with([
|
||||||
|
'event:id,slug,name',
|
||||||
|
'providerRuns' => function (HasMany $query): void {
|
||||||
|
$query->select(['id', 'request_id', 'provider_task_id', 'attempt'])
|
||||||
|
->orderByDesc('attempt');
|
||||||
|
},
|
||||||
|
])
|
||||||
|
->whereIn('status', [AiEditRequest::STATUS_QUEUED, AiEditRequest::STATUS_PROCESSING])
|
||||||
|
->where(function (Builder $query) use ($cutoff): void {
|
||||||
|
$query
|
||||||
|
->where(function (Builder $queuedQuery) use ($cutoff): void {
|
||||||
|
$queuedQuery->whereNull('started_at')
|
||||||
|
->whereNotNull('queued_at')
|
||||||
|
->where('queued_at', '<=', $cutoff);
|
||||||
|
})
|
||||||
|
->orWhere(function (Builder $processingQuery) use ($cutoff): void {
|
||||||
|
$processingQuery->whereNotNull('started_at')
|
||||||
|
->where('started_at', '<=', $cutoff);
|
||||||
|
})
|
||||||
|
->orWhere(function (Builder $fallbackQuery) use ($cutoff): void {
|
||||||
|
$fallbackQuery->whereNull('queued_at')
|
||||||
|
->whereNull('started_at')
|
||||||
|
->where('updated_at', '<=', $cutoff);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->orderBy('updated_at')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($requests->isEmpty()) {
|
||||||
|
$this->info(sprintf('No stuck AI edit requests older than %d minute(s).', $minutes));
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->table(
|
||||||
|
['ID', 'Event', 'Status', 'Queued/Started', 'Latest task'],
|
||||||
|
$requests->map(function (AiEditRequest $request): array {
|
||||||
|
$latestTaskId = $this->latestProviderTaskId($request) ?? '-';
|
||||||
|
$eventLabel = (string) ($request->event?->name ?: $request->event?->slug ?: $request->event_id);
|
||||||
|
$ageSource = $request->started_at ?: $request->queued_at ?: $request->updated_at;
|
||||||
|
|
||||||
|
return [
|
||||||
|
(string) $request->id,
|
||||||
|
$eventLabel,
|
||||||
|
$request->status,
|
||||||
|
$ageSource?->toIso8601String() ?? '-',
|
||||||
|
$latestTaskId,
|
||||||
|
];
|
||||||
|
})->all()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (! $shouldRequeue && ! $shouldFail) {
|
||||||
|
$this->info('Dry-run only. Use --requeue to dispatch recovery jobs or --fail to terminate stuck requests.');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($shouldFail) {
|
||||||
|
$count = $this->markAsFailed($requests);
|
||||||
|
$this->info(sprintf('Marked %d AI edit request(s) as failed.', $count));
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
[$processDispatches, $pollDispatches] = $this->requeueRequests($requests);
|
||||||
|
$this->info(sprintf(
|
||||||
|
'Recovered %d stuck AI edit request(s): %d process dispatch(es), %d poll dispatch(es).',
|
||||||
|
$processDispatches + $pollDispatches,
|
||||||
|
$processDispatches,
|
||||||
|
$pollDispatches
|
||||||
|
));
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{0:int,1:int}
|
||||||
|
*/
|
||||||
|
private function requeueRequests(Collection $requests): array
|
||||||
|
{
|
||||||
|
$queueName = $this->runtimeConfig->queueName();
|
||||||
|
$processDispatches = 0;
|
||||||
|
$pollDispatches = 0;
|
||||||
|
|
||||||
|
foreach ($requests as $request) {
|
||||||
|
if ($request->status === AiEditRequest::STATUS_QUEUED) {
|
||||||
|
ProcessAiEditRequest::dispatch($request->id)->onQueue($queueName);
|
||||||
|
$processDispatches++;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$providerTaskId = $this->latestProviderTaskId($request);
|
||||||
|
if ($providerTaskId !== null) {
|
||||||
|
PollAiEditRequest::dispatch($request->id, $providerTaskId, 1)->onQueue($queueName);
|
||||||
|
$pollDispatches++;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessAiEditRequest::dispatch($request->id)->onQueue($queueName);
|
||||||
|
$processDispatches++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$processDispatches, $pollDispatches];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function markAsFailed(Collection $requests): int
|
||||||
|
{
|
||||||
|
$updated = 0;
|
||||||
|
$now = now();
|
||||||
|
|
||||||
|
foreach ($requests as $request) {
|
||||||
|
$request->forceFill([
|
||||||
|
'status' => AiEditRequest::STATUS_FAILED,
|
||||||
|
'failure_code' => 'operator_recovery_marked_failed',
|
||||||
|
'failure_message' => 'Marked as failed by ai-edits:recover-stuck.',
|
||||||
|
'completed_at' => $now,
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
$updated++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function latestProviderTaskId(AiEditRequest $request): ?string
|
||||||
|
{
|
||||||
|
foreach ($request->providerRuns as $run) {
|
||||||
|
$taskId = trim((string) ($run->provider_task_id ?? ''));
|
||||||
|
if ($taskId !== '') {
|
||||||
|
return $taskId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,6 @@ use App\Models\Tenant;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Console\Attributes\AsCommand;
|
use Illuminate\Console\Attributes\AsCommand;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
#[AsCommand(name: 'tenant:attach-demo-event')]
|
#[AsCommand(name: 'tenant:attach-demo-event')]
|
||||||
class AttachDemoEvent extends Command
|
class AttachDemoEvent extends Command
|
||||||
@@ -25,10 +24,12 @@ class AttachDemoEvent extends Command
|
|||||||
{
|
{
|
||||||
if (! \Illuminate\Support\Facades\Schema::hasTable('events')) {
|
if (! \Illuminate\Support\Facades\Schema::hasTable('events')) {
|
||||||
$this->error("Table 'events' does not exist. Run: php artisan migrate");
|
$this->error("Table 'events' does not exist. Run: php artisan migrate");
|
||||||
|
|
||||||
return self::FAILURE;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
if (! \Illuminate\Support\Facades\Schema::hasColumn('events', 'tenant_id')) {
|
if (! \Illuminate\Support\Facades\Schema::hasColumn('events', 'tenant_id')) {
|
||||||
$this->error("Column 'events.tenant_id' does not exist. Add it and rerun. Suggested: create a migration to add a nullable foreignId to tenants.");
|
$this->error("Column 'events.tenant_id' does not exist. Add it and rerun. Suggested: create a migration to add a nullable foreignId to tenants.");
|
||||||
|
|
||||||
return self::FAILURE;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
$tenant = null;
|
$tenant = null;
|
||||||
@@ -45,6 +46,7 @@ class AttachDemoEvent extends Command
|
|||||||
}
|
}
|
||||||
if (! $tenant) {
|
if (! $tenant) {
|
||||||
$this->error('Tenant not found. Provide --tenant-slug or a user with tenant_id via --tenant-email.');
|
$this->error('Tenant not found. Provide --tenant-slug or a user with tenant_id via --tenant-email.');
|
||||||
|
|
||||||
return self::FAILURE;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,12 +69,14 @@ class AttachDemoEvent extends Command
|
|||||||
|
|
||||||
if (! $event) {
|
if (! $event) {
|
||||||
$this->error('Event not found. Provide --event-id or --event-slug.');
|
$this->error('Event not found. Provide --event-id or --event-slug.');
|
||||||
|
|
||||||
return self::FAILURE;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Idempotent update
|
// Idempotent update
|
||||||
if ((int) $event->tenant_id === (int) $tenant->id) {
|
if ((int) $event->tenant_id === (int) $tenant->id) {
|
||||||
$this->info("Event #{$event->id} already attached to tenant #{$tenant->id} ({$tenant->slug}).");
|
$this->info("Event #{$event->id} already attached to tenant #{$tenant->id} ({$tenant->slug}).");
|
||||||
|
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +84,7 @@ class AttachDemoEvent extends Command
|
|||||||
$event->save();
|
$event->save();
|
||||||
|
|
||||||
$this->info("Attached event #{$event->id} ({$event->slug}) to tenant #{$tenant->id} ({$tenant->slug}).");
|
$this->info("Attached event #{$event->id} ({$event->slug}) to tenant #{$tenant->id} ({$tenant->slug}).");
|
||||||
|
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,22 +10,27 @@ use Illuminate\Support\Facades\Storage;
|
|||||||
class BackfillThumbnails extends Command
|
class BackfillThumbnails extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'media:backfill-thumbnails {--limit=500}';
|
protected $signature = 'media:backfill-thumbnails {--limit=500}';
|
||||||
|
|
||||||
protected $description = 'Generate thumbnails for photos missing thumbnail_path or where thumbnail equals original.';
|
protected $description = 'Generate thumbnails for photos missing thumbnail_path or where thumbnail equals original.';
|
||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$limit = (int) $this->option('limit');
|
$limit = (int) $this->option('limit');
|
||||||
$rows = DB::table('photos')
|
$rows = DB::table('photos')
|
||||||
->select(['id','event_id','file_path','thumbnail_path'])
|
->select(['id', 'event_id', 'file_path', 'thumbnail_path'])
|
||||||
->orderBy('id')
|
->orderBy('id')
|
||||||
->limit($limit)
|
->limit($limit)
|
||||||
->get();
|
->get();
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($rows as $r) {
|
foreach ($rows as $r) {
|
||||||
$orig = $this->relativeFromUrl((string)$r->file_path);
|
$orig = $this->relativeFromUrl((string) $r->file_path);
|
||||||
$thumb = (string)($r->thumbnail_path ?? '');
|
$thumb = (string) ($r->thumbnail_path ?? '');
|
||||||
if ($thumb && $thumb !== $r->file_path) continue; // already set to different thumb
|
if ($thumb && $thumb !== $r->file_path) {
|
||||||
if (! $orig) continue;
|
continue;
|
||||||
|
} // already set to different thumb
|
||||||
|
if (! $orig) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$baseName = pathinfo($orig, PATHINFO_FILENAME);
|
$baseName = pathinfo($orig, PATHINFO_FILENAME);
|
||||||
$destRel = "events/{$r->event_id}/photos/thumbs/{$baseName}_thumb.jpg";
|
$destRel = "events/{$r->event_id}/photos/thumbs/{$baseName}_thumb.jpg";
|
||||||
$made = ImageHelper::makeThumbnailOnDisk('public', $orig, $destRel, 640, 82);
|
$made = ImageHelper::makeThumbnailOnDisk('public', $orig, $destRel, 640, 82);
|
||||||
@@ -39,6 +44,7 @@ class BackfillThumbnails extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->info("Done. Thumbnails generated: {$count}");
|
$this->info("Done. Thumbnails generated: {$count}");
|
||||||
|
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +55,7 @@ class BackfillThumbnails extends Command
|
|||||||
if (str_starts_with($p, '/storage/')) {
|
if (str_starts_with($p, '/storage/')) {
|
||||||
return substr($p, strlen('/storage/'));
|
return substr($p, strlen('/storage/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Console\Commands;
|
|||||||
use App\Console\Concerns\InteractsWithCacheLocks;
|
use App\Console\Concerns\InteractsWithCacheLocks;
|
||||||
use App\Jobs\ArchiveEventMediaAssets;
|
use App\Jobs\ArchiveEventMediaAssets;
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
|
use App\Services\Compliance\RetentionOverrideService;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Contracts\Cache\Lock;
|
use Illuminate\Contracts\Cache\Lock;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@@ -37,6 +38,7 @@ class DispatchStorageArchiveCommand extends Command
|
|||||||
$maxDispatch = max(1, (int) config('storage-monitor.archive.max_dispatch', 100));
|
$maxDispatch = max(1, (int) config('storage-monitor.archive.max_dispatch', 100));
|
||||||
$eventId = $this->option('event');
|
$eventId = $this->option('event');
|
||||||
$dispatched = 0;
|
$dispatched = 0;
|
||||||
|
$overrides = app(RetentionOverrideService::class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$query = Event::query()
|
$query = Event::query()
|
||||||
@@ -57,12 +59,16 @@ class DispatchStorageArchiveCommand extends Command
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$query->chunkById($chunkSize, function ($events) use (&$dispatched, $maxDispatch, $eventLockTtl) {
|
$query->chunkById($chunkSize, function ($events) use (&$dispatched, $maxDispatch, $eventLockTtl, $overrides) {
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
if ($dispatched >= $maxDispatch) {
|
if ($dispatched >= $maxDispatch) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($overrides->eventOnHold($event)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$eventLock = $this->acquireCommandLock('storage:archive-event-'.$event->id, $eventLockTtl);
|
$eventLock = $this->acquireCommandLock('storage:archive-event-'.$event->id, $eventLockTtl);
|
||||||
if ($eventLock === false) {
|
if ($eventLock === false) {
|
||||||
Log::channel('storage-jobs')->info('Archive dispatch skipped due to in-flight lock', [
|
Log::channel('storage-jobs')->info('Archive dispatch skipped due to in-flight lock', [
|
||||||
|
|||||||
40
app/Console/Commands/DispatchTenantAnnouncements.php
Normal file
40
app/Console/Commands/DispatchTenantAnnouncements.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Services\TenantAnnouncements\TenantAnnouncementService;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class DispatchTenantAnnouncements extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'tenant-announcements:dispatch';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Dispatch scheduled tenant announcements and queue email notifications';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(TenantAnnouncementService $service): int
|
||||||
|
{
|
||||||
|
$result = $service->process();
|
||||||
|
|
||||||
|
$this->info(sprintf(
|
||||||
|
'Announcements: %d activated, %d archived, %d emails queued.',
|
||||||
|
$result['activated'],
|
||||||
|
$result['archived'],
|
||||||
|
$result['queued'],
|
||||||
|
));
|
||||||
|
|
||||||
|
return Command::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
130
app/Console/Commands/LemonSqueezyRegisterWebhooks.php
Normal file
130
app/Console/Commands/LemonSqueezyRegisterWebhooks.php
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Services\LemonSqueezy\LemonSqueezyClient;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class LemonSqueezyRegisterWebhooks extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'lemonsqueezy:webhooks:register
|
||||||
|
{--url= : Destination URL for Lemon Squeezy webhooks}
|
||||||
|
{--events=* : Override event types to subscribe}
|
||||||
|
{--secret= : Override the webhook signing secret}
|
||||||
|
{--test-mode : Register the webhook in test mode}
|
||||||
|
{--dry-run : Output payload without creating the destination}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Register Lemon Squeezy webhook notification settings.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(LemonSqueezyClient $client): int
|
||||||
|
{
|
||||||
|
$destination = (string) ($this->option('url') ?: $this->defaultWebhookUrl());
|
||||||
|
|
||||||
|
if ($destination === '') {
|
||||||
|
$this->error('Webhook destination URL is required. Use --url=...');
|
||||||
|
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$events = collect((array) $this->option('events'))
|
||||||
|
->filter()
|
||||||
|
->map(fn ($event) => trim((string) $event))
|
||||||
|
->filter()
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
|
||||||
|
if ($events === []) {
|
||||||
|
$events = config('lemonsqueezy.webhook_events', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($events === [] || ! is_array($events)) {
|
||||||
|
$this->error('No webhook events configured. Set config(lemonsqueezy.webhook_events) or pass --events.');
|
||||||
|
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$secret = (string) ($this->option('secret') ?: config('lemonsqueezy.webhook_secret'));
|
||||||
|
if ($secret === '') {
|
||||||
|
$this->error('Webhook signing secret is required. Set LEMONSQUEEZY_WEBHOOK_SECRET or pass --secret.');
|
||||||
|
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$storeId = (string) config('lemonsqueezy.store_id');
|
||||||
|
if ($storeId === '') {
|
||||||
|
$this->error('Lemon Squeezy store id is required. Set LEMONSQUEEZY_STORE_ID.');
|
||||||
|
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$testMode = (bool) $this->option('test-mode') || (bool) config('lemonsqueezy.test_mode', false);
|
||||||
|
|
||||||
|
$attributes = array_filter([
|
||||||
|
'url' => $destination,
|
||||||
|
'events' => $events,
|
||||||
|
'secret' => $secret,
|
||||||
|
'test_mode' => $testMode ? true : null,
|
||||||
|
], static fn ($value) => $value !== null && $value !== '');
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'data' => [
|
||||||
|
'type' => 'webhooks',
|
||||||
|
'attributes' => $attributes,
|
||||||
|
'relationships' => [
|
||||||
|
'store' => [
|
||||||
|
'data' => [
|
||||||
|
'type' => 'stores',
|
||||||
|
'id' => $storeId,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ((bool) $this->option('dry-run')) {
|
||||||
|
$this->line(json_encode($payload, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $client->post('/webhooks', $payload);
|
||||||
|
$data = Arr::get($response, 'data', $response);
|
||||||
|
$id = Arr::get($data, 'id');
|
||||||
|
|
||||||
|
Log::channel('lemonsqueezy-sync')->info('Lemon Squeezy webhook registered', [
|
||||||
|
'webhook_id' => $id,
|
||||||
|
'destination' => $destination,
|
||||||
|
'test_mode' => $testMode,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->info('Lemon Squeezy webhook registered.');
|
||||||
|
|
||||||
|
if ($id) {
|
||||||
|
$this->line('ID: '.$id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function defaultWebhookUrl(): string
|
||||||
|
{
|
||||||
|
$base = rtrim((string) config('app.url'), '/');
|
||||||
|
|
||||||
|
return $base !== '' ? $base.'/lemonsqueezy/webhook' : '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,22 +2,23 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Jobs\PullPackageFromPaddle;
|
use App\Jobs\PullPackageFromLemonSqueezy;
|
||||||
use App\Jobs\SyncPackageToPaddle;
|
use App\Jobs\SyncPackageToLemonSqueezy;
|
||||||
use App\Models\Package;
|
use App\Models\Package;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class PaddleSyncPackages extends Command
|
class LemonSqueezySyncPackages extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'paddle:sync-packages
|
protected $signature = 'lemonsqueezy:sync-packages
|
||||||
{--package=* : Limit sync to the given package IDs or slugs}
|
{--package=* : Limit sync to the given package IDs or slugs}
|
||||||
{--dry-run : Generate payload snapshots without calling Paddle}
|
{--dry-run : Generate payload snapshots without calling Lemon Squeezy}
|
||||||
{--pull : Fetch remote Paddle state instead of pushing local changes}
|
{--pull : Fetch remote Lemon Squeezy state instead of pushing local changes}
|
||||||
|
{--allow-unmapped : Allow sync when packages are missing Lemon Squeezy product/variant IDs}
|
||||||
{--queue : Dispatch jobs onto the queue instead of running synchronously}';
|
{--queue : Dispatch jobs onto the queue instead of running synchronously}';
|
||||||
|
|
||||||
protected $description = 'Synchronise local packages with Paddle products and prices.';
|
protected $description = 'Synchronise local packages with Lemon Squeezy products and variants.';
|
||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
@@ -32,6 +33,13 @@ class PaddleSyncPackages extends Command
|
|||||||
$dryRun = (bool) $this->option('dry-run');
|
$dryRun = (bool) $this->option('dry-run');
|
||||||
$pull = (bool) $this->option('pull');
|
$pull = (bool) $this->option('pull');
|
||||||
$queue = (bool) $this->option('queue');
|
$queue = (bool) $this->option('queue');
|
||||||
|
$allowUnmapped = (bool) $this->option('allow-unmapped');
|
||||||
|
|
||||||
|
if (! $pull && ! $allowUnmapped && ! $this->hasPackageFilter()) {
|
||||||
|
if (! $this->guardUnmappedPackages($packages)) {
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$packages->each(function (Package $package) use ($dryRun, $pull, $queue) {
|
$packages->each(function (Package $package) use ($dryRun, $pull, $queue) {
|
||||||
if ($pull) {
|
if ($pull) {
|
||||||
@@ -44,7 +52,7 @@ class PaddleSyncPackages extends Command
|
|||||||
});
|
});
|
||||||
|
|
||||||
$this->info(sprintf(
|
$this->info(sprintf(
|
||||||
'Queued %d package %s for Paddle %s.',
|
'Queued %d package %s for Lemon Squeezy %s.',
|
||||||
$packages->count(),
|
$packages->count(),
|
||||||
Str::plural('entry', $packages->count()),
|
Str::plural('entry', $packages->count()),
|
||||||
$pull ? 'pull' : 'sync'
|
$pull ? 'pull' : 'sync'
|
||||||
@@ -82,6 +90,42 @@ class PaddleSyncPackages extends Command
|
|||||||
return $query->orderByDesc('id')->get();
|
return $query->orderByDesc('id')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function hasPackageFilter(): bool
|
||||||
|
{
|
||||||
|
return collect((array) $this->option('package'))->filter()->isNotEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function guardUnmappedPackages(Collection $packages): bool
|
||||||
|
{
|
||||||
|
$unmapped = $packages->filter(fn (Package $package) => blank($package->lemonsqueezy_product_id) || blank($package->lemonsqueezy_variant_id));
|
||||||
|
|
||||||
|
if ($unmapped->isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->error('Unmapped Lemon Squeezy package IDs detected. Resolve mappings or pass --allow-unmapped.');
|
||||||
|
$this->table(
|
||||||
|
['ID', 'Slug', 'Missing'],
|
||||||
|
$unmapped->map(function (Package $package): array {
|
||||||
|
$missing = [];
|
||||||
|
if (blank($package->lemonsqueezy_product_id)) {
|
||||||
|
$missing[] = 'product_id';
|
||||||
|
}
|
||||||
|
if (blank($package->lemonsqueezy_variant_id)) {
|
||||||
|
$missing[] = 'variant_id';
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
$package->id,
|
||||||
|
$package->slug,
|
||||||
|
implode(', ', $missing),
|
||||||
|
];
|
||||||
|
})->values()->all()
|
||||||
|
);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected function dispatchSyncJob(Package $package, bool $dryRun, bool $queue): void
|
protected function dispatchSyncJob(Package $package, bool $dryRun, bool $queue): void
|
||||||
{
|
{
|
||||||
$context = [
|
$context = [
|
||||||
@@ -89,26 +133,26 @@ class PaddleSyncPackages extends Command
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($queue) {
|
if ($queue) {
|
||||||
SyncPackageToPaddle::dispatch($package->id, $context);
|
SyncPackageToLemonSqueezy::dispatch($package->id, $context);
|
||||||
$this->line(sprintf('> queued sync for package #%d (%s)', $package->id, $package->slug));
|
$this->line(sprintf('> queued sync for package #%d (%s)', $package->id, $package->slug));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncPackageToPaddle::dispatchSync($package->id, $context);
|
SyncPackageToLemonSqueezy::dispatchSync($package->id, $context);
|
||||||
$this->line(sprintf('> synced package #%d (%s)', $package->id, $package->slug));
|
$this->line(sprintf('> synced package #%d (%s)', $package->id, $package->slug));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function dispatchPullJob(Package $package, bool $queue): void
|
protected function dispatchPullJob(Package $package, bool $queue): void
|
||||||
{
|
{
|
||||||
if ($queue) {
|
if ($queue) {
|
||||||
PullPackageFromPaddle::dispatch($package->id);
|
PullPackageFromLemonSqueezy::dispatch($package->id);
|
||||||
$this->line(sprintf('> queued pull for package #%d (%s)', $package->id, $package->slug));
|
$this->line(sprintf('> queued pull for package #%d (%s)', $package->id, $package->slug));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PullPackageFromPaddle::dispatchSync($package->id);
|
PullPackageFromLemonSqueezy::dispatchSync($package->id);
|
||||||
$this->line(sprintf('> pulled package #%d (%s)', $package->id, $package->slug));
|
$this->line(sprintf('> pulled package #%d (%s)', $package->id, $package->slug));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,15 +4,15 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
use App\Models\PackagePurchase;
|
use App\Models\PackagePurchase;
|
||||||
use App\Models\Tenant;
|
use App\Models\Tenant;
|
||||||
use App\Models\User;
|
|
||||||
use App\Models\TenantPackage;
|
use App\Models\TenantPackage;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class MigrateLegacyPurchases extends Command
|
class MigrateLegacyPurchases extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'packages:migrate-legacy';
|
protected $signature = 'packages:migrate-legacy';
|
||||||
|
|
||||||
protected $description = 'Migrate legacy purchases to new system with temp tenants';
|
protected $description = 'Migrate legacy purchases to new system with temp tenants';
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
@@ -21,19 +21,20 @@ class MigrateLegacyPurchases extends Command
|
|||||||
|
|
||||||
if ($legacyPurchases->isEmpty()) {
|
if ($legacyPurchases->isEmpty()) {
|
||||||
$this->info('No legacy purchases found.');
|
$this->info('No legacy purchases found.');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info("Found {$legacyPurchases->count()} legacy purchases.");
|
$this->info("Found {$legacyPurchases->count()} legacy purchases.");
|
||||||
|
|
||||||
foreach ($legacyPurchases as $purchase) {
|
foreach ($legacyPurchases as $purchase) {
|
||||||
if (!$purchase->user_id) {
|
if (! $purchase->user_id) {
|
||||||
// Create temp user if no user
|
// Create temp user if no user
|
||||||
$tempUser = User::create([
|
$tempUser = User::create([
|
||||||
'name' => 'Legacy User ' . $purchase->id,
|
'name' => 'Legacy User '.$purchase->id,
|
||||||
'email' => 'legacy' . $purchase->id . '@fotospiel.local',
|
'email' => 'legacy'.$purchase->id.'@fotospiel.local',
|
||||||
'password' => Hash::make('legacy'),
|
'password' => Hash::make('legacy'),
|
||||||
'username' => 'legacy' . $purchase->id,
|
'username' => 'legacy'.$purchase->id,
|
||||||
'first_name' => 'Legacy',
|
'first_name' => 'Legacy',
|
||||||
'last_name' => 'User',
|
'last_name' => 'User',
|
||||||
'address' => 'Legacy Address',
|
'address' => 'Legacy Address',
|
||||||
@@ -43,7 +44,7 @@ class MigrateLegacyPurchases extends Command
|
|||||||
|
|
||||||
$tempTenant = Tenant::create([
|
$tempTenant = Tenant::create([
|
||||||
'user_id' => $tempUser->id,
|
'user_id' => $tempUser->id,
|
||||||
'name' => 'Legacy Tenant ' . $purchase->id,
|
'name' => 'Legacy Tenant '.$purchase->id,
|
||||||
'status' => 'active',
|
'status' => 'active',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -73,6 +74,7 @@ class MigrateLegacyPurchases extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->info('Legacy migration completed.');
|
$this->info('Legacy migration completed.');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,12 @@ class MonitorStorageCommand extends Command
|
|||||||
|
|
||||||
$assetStats = $this->buildAssetStatistics();
|
$assetStats = $this->buildAssetStatistics();
|
||||||
$thresholds = $this->capacityThresholds();
|
$thresholds = $this->capacityThresholds();
|
||||||
|
$checksumConfig = $this->checksumAlertConfig();
|
||||||
|
$checksumWindowMinutes = $checksumConfig['window_minutes'];
|
||||||
|
$checksumThresholds = $checksumConfig['thresholds'];
|
||||||
|
$checksumMismatches = $checksumConfig['enabled'] && $checksumWindowMinutes > 0
|
||||||
|
? $this->checksumMismatchCounts($checksumWindowMinutes)
|
||||||
|
: [];
|
||||||
$alerts = [];
|
$alerts = [];
|
||||||
$snapshotTargets = [];
|
$snapshotTargets = [];
|
||||||
|
|
||||||
@@ -78,6 +84,7 @@ class MonitorStorageCommand extends Command
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$targetChecksumMismatches = $checksumMismatches[$target->id] ?? 0;
|
||||||
$snapshotTargets[] = [
|
$snapshotTargets[] = [
|
||||||
'id' => $target->id,
|
'id' => $target->id,
|
||||||
'key' => $target->key,
|
'key' => $target->key,
|
||||||
@@ -85,13 +92,35 @@ class MonitorStorageCommand extends Command
|
|||||||
'is_hot' => (bool) $target->is_hot,
|
'is_hot' => (bool) $target->is_hot,
|
||||||
'capacity' => $capacity,
|
'capacity' => $capacity,
|
||||||
'assets' => $assets,
|
'assets' => $assets,
|
||||||
|
'checksum_mismatches' => [
|
||||||
|
'count' => $targetChecksumMismatches,
|
||||||
|
'window_minutes' => $checksumWindowMinutes,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($checksumConfig['enabled'] && $checksumWindowMinutes > 0) {
|
||||||
|
$totalMismatches = array_sum($checksumMismatches);
|
||||||
|
$checksumSeverity = $this->determineChecksumSeverity($totalMismatches, $checksumThresholds);
|
||||||
|
|
||||||
|
if ($checksumSeverity !== 'ok') {
|
||||||
|
$alerts[] = [
|
||||||
|
'type' => 'checksum_mismatch',
|
||||||
|
'severity' => $checksumSeverity,
|
||||||
|
'count' => $totalMismatches,
|
||||||
|
'window_minutes' => $checksumWindowMinutes,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$snapshot = [
|
$snapshot = [
|
||||||
'generated_at' => now()->toIso8601String(),
|
'generated_at' => now()->toIso8601String(),
|
||||||
'targets' => $snapshotTargets,
|
'targets' => $snapshotTargets,
|
||||||
'alerts' => $alerts,
|
'alerts' => $alerts,
|
||||||
|
'checksum' => [
|
||||||
|
'window_minutes' => $checksumWindowMinutes,
|
||||||
|
'mismatch_total' => array_sum($checksumMismatches),
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$ttlMinutes = max(1, (int) config('storage-monitor.monitor.cache_minutes', 15));
|
$ttlMinutes = max(1, (int) config('storage-monitor.monitor.cache_minutes', 15));
|
||||||
@@ -191,4 +220,62 @@ class MonitorStorageCommand extends Command
|
|||||||
|
|
||||||
return 'ok';
|
return 'ok';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checksumAlertConfig(): array
|
||||||
|
{
|
||||||
|
$enabled = (bool) config('storage-monitor.checksum_validation.enabled', true);
|
||||||
|
$windowMinutes = max(0, (int) config('storage-monitor.checksum_validation.alert_window_minutes', 60));
|
||||||
|
$warning = (int) config('storage-monitor.checksum_validation.thresholds.warning', 1);
|
||||||
|
$critical = (int) config('storage-monitor.checksum_validation.thresholds.critical', 5);
|
||||||
|
|
||||||
|
if ($warning > $critical && $critical > 0) {
|
||||||
|
[$warning, $critical] = [$critical, $warning];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'enabled' => $enabled,
|
||||||
|
'window_minutes' => $windowMinutes,
|
||||||
|
'thresholds' => [
|
||||||
|
'warning' => $warning,
|
||||||
|
'critical' => $critical,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checksumMismatchCounts(int $windowMinutes): array
|
||||||
|
{
|
||||||
|
$query = EventMediaAsset::query()
|
||||||
|
->selectRaw('media_storage_target_id, COUNT(*) as total_count')
|
||||||
|
->where('status', 'failed')
|
||||||
|
->where('meta->checksum_status', 'mismatch');
|
||||||
|
|
||||||
|
if ($windowMinutes > 0) {
|
||||||
|
$query->where('updated_at', '>=', now()->subMinutes($windowMinutes));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query->groupBy('media_storage_target_id')
|
||||||
|
->get()
|
||||||
|
->mapWithKeys(fn ($row) => [(int) $row->media_storage_target_id => (int) $row->total_count])
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function determineChecksumSeverity(int $count, array $thresholds): string
|
||||||
|
{
|
||||||
|
$warning = (int) ($thresholds['warning'] ?? 1);
|
||||||
|
$critical = (int) ($thresholds['critical'] ?? 5);
|
||||||
|
|
||||||
|
if ($count <= 0) {
|
||||||
|
return 'ok';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($critical > 0 && $count >= $critical) {
|
||||||
|
return 'critical';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($warning > 0 && $count >= $warning) {
|
||||||
|
return 'warning';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'ok';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Console\Commands;
|
|||||||
use App\Jobs\AnonymizeAccount;
|
use App\Jobs\AnonymizeAccount;
|
||||||
use App\Models\Tenant;
|
use App\Models\Tenant;
|
||||||
use App\Notifications\InactiveTenantDeletionWarning;
|
use App\Notifications\InactiveTenantDeletionWarning;
|
||||||
|
use App\Services\Compliance\RetentionOverrideService;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
@@ -27,7 +28,13 @@ class ProcessTenantRetention extends Command
|
|||||||
->withMax('purchases as last_purchase_activity', 'purchased_at')
|
->withMax('purchases as last_purchase_activity', 'purchased_at')
|
||||||
->withMax('photos as last_photo_activity', 'created_at')
|
->withMax('photos as last_photo_activity', 'created_at')
|
||||||
->chunkById(100, function ($tenants) use ($warningThreshold, $deletionThreshold) {
|
->chunkById(100, function ($tenants) use ($warningThreshold, $deletionThreshold) {
|
||||||
|
$overrides = app(RetentionOverrideService::class);
|
||||||
|
|
||||||
foreach ($tenants as $tenant) {
|
foreach ($tenants as $tenant) {
|
||||||
|
if ($overrides->tenantOnHold($tenant)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$lastActivity = $this->determineLastActivity($tenant);
|
$lastActivity = $this->determineLastActivity($tenant);
|
||||||
|
|
||||||
if (! $lastActivity) {
|
if (! $lastActivity) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
{
|
{
|
||||||
protected $signature = 'demo:seed-switcher {--with-photos : Download sample photos from Pexels} {--photos-per-event=18 : Target photos per event when downloading} {--cleanup : Remove demo switcher tenants/events/photos instead of seeding}';
|
protected $signature = 'demo:seed-switcher {--with-photos : Download sample photos from Pexels} {--photos-per-event=18 : Target photos per event when downloading} {--cleanup : Remove demo switcher tenants/events/photos instead of seeding}';
|
||||||
|
|
||||||
protected $description = 'Seeds demo tenants used by the DevTenantSwitcher (endcustomer + reseller profiles)';
|
protected $description = 'Seeds demo tenants used by the DevTenantSwitcher (endcustomer + partner profiles)';
|
||||||
|
|
||||||
public function __construct(private EventStorageManager $eventStorageManager)
|
public function __construct(private EventStorageManager $eventStorageManager)
|
||||||
{
|
{
|
||||||
@@ -52,7 +52,7 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
|
|
||||||
DB::transaction(function () use ($packages, $eventTypes) {
|
DB::transaction(function () use ($packages, $eventTypes) {
|
||||||
$this->seedCustomerStandardEmpty($packages, $eventTypes);
|
$this->seedCustomerStandardEmpty($packages, $eventTypes);
|
||||||
$this->seedCustomerStarterWedding($packages, $eventTypes);
|
$this->seedCustomerStandardWedding($packages, $eventTypes);
|
||||||
$this->seedResellerActive($packages, $eventTypes);
|
$this->seedResellerActive($packages, $eventTypes);
|
||||||
$this->seedResellerFull($packages, $eventTypes);
|
$this->seedResellerFull($packages, $eventTypes);
|
||||||
});
|
});
|
||||||
@@ -129,7 +129,7 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
$slugs = [
|
$slugs = [
|
||||||
'starter' => 'Starter',
|
'starter' => 'Starter',
|
||||||
'standard' => 'Standard',
|
'standard' => 'Standard',
|
||||||
's-small-reseller' => 'Reseller S',
|
's-small-reseller' => 'Partner Start',
|
||||||
];
|
];
|
||||||
|
|
||||||
$packages = [];
|
$packages = [];
|
||||||
@@ -165,10 +165,10 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
{
|
{
|
||||||
$tenant = $this->upsertTenant(
|
$tenant = $this->upsertTenant(
|
||||||
slug: 'demo-standard-empty',
|
slug: 'demo-standard-empty',
|
||||||
name: 'Demo Standard (ohne Event)',
|
name: 'Demo Starter (ohne Event)',
|
||||||
contactEmail: 'standard-empty@demo.fotospiel',
|
contactEmail: 'standard-empty@demo.fotospiel',
|
||||||
attributes: [
|
attributes: [
|
||||||
'subscription_tier' => 'standard',
|
'subscription_tier' => 'starter',
|
||||||
'subscription_status' => 'active',
|
'subscription_status' => 'active',
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -176,9 +176,9 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
$this->upsertAdmin($tenant, 'standard-empty@demo.fotospiel');
|
$this->upsertAdmin($tenant, 'standard-empty@demo.fotospiel');
|
||||||
|
|
||||||
TenantPackage::updateOrCreate(
|
TenantPackage::updateOrCreate(
|
||||||
['tenant_id' => $tenant->id, 'package_id' => $packages['standard']->id],
|
['tenant_id' => $tenant->id, 'package_id' => $packages['starter']->id],
|
||||||
[
|
[
|
||||||
'price' => $packages['standard']->price,
|
'price' => $packages['starter']->price,
|
||||||
'purchased_at' => Carbon::now()->subDays(1),
|
'purchased_at' => Carbon::now()->subDays(1),
|
||||||
'expires_at' => Carbon::now()->addMonths(12),
|
'expires_at' => Carbon::now()->addMonths(12),
|
||||||
'used_events' => 0,
|
'used_events' => 0,
|
||||||
@@ -186,26 +186,37 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->comment('Seeded Standard tenant without events.');
|
$this->comment('Seeded Starter tenant without events.');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function seedCustomerStarterWedding(array $packages, array $eventTypes): void
|
private function seedCustomerStandardWedding(array $packages, array $eventTypes): void
|
||||||
{
|
{
|
||||||
$tenant = $this->upsertTenant(
|
$tenant = $this->upsertTenant(
|
||||||
slug: 'demo-starter-wedding',
|
slug: 'demo-starter-wedding',
|
||||||
name: 'Demo Starter Wedding',
|
name: 'Demo Standard Wedding',
|
||||||
contactEmail: 'starter-wedding@demo.fotospiel',
|
contactEmail: 'starter-wedding@demo.fotospiel',
|
||||||
attributes: [
|
attributes: [
|
||||||
'subscription_tier' => 'starter',
|
'subscription_tier' => 'standard',
|
||||||
'subscription_status' => 'active',
|
'subscription_status' => 'active',
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->upsertAdmin($tenant, 'starter-wedding@demo.fotospiel');
|
$this->upsertAdmin($tenant, 'starter-wedding@demo.fotospiel');
|
||||||
|
|
||||||
|
TenantPackage::updateOrCreate(
|
||||||
|
['tenant_id' => $tenant->id, 'package_id' => $packages['standard']->id],
|
||||||
|
[
|
||||||
|
'price' => $packages['standard']->price,
|
||||||
|
'purchased_at' => Carbon::now()->subDays(1),
|
||||||
|
'expires_at' => Carbon::now()->addMonths(12),
|
||||||
|
'used_events' => 1,
|
||||||
|
'active' => true,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$event = $this->upsertEvent(
|
$event = $this->upsertEvent(
|
||||||
tenant: $tenant,
|
tenant: $tenant,
|
||||||
package: $packages['starter'],
|
package: $packages['standard'],
|
||||||
eventType: $eventTypes['wedding'] ?? null,
|
eventType: $eventTypes['wedding'] ?? null,
|
||||||
attributes: [
|
attributes: [
|
||||||
'name' => ['de' => 'Hochzeit Mia & Jonas', 'en' => 'Wedding Mia & Jonas'],
|
'name' => ['de' => 'Hochzeit Mia & Jonas', 'en' => 'Wedding Mia & Jonas'],
|
||||||
@@ -221,17 +232,18 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
|
|
||||||
private function seedResellerActive(array $packages, array $eventTypes): void
|
private function seedResellerActive(array $packages, array $eventTypes): void
|
||||||
{
|
{
|
||||||
|
$eventPackage = $this->resolveIncludedPackage($packages['s-small-reseller'], $packages);
|
||||||
$tenant = $this->upsertTenant(
|
$tenant = $this->upsertTenant(
|
||||||
slug: 'demo-reseller-active',
|
slug: 'demo-reseller-active',
|
||||||
name: 'Demo Reseller Active',
|
name: 'Demo Partner Active',
|
||||||
contactEmail: 'reseller-active@demo.fotospiel',
|
contactEmail: 'partner-active@demo.fotospiel',
|
||||||
attributes: [
|
attributes: [
|
||||||
'subscription_tier' => 'reseller',
|
'subscription_tier' => 'reseller',
|
||||||
'subscription_status' => 'active',
|
'subscription_status' => 'active',
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->upsertAdmin($tenant, 'reseller-active@demo.fotospiel');
|
$this->upsertAdmin($tenant, 'partner-active@demo.fotospiel');
|
||||||
|
|
||||||
TenantPackage::updateOrCreate(
|
TenantPackage::updateOrCreate(
|
||||||
['tenant_id' => $tenant->id, 'package_id' => $packages['s-small-reseller']->id],
|
['tenant_id' => $tenant->id, 'package_id' => $packages['s-small-reseller']->id],
|
||||||
@@ -268,7 +280,7 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
foreach ($events as $index => $config) {
|
foreach ($events as $index => $config) {
|
||||||
$event = $this->upsertEvent(
|
$event = $this->upsertEvent(
|
||||||
tenant: $tenant,
|
tenant: $tenant,
|
||||||
package: $packages['standard'],
|
package: $eventPackage,
|
||||||
eventType: $config['type'],
|
eventType: $config['type'],
|
||||||
attributes: [
|
attributes: [
|
||||||
'name' => $config['name'],
|
'name' => $config['name'],
|
||||||
@@ -285,17 +297,18 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
|
|
||||||
private function seedResellerFull(array $packages, array $eventTypes): void
|
private function seedResellerFull(array $packages, array $eventTypes): void
|
||||||
{
|
{
|
||||||
|
$eventPackage = $this->resolveIncludedPackage($packages['s-small-reseller'], $packages);
|
||||||
$tenant = $this->upsertTenant(
|
$tenant = $this->upsertTenant(
|
||||||
slug: 'demo-reseller-full',
|
slug: 'demo-reseller-full',
|
||||||
name: 'Demo Reseller Voll',
|
name: 'Demo Partner Voll',
|
||||||
contactEmail: 'reseller-full@demo.fotospiel',
|
contactEmail: 'partner-full@demo.fotospiel',
|
||||||
attributes: [
|
attributes: [
|
||||||
'subscription_tier' => 'reseller',
|
'subscription_tier' => 'reseller',
|
||||||
'subscription_status' => 'active',
|
'subscription_status' => 'active',
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->upsertAdmin($tenant, 'reseller-full@demo.fotospiel');
|
$this->upsertAdmin($tenant, 'partner-full@demo.fotospiel');
|
||||||
|
|
||||||
TenantPackage::updateOrCreate(
|
TenantPackage::updateOrCreate(
|
||||||
['tenant_id' => $tenant->id, 'package_id' => $packages['s-small-reseller']->id],
|
['tenant_id' => $tenant->id, 'package_id' => $packages['s-small-reseller']->id],
|
||||||
@@ -319,7 +332,7 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
foreach ($eventConfigs as $index => $config) {
|
foreach ($eventConfigs as $index => $config) {
|
||||||
$event = $this->upsertEvent(
|
$event = $this->upsertEvent(
|
||||||
tenant: $tenant,
|
tenant: $tenant,
|
||||||
package: $packages['standard'],
|
package: $eventPackage,
|
||||||
eventType: $config['type'],
|
eventType: $config['type'],
|
||||||
attributes: [
|
attributes: [
|
||||||
'name' => $config['name'],
|
'name' => $config['name'],
|
||||||
@@ -346,8 +359,8 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
'settings' => [
|
'settings' => [
|
||||||
'branding' => [
|
'branding' => [
|
||||||
'logo_url' => null,
|
'logo_url' => null,
|
||||||
'primary_color' => '#1D4ED8',
|
'primary_color' => '#FF5A5F',
|
||||||
'secondary_color' => '#0F172A',
|
'secondary_color' => '#FFF8F5',
|
||||||
'font_family' => 'Inter, sans-serif',
|
'font_family' => 'Inter, sans-serif',
|
||||||
],
|
],
|
||||||
'features' => [
|
'features' => [
|
||||||
@@ -424,6 +437,19 @@ class SeedDemoSwitcherTenants extends Command
|
|||||||
return $event;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function resolveIncludedPackage(Package $resellerPackage, array $packages): Package
|
||||||
|
{
|
||||||
|
$includedSlug = $resellerPackage->included_package_slug;
|
||||||
|
|
||||||
|
if ($includedSlug && isset($packages[$includedSlug])) {
|
||||||
|
return $packages[$includedSlug];
|
||||||
|
}
|
||||||
|
|
||||||
|
$fallback = $packages['starter'] ?? $packages['standard'] ?? null;
|
||||||
|
|
||||||
|
return $fallback ?? $resellerPackage;
|
||||||
|
}
|
||||||
|
|
||||||
private function fallbackEventType(): ?EventType
|
private function fallbackEventType(): ?EventType
|
||||||
{
|
{
|
||||||
$fallback = EventType::first();
|
$fallback = EventType::first();
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class SendAbandonedCheckoutReminders extends Command
|
|||||||
if ($this->shouldSendReminder($checkout, $stage)) {
|
if ($this->shouldSendReminder($checkout, $stage)) {
|
||||||
$resumeUrl = $this->generateResumeUrl($checkout);
|
$resumeUrl = $this->generateResumeUrl($checkout);
|
||||||
|
|
||||||
if (!$isDryRun) {
|
if (! $isDryRun) {
|
||||||
$mailLocale = $checkout->user->preferred_locale ?? config('app.locale');
|
$mailLocale = $checkout->user->preferred_locale ?? config('app.locale');
|
||||||
|
|
||||||
Mail::to($checkout->user)
|
Mail::to($checkout->user)
|
||||||
@@ -86,8 +86,8 @@ class SendAbandonedCheckoutReminders extends Command
|
|||||||
$totalProcessed++;
|
$totalProcessed++;
|
||||||
}
|
}
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
Log::error("Failed to send {$stage} reminder for checkout {$checkout->id}: " . $e->getMessage());
|
Log::error("Failed to send {$stage} reminder for checkout {$checkout->id}: ".$e->getMessage());
|
||||||
$this->error(" ❌ Failed to process checkout {$checkout->id}: " . $e->getMessage());
|
$this->error(" ❌ Failed to process checkout {$checkout->id}: ".$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ class SendAbandonedCheckoutReminders extends Command
|
|||||||
->count();
|
->count();
|
||||||
|
|
||||||
if ($oldCheckouts > 0) {
|
if ($oldCheckouts > 0) {
|
||||||
if (!$isDryRun) {
|
if (! $isDryRun) {
|
||||||
AbandonedCheckoutModel::where('abandoned_at', '<', now()->subDays(30))
|
AbandonedCheckoutModel::where('abandoned_at', '<', now()->subDays(30))
|
||||||
->where('converted', false)
|
->where('converted', false)
|
||||||
->delete();
|
->delete();
|
||||||
@@ -108,10 +108,10 @@ class SendAbandonedCheckoutReminders extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info("✅ Reminder process completed!");
|
$this->info('✅ Reminder process completed!');
|
||||||
$this->info(" Processed: {$totalProcessed} checkouts");
|
$this->info(" Processed: {$totalProcessed} checkouts");
|
||||||
|
|
||||||
if (!$isDryRun) {
|
if (! $isDryRun) {
|
||||||
$this->info(" Sent: {$totalSent} reminder emails");
|
$this->info(" Sent: {$totalSent} reminder emails");
|
||||||
} else {
|
} else {
|
||||||
$this->info(" Would send: {$totalSent} reminder emails");
|
$this->info(" Would send: {$totalSent} reminder emails");
|
||||||
@@ -131,12 +131,12 @@ class SendAbandonedCheckoutReminders extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
// User existiert noch?
|
// User existiert noch?
|
||||||
if (!$checkout->user) {
|
if (! $checkout->user) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Package existiert noch?
|
// Package existiert noch?
|
||||||
if (!$checkout->package) {
|
if (! $checkout->package) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use Illuminate\Support\Str;
|
|||||||
|
|
||||||
class SyncGoogleFonts extends Command
|
class SyncGoogleFonts extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'fonts:sync-google {--count=50 : Number of popular fonts to fetch} {--weights=400,700 : Comma separated numeric font weights to download} {--italic : Also download italic variants where available} {--force : Re-download files even if they exist} {--path= : Optional custom output directory (defaults to public/fonts/google)} {--family= : Download specific family name(s), comma separated (case-insensitive)} {--category= : Filter by category, comma separated (e.g. sans-serif,serif)} {--prune : Remove local font families not included in this sync} {--dry-run : Show what would be downloaded without writing files}';
|
protected $signature = 'fonts:sync-google {--count=50 : Number of popular fonts to fetch} {--weights=400,700 : Comma separated numeric font weights to download} {--italic : Also download italic variants where available} {--force : Re-download files even if they exist} {--path= : Optional custom output directory (defaults to public/fonts/google)} {--family= : Download specific family name(s), comma separated (case-insensitive)} {--category= : Filter by category, comma separated (e.g. sans-serif,serif)} {--prune : Remove local font families not included in this sync} {--dry-run : Show what would be downloaded without writing files} {--from-disk : Rebuild manifest + CSS from existing font files without downloading}';
|
||||||
|
|
||||||
protected $description = 'Download the most popular Google Fonts to the local public/fonts/google directory and generate a manifest + CSS file.';
|
protected $description = 'Download the most popular Google Fonts to the local public/fonts/google directory and generate a manifest + CSS file.';
|
||||||
|
|
||||||
@@ -20,6 +20,17 @@ class SyncGoogleFonts extends Command
|
|||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
|
$dryRun = (bool) $this->option('dry-run');
|
||||||
|
$fromDisk = (bool) $this->option('from-disk');
|
||||||
|
$pathOption = $this->option('path');
|
||||||
|
$basePath = $pathOption
|
||||||
|
? (Str::startsWith($pathOption, DIRECTORY_SEPARATOR) ? $pathOption : base_path($pathOption))
|
||||||
|
: public_path('fonts/google');
|
||||||
|
|
||||||
|
if ($fromDisk) {
|
||||||
|
return $this->syncFromDisk($basePath, $dryRun);
|
||||||
|
}
|
||||||
|
|
||||||
$apiKey = config('services.google_fonts.key');
|
$apiKey = config('services.google_fonts.key');
|
||||||
|
|
||||||
if (! $apiKey) {
|
if (! $apiKey) {
|
||||||
@@ -32,16 +43,10 @@ class SyncGoogleFonts extends Command
|
|||||||
$weights = $this->prepareWeights($this->option('weights'));
|
$weights = $this->prepareWeights($this->option('weights'));
|
||||||
$includeItalic = (bool) $this->option('italic');
|
$includeItalic = (bool) $this->option('italic');
|
||||||
$force = (bool) $this->option('force');
|
$force = (bool) $this->option('force');
|
||||||
$dryRun = (bool) $this->option('dry-run');
|
|
||||||
$families = $this->normalizeFamilyOption($this->option('family'));
|
$families = $this->normalizeFamilyOption($this->option('family'));
|
||||||
$categories = $this->prepareCategories($this->option('category'));
|
$categories = $this->prepareCategories($this->option('category'));
|
||||||
$prune = (bool) $this->option('prune');
|
$prune = (bool) $this->option('prune');
|
||||||
|
|
||||||
$pathOption = $this->option('path');
|
|
||||||
$basePath = $pathOption
|
|
||||||
? (Str::startsWith($pathOption, DIRECTORY_SEPARATOR) ? $pathOption : base_path($pathOption))
|
|
||||||
: public_path('fonts/google');
|
|
||||||
|
|
||||||
if (count($families)) {
|
if (count($families)) {
|
||||||
$label = count($families) > 1 ? 'families' : 'family';
|
$label = count($families) > 1 ? 'families' : 'family';
|
||||||
$this->info(sprintf('Fetching Google Font %s "%s" (weights: %s, italic: %s)...', $label, implode(', ', $families), implode(', ', $weights), $includeItalic ? 'yes' : 'no'));
|
$this->info(sprintf('Fetching Google Font %s "%s" (weights: %s, italic: %s)...', $label, implode(', ', $families), implode(', ', $weights), $includeItalic ? 'yes' : 'no'));
|
||||||
@@ -206,6 +211,204 @@ class SyncGoogleFonts extends Command
|
|||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function syncFromDisk(string $basePath, bool $dryRun): int
|
||||||
|
{
|
||||||
|
if (! File::isDirectory($basePath)) {
|
||||||
|
$this->error(sprintf('Font directory not found: %s', $basePath));
|
||||||
|
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->option('prune')) {
|
||||||
|
$this->warn('Ignoring --prune when rebuilding from disk.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$fonts = $this->buildManifestFromDisk($basePath);
|
||||||
|
|
||||||
|
if (! count($fonts)) {
|
||||||
|
$this->warn('No fonts found on disk.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($dryRun) {
|
||||||
|
$this->info(sprintf('Dry run complete: %d font families would be written to %s', count($fonts), $basePath));
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->writeManifest($basePath, $fonts);
|
||||||
|
$this->writeCss($basePath, $fonts);
|
||||||
|
Cache::forget('fonts:manifest');
|
||||||
|
|
||||||
|
$this->info(sprintf('Rebuilt manifest for %d font families from %s', count($fonts), $basePath));
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array<string, mixed>>
|
||||||
|
*/
|
||||||
|
private function buildManifestFromDisk(string $basePath): array
|
||||||
|
{
|
||||||
|
$directories = File::directories($basePath);
|
||||||
|
$fonts = [];
|
||||||
|
|
||||||
|
foreach ($directories as $dir) {
|
||||||
|
$slug = basename($dir);
|
||||||
|
$files = collect(File::files($dir))
|
||||||
|
->filter(function (\SplFileInfo $file) {
|
||||||
|
$extension = strtolower($file->getExtension());
|
||||||
|
|
||||||
|
return in_array($extension, ['woff2', 'woff', 'otf', 'ttf'], true);
|
||||||
|
})
|
||||||
|
->values();
|
||||||
|
|
||||||
|
if (! $files->count()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variantsByKey = [];
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$filename = $file->getFilename();
|
||||||
|
$extension = strtolower($file->getExtension());
|
||||||
|
$style = $this->extractStyleFromFilename($filename);
|
||||||
|
$weight = $this->extractWeightFromFilename($filename);
|
||||||
|
$variantKey = $this->buildVariantKey($weight, $style);
|
||||||
|
$priority = $this->extensionPriority($extension);
|
||||||
|
$relativePath = sprintf('/fonts/google/%s/%s', $slug, $filename);
|
||||||
|
|
||||||
|
$existing = $variantsByKey[$variantKey] ?? null;
|
||||||
|
if ($existing && ($existing['priority'] ?? 0) >= $priority) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variantsByKey[$variantKey] = [
|
||||||
|
'variant' => $variantKey,
|
||||||
|
'weight' => $weight,
|
||||||
|
'style' => $style,
|
||||||
|
'url' => $relativePath,
|
||||||
|
'priority' => $priority,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! count($variantsByKey)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variants = array_values(array_map(function (array $variant) {
|
||||||
|
unset($variant['priority']);
|
||||||
|
|
||||||
|
return $variant;
|
||||||
|
}, $variantsByKey));
|
||||||
|
|
||||||
|
usort($variants, function (array $left, array $right) {
|
||||||
|
$weightCompare = ($left['weight'] ?? 400) <=> ($right['weight'] ?? 400);
|
||||||
|
if ($weightCompare !== 0) {
|
||||||
|
return $weightCompare;
|
||||||
|
}
|
||||||
|
|
||||||
|
return strcmp((string) ($left['style'] ?? 'normal'), (string) ($right['style'] ?? 'normal'));
|
||||||
|
});
|
||||||
|
|
||||||
|
$fonts[] = [
|
||||||
|
'family' => $this->familyFromSlug($slug),
|
||||||
|
'slug' => $slug,
|
||||||
|
'category' => null,
|
||||||
|
'variants' => $variants,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($fonts, fn (array $left, array $right) => strcmp((string) $left['family'], (string) $right['family']));
|
||||||
|
|
||||||
|
return $fonts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function familyFromSlug(string $slug): string
|
||||||
|
{
|
||||||
|
$parts = array_filter(explode('-', $slug), fn ($part) => $part !== '');
|
||||||
|
|
||||||
|
$words = array_map(function (string $part) {
|
||||||
|
if (is_numeric($part)) {
|
||||||
|
return $part;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($part) <= 3) {
|
||||||
|
return strtoupper($part);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ucfirst(strtolower($part));
|
||||||
|
}, $parts);
|
||||||
|
|
||||||
|
return trim(implode(' ', $words));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractStyleFromFilename(string $filename): string
|
||||||
|
{
|
||||||
|
$lower = strtolower($filename);
|
||||||
|
|
||||||
|
return str_contains($lower, 'italic') || str_contains($lower, 'oblique') ? 'italic' : 'normal';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractWeightFromFilename(string $filename): int
|
||||||
|
{
|
||||||
|
if (preg_match('/(?:^|[^0-9])(100|200|300|400|500|600|700|800|900)(?:[^0-9]|$)/', $filename, $matches)) {
|
||||||
|
return (int) $matches[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$lower = strtolower($filename);
|
||||||
|
$weightMap = [
|
||||||
|
'thin' => 100,
|
||||||
|
'extralight' => 200,
|
||||||
|
'ultralight' => 200,
|
||||||
|
'light' => 300,
|
||||||
|
'regular' => 400,
|
||||||
|
'book' => 400,
|
||||||
|
'medium' => 500,
|
||||||
|
'semibold' => 600,
|
||||||
|
'demibold' => 600,
|
||||||
|
'bold' => 700,
|
||||||
|
'extrabold' => 800,
|
||||||
|
'ultrabold' => 800,
|
||||||
|
'black' => 900,
|
||||||
|
'heavy' => 900,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($weightMap as $label => $weight) {
|
||||||
|
if (str_contains($lower, $label)) {
|
||||||
|
return $weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildVariantKey(int $weight, string $style): string
|
||||||
|
{
|
||||||
|
if ($weight === 400 && $style === 'normal') {
|
||||||
|
return 'regular';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($weight === 400 && $style === 'italic') {
|
||||||
|
return 'italic';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($style === 'italic') {
|
||||||
|
return $weight.'italic';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (string) $weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extensionPriority(string $extension): int
|
||||||
|
{
|
||||||
|
return match ($extension) {
|
||||||
|
'woff2' => 4,
|
||||||
|
'woff' => 3,
|
||||||
|
'otf' => 2,
|
||||||
|
'ttf' => 1,
|
||||||
|
default => 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int, string>
|
* @return array<int, string>
|
||||||
*/
|
*/
|
||||||
|
|||||||
19
app/Enums/DataExportScope.php
Normal file
19
app/Enums/DataExportScope.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum DataExportScope: string
|
||||||
|
{
|
||||||
|
case USER = 'user';
|
||||||
|
case TENANT = 'tenant';
|
||||||
|
case EVENT = 'event';
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::USER => __('User'),
|
||||||
|
self::TENANT => __('Tenant'),
|
||||||
|
self::EVENT => __('Event'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,4 +6,4 @@ enum PackageType: string
|
|||||||
{
|
{
|
||||||
case ENDCUSTOMER = 'endcustomer';
|
case ENDCUSTOMER = 'endcustomer';
|
||||||
case RESELLER = 'reseller';
|
case RESELLER = 'reseller';
|
||||||
}
|
}
|
||||||
|
|||||||
12
app/Enums/PhotoLiveStatus.php
Normal file
12
app/Enums/PhotoLiveStatus.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum PhotoLiveStatus: string
|
||||||
|
{
|
||||||
|
case NONE = 'none';
|
||||||
|
case PENDING = 'pending';
|
||||||
|
case APPROVED = 'approved';
|
||||||
|
case REJECTED = 'rejected';
|
||||||
|
case EXPIRED = 'expired';
|
||||||
|
}
|
||||||
17
app/Enums/RetentionOverrideScope.php
Normal file
17
app/Enums/RetentionOverrideScope.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum RetentionOverrideScope: string
|
||||||
|
{
|
||||||
|
case TENANT = 'tenant';
|
||||||
|
case EVENT = 'event';
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::TENANT => __('Tenant'),
|
||||||
|
self::EVENT => __('Event'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Enums/TenantAnnouncementAudience.php
Normal file
19
app/Enums/TenantAnnouncementAudience.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum TenantAnnouncementAudience: string
|
||||||
|
{
|
||||||
|
case ALL = 'all';
|
||||||
|
case TENANTS = 'tenants';
|
||||||
|
case SEGMENTS = 'segments';
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::ALL => __('Alle Tenants'),
|
||||||
|
self::TENANTS => __('Ausgewählte Tenants'),
|
||||||
|
self::SEGMENTS => __('Segmente'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Enums/TenantAnnouncementDeliveryStatus.php
Normal file
19
app/Enums/TenantAnnouncementDeliveryStatus.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum TenantAnnouncementDeliveryStatus: string
|
||||||
|
{
|
||||||
|
case QUEUED = 'queued';
|
||||||
|
case FAILED = 'failed';
|
||||||
|
case SKIPPED = 'skipped';
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::QUEUED => __('Warteschlange'),
|
||||||
|
self::FAILED => __('Fehlgeschlagen'),
|
||||||
|
self::SKIPPED => __('Übersprungen'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
17
app/Enums/TenantAnnouncementSegment.php
Normal file
17
app/Enums/TenantAnnouncementSegment.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum TenantAnnouncementSegment: string
|
||||||
|
{
|
||||||
|
case ACTIVE_PACKAGE = 'active_package';
|
||||||
|
case ACTIVE_STATUS = 'active_status';
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::ACTIVE_PACKAGE => __('Aktives Paket'),
|
||||||
|
self::ACTIVE_STATUS => __('Aktiv (nicht gesperrt/gelöscht)'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
21
app/Enums/TenantAnnouncementStatus.php
Normal file
21
app/Enums/TenantAnnouncementStatus.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum TenantAnnouncementStatus: string
|
||||||
|
{
|
||||||
|
case DRAFT = 'draft';
|
||||||
|
case SCHEDULED = 'scheduled';
|
||||||
|
case ACTIVE = 'active';
|
||||||
|
case ARCHIVED = 'archived';
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::DRAFT => __('Entwurf'),
|
||||||
|
self::SCHEDULED => __('Geplant'),
|
||||||
|
self::ACTIVE => __('Aktiv'),
|
||||||
|
self::ARCHIVED => __('Archiviert'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,6 @@ namespace App\Exports;
|
|||||||
use App\Models\EventPurchase;
|
use App\Models\EventPurchase;
|
||||||
use Filament\Actions\Exports\Exporter;
|
use Filament\Actions\Exports\Exporter;
|
||||||
use Filament\Actions\Exports\Models\Export;
|
use Filament\Actions\Exports\Models\Export;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
class EventPurchaseExporter extends Exporter
|
class EventPurchaseExporter extends Exporter
|
||||||
{
|
{
|
||||||
@@ -28,11 +26,10 @@ class EventPurchaseExporter extends Exporter
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
public static function getCompletedNotificationBody(Export $export): string
|
||||||
{
|
{
|
||||||
$body = "Your Event Purchases export has completed and is ready for download. {$export->successful_rows} purchases were exported.";
|
$body = "Your Event Purchases export has completed and is ready for download. {$export->successful_rows} purchases were exported.";
|
||||||
|
|
||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Filament\Blog\Resources\CategoryResource\Pages;
|
|||||||
use App\Filament\Blog\Traits\HasContentEditor;
|
use App\Filament\Blog\Traits\HasContentEditor;
|
||||||
use App\Filament\Clusters\RareAdmin\RareAdminCluster;
|
use App\Filament\Clusters\RareAdmin\RareAdminCluster;
|
||||||
use App\Models\BlogCategory;
|
use App\Models\BlogCategory;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
@@ -24,6 +25,7 @@ use Filament\Tables\Columns\IconColumn;
|
|||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -116,38 +118,25 @@ class CategoryResource extends Resource
|
|||||||
$data['description_de'] = $descArray['de'] ?? '';
|
$data['description_de'] = $descArray['de'] ?? '';
|
||||||
$data['description_en'] = $descArray['en'] ?? '';
|
$data['description_en'] = $descArray['en'] ?? '';
|
||||||
|
|
||||||
\Illuminate\Support\Facades\Log::info('BeforeFill Description Extraction:', [
|
|
||||||
'descJson' => $descJson,
|
|
||||||
'descArray' => $descArray,
|
|
||||||
'description_de' => $data['description_de'],
|
|
||||||
'description_en' => $data['description_en'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function mutateFormDataBeforeCreate(array $data): array
|
public static function mutateFormDataBeforeCreate(array $data): array
|
||||||
{
|
{
|
||||||
\Illuminate\Support\Facades\Log::info('mutateFormDataBeforeCreate Input Data:', ['data' => $data]);
|
|
||||||
|
|
||||||
$nameData = [
|
$nameData = [
|
||||||
'de' => $data['name_de'] ?? '',
|
'de' => $data['name_de'] ?? '',
|
||||||
'en' => $data['name_en'] ?? '',
|
'en' => $data['name_en'] ?? '',
|
||||||
];
|
];
|
||||||
$data['name'] = json_encode($nameData);
|
$data['name'] = json_encode($nameData);
|
||||||
\Illuminate\Support\Facades\Log::info('mutateFormDataBeforeCreate Name JSON:', ['name' => $nameData]);
|
|
||||||
|
|
||||||
$descData = [
|
$descData = [
|
||||||
'de' => $data['description_de'] ?? '',
|
'de' => $data['description_de'] ?? '',
|
||||||
'en' => $data['description_en'] ?? '',
|
'en' => $data['description_en'] ?? '',
|
||||||
];
|
];
|
||||||
$data['description'] = json_encode($descData);
|
$data['description'] = json_encode($descData);
|
||||||
\Illuminate\Support\Facades\Log::info('mutateFormDataBeforeCreate Description JSON:', ['description' => $descData]);
|
|
||||||
|
|
||||||
unset($data['name_de'], $data['name_en'], $data['description_de'], $data['description_en']);
|
unset($data['name_de'], $data['name_en'], $data['description_de'], $data['description_en']);
|
||||||
|
|
||||||
\Illuminate\Support\Facades\Log::info('mutateFormDataBeforeCreate Final Data:', $data);
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,11 +174,28 @@ class CategoryResource extends Resource
|
|||||||
//
|
//
|
||||||
])
|
])
|
||||||
->actions([
|
->actions([
|
||||||
EditAction::make(),
|
EditAction::make()
|
||||||
|
->after(fn (array $data, BlogCategory $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
DeleteBulkAction::make(),
|
DeleteBulkAction::make()
|
||||||
|
->after(function (Collection $records): void {
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
namespace App\Filament\Blog\Resources\CategoryResource\Pages;
|
namespace App\Filament\Blog\Resources\CategoryResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Blog\Resources\CategoryResource;
|
use App\Filament\Blog\Resources\CategoryResource;
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
use App\Filament\Resources\Pages\AuditedCreateRecord;
|
||||||
|
|
||||||
class CreateCategory extends CreateRecord
|
class CreateCategory extends AuditedCreateRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = CategoryResource::class;
|
protected static string $resource = CategoryResource::class;
|
||||||
|
|
||||||
@@ -30,4 +30,4 @@ class CreateCategory extends CreateRecord
|
|||||||
|
|
||||||
$this->record = static::getResource()::getModel()::create($data);
|
$this->record = static::getResource()::getModel()::create($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,23 @@
|
|||||||
namespace App\Filament\Blog\Resources\CategoryResource\Pages;
|
namespace App\Filament\Blog\Resources\CategoryResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Blog\Resources\CategoryResource;
|
use App\Filament\Blog\Resources\CategoryResource;
|
||||||
|
use App\Filament\Resources\Pages\AuditedEditRecord;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditCategory extends EditRecord
|
class EditCategory extends AuditedEditRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = CategoryResource::class;
|
protected static string $resource = CategoryResource::class;
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Actions\DeleteAction::make(),
|
Actions\DeleteAction::make()
|
||||||
|
->after(fn ($record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +30,7 @@ class EditCategory extends EditRecord
|
|||||||
'description_de' => 'nullable|string',
|
'description_de' => 'nullable|string',
|
||||||
'name_en' => 'nullable|string|max:255',
|
'name_en' => 'nullable|string|max:255',
|
||||||
'description_en' => 'nullable|string',
|
'description_en' => 'nullable|string',
|
||||||
'slug' => 'required|string|max:255|unique:blog_categories,slug,' . $this->record->id,
|
'slug' => 'required|string|max:255|unique:blog_categories,slug,'.$this->record->id,
|
||||||
'is_visible' => 'boolean',
|
'is_visible' => 'boolean',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -40,12 +46,13 @@ class EditCategory extends EditRecord
|
|||||||
public function save(bool $shouldRedirect = true, bool $shouldSendSavedNotification = true): void
|
public function save(bool $shouldRedirect = true, bool $shouldSendSavedNotification = true): void
|
||||||
{
|
{
|
||||||
$state = $this->form->getState();
|
$state = $this->form->getState();
|
||||||
\Illuminate\Support\Facades\Log::info('EditCategory Save - Full State:', $state);
|
|
||||||
|
|
||||||
$data = $state['data'] ?? $state;
|
$data = $state['data'] ?? $state;
|
||||||
|
|
||||||
$data = \App\Filament\Blog\Resources\CategoryResource::mutateFormDataBeforeSave($data);
|
$data = \App\Filament\Blog\Resources\CategoryResource::mutateFormDataBeforeSave($data);
|
||||||
|
|
||||||
$this->record->update($data);
|
$this->record->update($data);
|
||||||
|
|
||||||
|
parent::afterSave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ class ListCategories extends ListRecords
|
|||||||
Actions\CreateAction::make(),
|
Actions\CreateAction::make(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Filament\Blog\Traits\HasContentEditor;
|
|||||||
use App\Filament\Clusters\RareAdmin\RareAdminCluster;
|
use App\Filament\Clusters\RareAdmin\RareAdminCluster;
|
||||||
use App\Models\BlogCategory;
|
use App\Models\BlogCategory;
|
||||||
use App\Models\BlogPost;
|
use App\Models\BlogPost;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\DeleteAction;
|
use Filament\Actions\DeleteAction;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
@@ -29,6 +30,7 @@ use Filament\Tables\Columns\TextColumn;
|
|||||||
use Filament\Tables\Filters\TernaryFilter;
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -77,9 +79,10 @@ class PostResource extends Resource
|
|||||||
->label('Inhalt')
|
->label('Inhalt')
|
||||||
->required()
|
->required()
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
TextInput::make('excerpt.de')
|
Textarea::make('excerpt.de')
|
||||||
->label('Auszug')
|
->label('Auszug')
|
||||||
->maxLength(255),
|
->maxLength(65535)
|
||||||
|
->columnSpanFull(),
|
||||||
TextInput::make('meta_title.de')
|
TextInput::make('meta_title.de')
|
||||||
->label('Meta-Titel')
|
->label('Meta-Titel')
|
||||||
->maxLength(255),
|
->maxLength(255),
|
||||||
@@ -97,9 +100,10 @@ class PostResource extends Resource
|
|||||||
MarkdownEditor::make('content.en')
|
MarkdownEditor::make('content.en')
|
||||||
->label('Inhalt')
|
->label('Inhalt')
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
TextInput::make('excerpt.en')
|
Textarea::make('excerpt.en')
|
||||||
->label('Auszug')
|
->label('Auszug')
|
||||||
->maxLength(255),
|
->maxLength(65535)
|
||||||
|
->columnSpanFull(),
|
||||||
TextInput::make('meta_title.en')
|
TextInput::make('meta_title.en')
|
||||||
->label('Meta-Titel')
|
->label('Meta-Titel')
|
||||||
->maxLength(255),
|
->maxLength(255),
|
||||||
@@ -119,9 +123,10 @@ class PostResource extends Resource
|
|||||||
->unique(BlogPost::class, 'slug', ignoreRecord: true)
|
->unique(BlogPost::class, 'slug', ignoreRecord: true)
|
||||||
->maxLength(255)
|
->maxLength(255)
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
FileUpload::make('featured_image')
|
FileUpload::make('banner')
|
||||||
->label('Featured Image')
|
->label('Featured Image')
|
||||||
->image()
|
->image()
|
||||||
|
->disk('public')
|
||||||
->directory('blog')
|
->directory('blog')
|
||||||
->visibility('public'),
|
->visibility('public'),
|
||||||
Select::make('blog_category_id')
|
Select::make('blog_category_id')
|
||||||
@@ -243,11 +248,27 @@ class PostResource extends Resource
|
|||||||
->actions([
|
->actions([
|
||||||
DeleteAction::make()
|
DeleteAction::make()
|
||||||
->icon('heroicon-o-trash')
|
->icon('heroicon-o-trash')
|
||||||
->label(''),
|
->label('')
|
||||||
|
->after(fn (BlogPost $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
DeleteBulkAction::make(),
|
DeleteBulkAction::make()
|
||||||
|
->after(function (Collection $records): void {
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
namespace App\Filament\Blog\Resources\PostResource\Pages;
|
namespace App\Filament\Blog\Resources\PostResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Blog\Resources\PostResource;
|
use App\Filament\Blog\Resources\PostResource;
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
use App\Filament\Resources\Pages\AuditedCreateRecord;
|
||||||
|
|
||||||
class CreatePost extends CreateRecord
|
class CreatePost extends AuditedCreateRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = PostResource::class;
|
protected static string $resource = PostResource::class;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,11 @@
|
|||||||
namespace App\Filament\Blog\Resources\PostResource\Pages;
|
namespace App\Filament\Blog\Resources\PostResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Blog\Resources\PostResource;
|
use App\Filament\Blog\Resources\PostResource;
|
||||||
|
use App\Filament\Resources\Pages\AuditedEditRecord;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditPost extends EditRecord
|
class EditPost extends AuditedEditRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = PostResource::class;
|
protected static string $resource = PostResource::class;
|
||||||
|
|
||||||
@@ -14,7 +15,12 @@ class EditPost extends EditRecord
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Actions\ViewAction::make(),
|
Actions\ViewAction::make(),
|
||||||
Actions\DeleteAction::make(),
|
Actions\DeleteAction::make()
|
||||||
|
->after(fn ($record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ class ListPosts extends ListRecords
|
|||||||
Actions\CreateAction::make(),
|
Actions\CreateAction::make(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ use Filament\Resources\Pages\ViewRecord;
|
|||||||
class ViewPost extends ViewRecord
|
class ViewPost extends ViewRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = PostResource::class;
|
protected static string $resource = PostResource::class;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,4 +26,4 @@ trait HasContentEditor
|
|||||||
'h3',
|
'h3',
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\DailyOps\DailyOpsCluster;
|
||||||
|
use App\Filament\Widgets\JoinTokenOverviewWidget;
|
||||||
|
use App\Filament\Widgets\JoinTokenTopTokensWidget;
|
||||||
|
use App\Filament\Widgets\JoinTokenTrendWidget;
|
||||||
|
use App\Models\Event;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Pages\Dashboard;
|
||||||
|
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
class JoinTokenAnalyticsDashboard extends Dashboard
|
||||||
|
{
|
||||||
|
use HasFiltersForm;
|
||||||
|
|
||||||
|
protected static ?string $cluster = DailyOpsCluster::class;
|
||||||
|
|
||||||
|
protected static string $routePath = 'join-token-analytics';
|
||||||
|
|
||||||
|
protected static null|string|BackedEnum $navigationIcon = 'heroicon-o-chart-bar';
|
||||||
|
|
||||||
|
protected static null|string|UnitEnum $navigationGroup = null;
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 12;
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): UnitEnum|string|null
|
||||||
|
{
|
||||||
|
return __('admin.nav.security');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('admin.join_token_analytics.navigation.label');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeading(): string
|
||||||
|
{
|
||||||
|
return __('admin.join_token_analytics.heading');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSubheading(): ?string
|
||||||
|
{
|
||||||
|
return __('admin.join_token_analytics.subheading');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColumns(): int|array
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWidgets(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
JoinTokenOverviewWidget::class,
|
||||||
|
JoinTokenTrendWidget::class,
|
||||||
|
JoinTokenTopTokensWidget::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function filtersForm(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Section::make()
|
||||||
|
->schema([
|
||||||
|
Select::make('range')
|
||||||
|
->label(__('admin.join_token_analytics.filters.range'))
|
||||||
|
->options(trans('admin.join_token_analytics.filters.range_options'))
|
||||||
|
->default('24h')
|
||||||
|
->native(false),
|
||||||
|
Select::make('event_id')
|
||||||
|
->label(__('admin.join_token_analytics.filters.event'))
|
||||||
|
->placeholder(__('admin.join_token_analytics.filters.event_placeholder'))
|
||||||
|
->searchable()
|
||||||
|
->getSearchResultsUsing(fn (string $search): array => $this->searchEvents($search))
|
||||||
|
->getOptionLabelUsing(fn ($value): ?string => $this->resolveEventLabel($value))
|
||||||
|
->native(false),
|
||||||
|
])
|
||||||
|
->columns(2),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function searchEvents(string $search): array
|
||||||
|
{
|
||||||
|
return Event::query()
|
||||||
|
->with('tenant')
|
||||||
|
->when($search !== '', function ($query) use ($search) {
|
||||||
|
$query->where('slug', 'like', "%{$search}%")
|
||||||
|
->orWhere('name->de', 'like', "%{$search}%")
|
||||||
|
->orWhere('name->en', 'like', "%{$search}%");
|
||||||
|
})
|
||||||
|
->orderByDesc('date')
|
||||||
|
->limit(25)
|
||||||
|
->get()
|
||||||
|
->mapWithKeys(fn (Event $event) => [$event->id => $this->formatEventLabel($event)])
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function resolveEventLabel(mixed $value): ?string
|
||||||
|
{
|
||||||
|
if (! is_numeric($value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$event = Event::query()
|
||||||
|
->with('tenant')
|
||||||
|
->find((int) $value);
|
||||||
|
|
||||||
|
return $event ? $this->formatEventLabel($event) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function formatEventLabel(Event $event): string
|
||||||
|
{
|
||||||
|
$locale = app()->getLocale();
|
||||||
|
$name = $event->name[$locale] ?? $event->name['de'] ?? $event->name['en'] ?? $event->slug ?? __('admin.common.unnamed');
|
||||||
|
$tenant = $event->tenant?->name ?? __('admin.common.unnamed');
|
||||||
|
$date = $event->date?->format('Y-m-d');
|
||||||
|
|
||||||
|
return $date ? "{$name} ({$tenant}) {$date}" : "{$name} ({$tenant})";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Resources\Photos\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\Photos\PhotoResource;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreatePhoto extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = PhotoResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Resources\Photos\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\Photos\PhotoResource;
|
||||||
|
use App\Filament\Resources\Pages\AuditedEditRecord;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
|
use Filament\Actions\ViewAction;
|
||||||
|
|
||||||
|
class EditPhoto extends AuditedEditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = PhotoResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ViewAction::make(),
|
||||||
|
DeleteAction::make()
|
||||||
|
->after(fn ($record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Resources\Photos\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\Photos\PhotoResource;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListPhotos extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = PhotoResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Resources\Photos\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\Photos\PhotoResource;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewPhoto extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = PhotoResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Resources\Photos;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\DailyOps\DailyOpsCluster;
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\Photos\Pages\ListPhotos;
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\Photos\Pages\ViewPhoto;
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\Photos\Schemas\PhotoForm;
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\Photos\Schemas\PhotoInfolist;
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\Photos\Tables\PhotosTable;
|
||||||
|
use App\Models\Photo;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
class PhotoResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = Photo::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedShieldCheck;
|
||||||
|
|
||||||
|
protected static ?string $cluster = DailyOpsCluster::class;
|
||||||
|
|
||||||
|
protected static ?string $slug = 'moderation-queue';
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'id';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 20;
|
||||||
|
|
||||||
|
public static function canCreate(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return PhotoForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function infolist(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return PhotoInfolist::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return PhotosTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->with(['event.tenant', 'moderator']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('admin.moderation.navigation.label');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): UnitEnum|string|null
|
||||||
|
{
|
||||||
|
return __('admin.nav.curation');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListPhotos::route('/'),
|
||||||
|
'view' => ViewPhoto::route('/{record}'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Resources\Photos\Schemas;
|
||||||
|
|
||||||
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Components\Toggle;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class PhotoForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Select::make('event_id')
|
||||||
|
->relationship('event', 'name')
|
||||||
|
->required(),
|
||||||
|
Select::make('emotion_id')
|
||||||
|
->relationship('emotion', 'name'),
|
||||||
|
Select::make('task_id')
|
||||||
|
->relationship('task', 'title'),
|
||||||
|
TextInput::make('guest_name')
|
||||||
|
->required(),
|
||||||
|
TextInput::make('file_path')
|
||||||
|
->required(),
|
||||||
|
TextInput::make('thumbnail_path')
|
||||||
|
->required(),
|
||||||
|
TextInput::make('likes_count')
|
||||||
|
->required()
|
||||||
|
->numeric()
|
||||||
|
->default(0),
|
||||||
|
Toggle::make('is_featured')
|
||||||
|
->required(),
|
||||||
|
Textarea::make('metadata')
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextInput::make('tenant_id')
|
||||||
|
->numeric(),
|
||||||
|
Select::make('media_asset_id')
|
||||||
|
->relationship('mediaAsset', 'id'),
|
||||||
|
TextInput::make('security_scan_status')
|
||||||
|
->required()
|
||||||
|
->default('pending'),
|
||||||
|
Textarea::make('security_scan_message')
|
||||||
|
->columnSpanFull(),
|
||||||
|
DateTimePicker::make('security_scanned_at'),
|
||||||
|
Textarea::make('security_meta')
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextInput::make('ingest_source')
|
||||||
|
->required()
|
||||||
|
->default('guest_pwa'),
|
||||||
|
TextInput::make('filename'),
|
||||||
|
TextInput::make('original_name'),
|
||||||
|
TextInput::make('mime_type'),
|
||||||
|
TextInput::make('size')
|
||||||
|
->numeric(),
|
||||||
|
TextInput::make('width')
|
||||||
|
->numeric(),
|
||||||
|
TextInput::make('height')
|
||||||
|
->numeric(),
|
||||||
|
TextInput::make('status')
|
||||||
|
->required()
|
||||||
|
->default('pending'),
|
||||||
|
TextInput::make('uploader_id')
|
||||||
|
->numeric(),
|
||||||
|
TextInput::make('ip_address'),
|
||||||
|
Textarea::make('user_agent')
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextInput::make('created_by_device_id'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Resources\Photos\Schemas;
|
||||||
|
|
||||||
|
use App\Models\Photo;
|
||||||
|
use Filament\Infolists\Components\ImageEntry;
|
||||||
|
use Filament\Infolists\Components\TextEntry;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class PhotoInfolist
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Section::make(__('admin.moderation.sections.photo'))
|
||||||
|
->columns(3)
|
||||||
|
->schema([
|
||||||
|
ImageEntry::make('thumbnail_path')
|
||||||
|
->label(__('admin.moderation.fields.photo'))
|
||||||
|
->disk('public')
|
||||||
|
->visibility('public')
|
||||||
|
->getStateUsing(fn (Photo $record) => $record->thumbnail_path ?: $record->file_path)
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextEntry::make('event.name')
|
||||||
|
->label(__('admin.moderation.fields.event'))
|
||||||
|
->placeholder('—'),
|
||||||
|
TextEntry::make('event.tenant.name')
|
||||||
|
->label(__('admin.moderation.fields.tenant'))
|
||||||
|
->placeholder('—'),
|
||||||
|
TextEntry::make('guest_name')
|
||||||
|
->label(__('admin.moderation.fields.uploader'))
|
||||||
|
->placeholder('—'),
|
||||||
|
TextEntry::make('created_at')
|
||||||
|
->label(__('admin.moderation.fields.uploaded_at'))
|
||||||
|
->since()
|
||||||
|
->placeholder('—'),
|
||||||
|
TextEntry::make('ingest_source')
|
||||||
|
->label(__('admin.moderation.fields.ingest_source'))
|
||||||
|
->formatStateUsing(fn (?string $state) => match ($state) {
|
||||||
|
Photo::SOURCE_GUEST_PWA => __('admin.moderation.ingest_sources.guest_pwa'),
|
||||||
|
Photo::SOURCE_TENANT_ADMIN => __('admin.moderation.ingest_sources.tenant_admin'),
|
||||||
|
Photo::SOURCE_PHOTOBOOTH => __('admin.moderation.ingest_sources.photobooth'),
|
||||||
|
Photo::SOURCE_SPARKBOOTH => __('admin.moderation.ingest_sources.sparkbooth'),
|
||||||
|
Photo::SOURCE_UNKNOWN => __('admin.moderation.ingest_sources.unknown'),
|
||||||
|
default => '—',
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
Section::make(__('admin.moderation.sections.moderation'))
|
||||||
|
->columns(2)
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('status')
|
||||||
|
->label(__('admin.moderation.fields.status'))
|
||||||
|
->badge()
|
||||||
|
->color(fn (?string $state) => match ($state) {
|
||||||
|
'approved' => 'success',
|
||||||
|
'rejected' => 'danger',
|
||||||
|
'hidden' => 'gray',
|
||||||
|
default => 'warning',
|
||||||
|
})
|
||||||
|
->formatStateUsing(fn (?string $state) => match ($state) {
|
||||||
|
'pending' => __('admin.moderation.status.pending'),
|
||||||
|
'approved' => __('admin.moderation.status.approved'),
|
||||||
|
'rejected' => __('admin.moderation.status.rejected'),
|
||||||
|
'hidden' => __('admin.moderation.status.hidden'),
|
||||||
|
default => '—',
|
||||||
|
}),
|
||||||
|
TextEntry::make('moderator.name')
|
||||||
|
->label(__('admin.moderation.fields.moderated_by'))
|
||||||
|
->placeholder('—'),
|
||||||
|
TextEntry::make('moderated_at')
|
||||||
|
->label(__('admin.moderation.fields.moderated_at'))
|
||||||
|
->dateTime()
|
||||||
|
->placeholder('—'),
|
||||||
|
TextEntry::make('moderation_notes')
|
||||||
|
->label(__('admin.moderation.fields.moderation_notes'))
|
||||||
|
->placeholder('—')
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextEntry::make('security_scan_status')
|
||||||
|
->label(__('admin.moderation.fields.security_scan_status'))
|
||||||
|
->badge()
|
||||||
|
->color(fn (?string $state) => match ($state) {
|
||||||
|
'clean', 'skipped', 'stripped' => 'success',
|
||||||
|
'infected' => 'danger',
|
||||||
|
'error' => 'warning',
|
||||||
|
default => 'gray',
|
||||||
|
})
|
||||||
|
->formatStateUsing(fn (?string $state) => match ($state) {
|
||||||
|
'pending' => __('admin.moderation.security_scan.pending'),
|
||||||
|
'clean' => __('admin.moderation.security_scan.clean'),
|
||||||
|
'infected' => __('admin.moderation.security_scan.infected'),
|
||||||
|
'skipped' => __('admin.moderation.security_scan.skipped'),
|
||||||
|
'stripped' => __('admin.moderation.security_scan.stripped'),
|
||||||
|
'error' => __('admin.moderation.security_scan.error'),
|
||||||
|
default => '—',
|
||||||
|
}),
|
||||||
|
TextEntry::make('security_scan_message')
|
||||||
|
->label(__('admin.moderation.fields.security_scan_message'))
|
||||||
|
->placeholder('—')
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextEntry::make('security_scanned_at')
|
||||||
|
->label(__('admin.moderation.fields.security_scanned_at'))
|
||||||
|
->dateTime()
|
||||||
|
->placeholder('—'),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,292 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Resources\Photos\Tables;
|
||||||
|
|
||||||
|
use App\Models\Event;
|
||||||
|
use App\Models\Photo;
|
||||||
|
use App\Models\Tenant;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Actions\BulkAction;
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\ViewAction;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Forms\Components\DatePicker;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Columns\ImageColumn;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
|
||||||
|
class PhotosTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->defaultSort('created_at', 'desc')
|
||||||
|
->columns([
|
||||||
|
ImageColumn::make('thumbnail_path')
|
||||||
|
->label(__('admin.moderation.table.photo'))
|
||||||
|
->disk('public')
|
||||||
|
->visibility('public')
|
||||||
|
->circular()
|
||||||
|
->getStateUsing(fn (Photo $record) => $record->thumbnail_path ?: $record->file_path),
|
||||||
|
Tables\Columns\TextColumn::make('event.name')
|
||||||
|
->label(__('admin.moderation.table.event'))
|
||||||
|
->searchable()
|
||||||
|
->limit(30),
|
||||||
|
Tables\Columns\TextColumn::make('event.tenant.name')
|
||||||
|
->label(__('admin.moderation.table.tenant'))
|
||||||
|
->limit(30),
|
||||||
|
Tables\Columns\TextColumn::make('guest_name')
|
||||||
|
->label(__('admin.moderation.table.uploader'))
|
||||||
|
->searchable()
|
||||||
|
->limit(20),
|
||||||
|
Tables\Columns\TextColumn::make('status')
|
||||||
|
->label(__('admin.moderation.table.status'))
|
||||||
|
->badge()
|
||||||
|
->color(fn (?string $state) => match ($state) {
|
||||||
|
'approved' => 'success',
|
||||||
|
'rejected' => 'danger',
|
||||||
|
'hidden' => 'gray',
|
||||||
|
default => 'warning',
|
||||||
|
})
|
||||||
|
->formatStateUsing(fn (?string $state) => self::statusLabels()[$state] ?? '—')
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('security_scan_status')
|
||||||
|
->label(__('admin.moderation.table.security_scan'))
|
||||||
|
->badge()
|
||||||
|
->color(fn (?string $state) => match ($state) {
|
||||||
|
'clean', 'skipped', 'stripped' => 'success',
|
||||||
|
'infected' => 'danger',
|
||||||
|
'error' => 'warning',
|
||||||
|
default => 'gray',
|
||||||
|
})
|
||||||
|
->formatStateUsing(fn (?string $state) => self::securityScanLabels()[$state] ?? '—')
|
||||||
|
->toggleable(),
|
||||||
|
Tables\Columns\TextColumn::make('ingest_source')
|
||||||
|
->label(__('admin.moderation.table.ingest_source'))
|
||||||
|
->badge()
|
||||||
|
->color('gray')
|
||||||
|
->formatStateUsing(fn (?string $state) => self::ingestSourceLabels()[$state] ?? '—')
|
||||||
|
->toggleable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->label(__('admin.moderation.table.uploaded_at'))
|
||||||
|
->since()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('moderator.name')
|
||||||
|
->label(__('admin.moderation.table.moderated_by'))
|
||||||
|
->placeholder('—')
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('moderated_at')
|
||||||
|
->label(__('admin.moderation.table.moderated_at'))
|
||||||
|
->since()
|
||||||
|
->placeholder('—')
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
SelectFilter::make('status')
|
||||||
|
->label(__('admin.moderation.filters.status'))
|
||||||
|
->options(self::statusLabels())
|
||||||
|
->default('pending'),
|
||||||
|
SelectFilter::make('ingest_source')
|
||||||
|
->label(__('admin.moderation.filters.ingest_source'))
|
||||||
|
->options(self::ingestSourceLabels())
|
||||||
|
->default(Photo::SOURCE_GUEST_PWA),
|
||||||
|
SelectFilter::make('security_scan_status')
|
||||||
|
->label(__('admin.moderation.filters.security_scan_status'))
|
||||||
|
->options(self::securityScanLabels()),
|
||||||
|
SelectFilter::make('tenant_id')
|
||||||
|
->label(__('admin.common.tenant'))
|
||||||
|
->options(fn () => Tenant::query()->orderBy('name')->pluck('name', 'id')->toArray())
|
||||||
|
->searchable(),
|
||||||
|
SelectFilter::make('event_id')
|
||||||
|
->label(__('admin.common.event'))
|
||||||
|
->options(fn () => Event::query()->orderBy('name')->pluck('name', 'id')->toArray())
|
||||||
|
->searchable(),
|
||||||
|
Filter::make('created_at')
|
||||||
|
->label(__('admin.moderation.filters.uploaded_at'))
|
||||||
|
->form([
|
||||||
|
DatePicker::make('from')->label(__('admin.common.from')),
|
||||||
|
DatePicker::make('until')->label(__('admin.common.until')),
|
||||||
|
])
|
||||||
|
->query(function (Builder $query, array $data): Builder {
|
||||||
|
return $query
|
||||||
|
->when(
|
||||||
|
$data['from'] ?? null,
|
||||||
|
fn (Builder $query, string $date): Builder => $query->whereDate('created_at', '>=', $date)
|
||||||
|
)
|
||||||
|
->when(
|
||||||
|
$data['until'] ?? null,
|
||||||
|
fn (Builder $query, string $date): Builder => $query->whereDate('created_at', '<=', $date)
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
ViewAction::make(),
|
||||||
|
Action::make('approve')
|
||||||
|
->label(__('admin.moderation.actions.approve'))
|
||||||
|
->color('success')
|
||||||
|
->icon(Heroicon::OutlinedCheckCircle)
|
||||||
|
->visible(fn (Photo $record) => $record->status === 'pending')
|
||||||
|
->form([
|
||||||
|
self::moderationNotesField(false),
|
||||||
|
])
|
||||||
|
->requiresConfirmation()
|
||||||
|
->action(fn (Photo $record, array $data) => self::applyModeration($record, 'approved', $data['moderation_notes'] ?? null)),
|
||||||
|
Action::make('reject')
|
||||||
|
->label(__('admin.moderation.actions.reject'))
|
||||||
|
->color('danger')
|
||||||
|
->icon(Heroicon::OutlinedXCircle)
|
||||||
|
->visible(fn (Photo $record) => $record->status === 'pending')
|
||||||
|
->form([
|
||||||
|
self::moderationNotesField(true),
|
||||||
|
])
|
||||||
|
->requiresConfirmation()
|
||||||
|
->action(fn (Photo $record, array $data) => self::applyModeration($record, 'rejected', $data['moderation_notes'] ?? null)),
|
||||||
|
Action::make('hide')
|
||||||
|
->label(__('admin.moderation.actions.hide'))
|
||||||
|
->color('gray')
|
||||||
|
->icon(Heroicon::OutlinedEyeSlash)
|
||||||
|
->visible(fn (Photo $record) => $record->status !== 'hidden')
|
||||||
|
->form([
|
||||||
|
self::moderationNotesField(false),
|
||||||
|
])
|
||||||
|
->requiresConfirmation()
|
||||||
|
->action(fn (Photo $record, array $data) => self::applyModeration($record, 'hidden', $data['moderation_notes'] ?? null)),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
BulkAction::make('approve')
|
||||||
|
->label(__('admin.moderation.actions.approve_selected'))
|
||||||
|
->icon(Heroicon::OutlinedCheckCircle)
|
||||||
|
->color('success')
|
||||||
|
->form([
|
||||||
|
self::moderationNotesField(false),
|
||||||
|
])
|
||||||
|
->requiresConfirmation()
|
||||||
|
->action(fn (Collection $records, array $data) => self::applyModerationToRecords($records, 'approved', $data['moderation_notes'] ?? null)),
|
||||||
|
BulkAction::make('reject')
|
||||||
|
->label(__('admin.moderation.actions.reject_selected'))
|
||||||
|
->icon(Heroicon::OutlinedXCircle)
|
||||||
|
->color('danger')
|
||||||
|
->form([
|
||||||
|
self::moderationNotesField(true),
|
||||||
|
])
|
||||||
|
->requiresConfirmation()
|
||||||
|
->action(fn (Collection $records, array $data) => self::applyModerationToRecords($records, 'rejected', $data['moderation_notes'] ?? null)),
|
||||||
|
BulkAction::make('hide')
|
||||||
|
->label(__('admin.moderation.actions.hide_selected'))
|
||||||
|
->icon(Heroicon::OutlinedEyeSlash)
|
||||||
|
->color('gray')
|
||||||
|
->form([
|
||||||
|
self::moderationNotesField(false),
|
||||||
|
])
|
||||||
|
->requiresConfirmation()
|
||||||
|
->action(fn (Collection $records, array $data) => self::applyModerationToRecords($records, 'hidden', $data['moderation_notes'] ?? null)),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function moderationNotesField(bool $required): Textarea
|
||||||
|
{
|
||||||
|
return Textarea::make('moderation_notes')
|
||||||
|
->label(__('admin.moderation.fields.moderation_notes'))
|
||||||
|
->maxLength(1000)
|
||||||
|
->rows(3)
|
||||||
|
->required($required);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function applyModeration(Photo $record, string $status, ?string $notes): void
|
||||||
|
{
|
||||||
|
$record->update([
|
||||||
|
'status' => $status,
|
||||||
|
'moderation_notes' => $notes,
|
||||||
|
'moderated_at' => now(),
|
||||||
|
'moderated_by' => Filament::auth()->id(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
app(SuperAdminAuditLogger::class)->record(
|
||||||
|
'photo.'.$status,
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata([
|
||||||
|
'status',
|
||||||
|
'moderation_notes',
|
||||||
|
'moderated_at',
|
||||||
|
'moderated_by',
|
||||||
|
]),
|
||||||
|
source: self::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function applyModerationToRecords(Collection $records, string $status, ?string $notes): int
|
||||||
|
{
|
||||||
|
$moderatedAt = now();
|
||||||
|
$moderatedBy = Filament::auth()->id();
|
||||||
|
|
||||||
|
$updated = Photo::query()
|
||||||
|
->whereIn('id', $records->pluck('id'))
|
||||||
|
->where('status', 'pending')
|
||||||
|
->update([
|
||||||
|
'status' => $status,
|
||||||
|
'moderation_notes' => $notes,
|
||||||
|
'moderated_at' => $moderatedAt,
|
||||||
|
'moderated_by' => $moderatedBy,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->record(
|
||||||
|
'photo.'.$status,
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata([
|
||||||
|
'status',
|
||||||
|
'moderation_notes',
|
||||||
|
'moderated_at',
|
||||||
|
'moderated_by',
|
||||||
|
]),
|
||||||
|
source: self::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function statusLabels(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'pending' => __('admin.moderation.status.pending'),
|
||||||
|
'approved' => __('admin.moderation.status.approved'),
|
||||||
|
'rejected' => __('admin.moderation.status.rejected'),
|
||||||
|
'hidden' => __('admin.moderation.status.hidden'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function ingestSourceLabels(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Photo::SOURCE_GUEST_PWA => __('admin.moderation.ingest_sources.guest_pwa'),
|
||||||
|
Photo::SOURCE_TENANT_ADMIN => __('admin.moderation.ingest_sources.tenant_admin'),
|
||||||
|
Photo::SOURCE_PHOTOBOOTH => __('admin.moderation.ingest_sources.photobooth'),
|
||||||
|
Photo::SOURCE_SPARKBOOTH => __('admin.moderation.ingest_sources.sparkbooth'),
|
||||||
|
Photo::SOURCE_UNKNOWN => __('admin.moderation.ingest_sources.unknown'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function securityScanLabels(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'pending' => __('admin.moderation.security_scan.pending'),
|
||||||
|
'clean' => __('admin.moderation.security_scan.clean'),
|
||||||
|
'infected' => __('admin.moderation.security_scan.infected'),
|
||||||
|
'skipped' => __('admin.moderation.security_scan.skipped'),
|
||||||
|
'stripped' => __('admin.moderation.security_scan.stripped'),
|
||||||
|
'error' => __('admin.moderation.security_scan.error'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Resources\TenantCheckoutHealths\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\TenantCheckoutHealths\TenantCheckoutHealthResource;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListTenantCheckoutHealths extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = TenantCheckoutHealthResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,267 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Resources\TenantCheckoutHealths\Tables;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\TenantCheckoutHealths\TenantCheckoutHealthResource;
|
||||||
|
use App\Models\CheckoutSession;
|
||||||
|
use App\Models\Tenant;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Tables\Columns\IconColumn;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
class TenantCheckoutHealthTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('name')
|
||||||
|
->label(__('admin.common.tenant'))
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
TextColumn::make('slug')
|
||||||
|
->label(__('admin.common.slug'))
|
||||||
|
->searchable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('contact_email')
|
||||||
|
->label(__('admin.tenants.fields.contact_email'))
|
||||||
|
->searchable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('subscription_status')
|
||||||
|
->label('Subscription')
|
||||||
|
->badge()
|
||||||
|
->color(fn (?string $state) => match ($state) {
|
||||||
|
'active' => 'success',
|
||||||
|
'suspended' => 'warning',
|
||||||
|
'expired' => 'danger',
|
||||||
|
'free' => 'gray',
|
||||||
|
default => 'gray',
|
||||||
|
}),
|
||||||
|
TextColumn::make('active_reseller_package')
|
||||||
|
->label('Active package')
|
||||||
|
->getStateUsing(fn (Tenant $record) => $record->activeResellerPackage?->package?->name ?? '—')
|
||||||
|
->badge()
|
||||||
|
->color(fn (string $state) => $state === '—' ? 'gray' : 'success')
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
IconColumn::make('status_mismatch')
|
||||||
|
->label('Status mismatch')
|
||||||
|
->boolean()
|
||||||
|
->getStateUsing(fn (Tenant $record) => self::hasStatusMismatch($record)),
|
||||||
|
TextColumn::make('last_checkout_transaction_at')
|
||||||
|
->label('Last transaction')
|
||||||
|
->badge()
|
||||||
|
->color(fn (?Carbon $state) => self::transactionAgeColor($state))
|
||||||
|
->getStateUsing(fn (Tenant $record) => $record->last_checkout_transaction_at
|
||||||
|
? Carbon::parse($record->last_checkout_transaction_at)
|
||||||
|
: null)
|
||||||
|
->formatStateUsing(fn (?Carbon $state) => $state?->diffForHumans() ?? '—')
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('checkout_transaction_count_window')
|
||||||
|
->label('Transactions (30d)')
|
||||||
|
->default('0')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(),
|
||||||
|
TextColumn::make('checkout_transaction_total_window')
|
||||||
|
->label('Total (30d)')
|
||||||
|
->default(0)
|
||||||
|
->money('EUR')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(),
|
||||||
|
TextColumn::make('checkout_refund_count_window')
|
||||||
|
->label('Refunds (30d)')
|
||||||
|
->badge()
|
||||||
|
->color(fn (?int $state) => $state && $state > 0 ? 'danger' : 'gray')
|
||||||
|
->default('0')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('checkout_refund_total_window')
|
||||||
|
->label('Refund total (30d)')
|
||||||
|
->default(0)
|
||||||
|
->money('EUR')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('checkout_requires_action_count')
|
||||||
|
->label('Checkout action required')
|
||||||
|
->badge()
|
||||||
|
->color(fn (?int $state) => $state && $state > 0 ? 'warning' : 'gray')
|
||||||
|
->default('0')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('checkout_processing_count')
|
||||||
|
->label('Checkout processing')
|
||||||
|
->badge()
|
||||||
|
->color(fn (?int $state) => $state && $state > 0 ? 'warning' : 'gray')
|
||||||
|
->default('0')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('checkout_expired_count')
|
||||||
|
->label('Checkout expired')
|
||||||
|
->badge()
|
||||||
|
->color(fn (?int $state) => $state && $state > 0 ? 'danger' : 'gray')
|
||||||
|
->default('0')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('checkout_transaction_count')
|
||||||
|
->label('Transactions (all)')
|
||||||
|
->default('0')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('checkout_transaction_total')
|
||||||
|
->label('Total (all)')
|
||||||
|
->default(0)
|
||||||
|
->money('EUR')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
Filter::make('status_mismatch')
|
||||||
|
->label('Status mismatch')
|
||||||
|
->indicator('Status mismatch')
|
||||||
|
->query(fn (Builder $query) => self::applyStatusMismatchFilter($query)),
|
||||||
|
Filter::make('active_package')
|
||||||
|
->label('Active package')
|
||||||
|
->indicator('Active package')
|
||||||
|
->query(fn (Builder $query) => $query->whereHas('activeResellerPackage', function (Builder $query) {
|
||||||
|
$query->where('active', true)
|
||||||
|
->where(function (Builder $query) {
|
||||||
|
$query->whereNull('expires_at')
|
||||||
|
->orWhere('expires_at', '>=', now());
|
||||||
|
});
|
||||||
|
})),
|
||||||
|
Filter::make('not_suspended_or_deleted')
|
||||||
|
->label('Not suspended/deleted')
|
||||||
|
->indicator('Not suspended/deleted')
|
||||||
|
->query(fn (Builder $query) => $query
|
||||||
|
->where('is_suspended', false)
|
||||||
|
->whereNull('pending_deletion_at')
|
||||||
|
->whereNull('anonymized_at')),
|
||||||
|
Filter::make('checkout_transaction_stale')
|
||||||
|
->label('Stale transactions')
|
||||||
|
->indicator('Stale transactions')
|
||||||
|
->query(function (Builder $query): Builder {
|
||||||
|
$cutoff = now()->subDays(TenantCheckoutHealthResource::TRANSACTION_WINDOW_DAYS);
|
||||||
|
$provider = TenantCheckoutHealthResource::provider();
|
||||||
|
|
||||||
|
return $query
|
||||||
|
->whereHas('purchases', fn (Builder $query) => $query->where('provider', $provider))
|
||||||
|
->whereDoesntHave('purchases', fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider)
|
||||||
|
->where('purchased_at', '>=', $cutoff));
|
||||||
|
}),
|
||||||
|
Filter::make('checkout_attention')
|
||||||
|
->label('Checkout attention')
|
||||||
|
->indicator('Checkout attention')
|
||||||
|
->query(fn (Builder $query) => $query->whereHas('checkoutSessions', function (Builder $query) {
|
||||||
|
$query->where('provider', TenantCheckoutHealthResource::provider())
|
||||||
|
->where(function (Builder $query) {
|
||||||
|
$query->whereIn('status', [
|
||||||
|
CheckoutSession::STATUS_REQUIRES_CUSTOMER_ACTION,
|
||||||
|
CheckoutSession::STATUS_PROCESSING,
|
||||||
|
])
|
||||||
|
->orWhere(function (Builder $query) {
|
||||||
|
$query->whereNotIn('status', [
|
||||||
|
CheckoutSession::STATUS_COMPLETED,
|
||||||
|
CheckoutSession::STATUS_CANCELLED,
|
||||||
|
])
|
||||||
|
->whereNotNull('expires_at')
|
||||||
|
->where('expires_at', '<', now());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})),
|
||||||
|
Filter::make('refund_spike')
|
||||||
|
->label('Refund spike (30d)')
|
||||||
|
->form([
|
||||||
|
TextInput::make('min_refunds')
|
||||||
|
->label('Minimum refunds')
|
||||||
|
->numeric()
|
||||||
|
->default(1)
|
||||||
|
->minValue(1),
|
||||||
|
])
|
||||||
|
->indicateUsing(function (array $data): ?string {
|
||||||
|
$min = (int) ($data['min_refunds'] ?? 0);
|
||||||
|
|
||||||
|
return $min > 0 ? "Refunds >= {$min} (30d)" : null;
|
||||||
|
})
|
||||||
|
->query(function (Builder $query, array $data): Builder {
|
||||||
|
$min = (int) ($data['min_refunds'] ?? 0);
|
||||||
|
|
||||||
|
if ($min < 1) {
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cutoff = now()->subDays(TenantCheckoutHealthResource::TRANSACTION_WINDOW_DAYS);
|
||||||
|
$provider = TenantCheckoutHealthResource::provider();
|
||||||
|
|
||||||
|
return $query->whereHas('purchases', fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider)
|
||||||
|
->where('refunded', true)
|
||||||
|
->where('purchased_at', '>=', $cutoff), '>=', $min);
|
||||||
|
}),
|
||||||
|
SelectFilter::make('subscription_status')
|
||||||
|
->label('Subscription')
|
||||||
|
->options([
|
||||||
|
'active' => 'Active',
|
||||||
|
'suspended' => 'Suspended',
|
||||||
|
'expired' => 'Expired',
|
||||||
|
'free' => 'Free',
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
->actions([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function hasStatusMismatch(Tenant $record): bool
|
||||||
|
{
|
||||||
|
$hasActivePackage = (bool) ($record->has_active_reseller_package ?? $record->activeResellerPackage);
|
||||||
|
$status = (string) ($record->subscription_status ?? '');
|
||||||
|
$expiresAt = $record->subscription_expires_at;
|
||||||
|
|
||||||
|
if ($status === 'active' && ! $hasActivePackage) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($status !== 'active' && $hasActivePackage) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($status === 'active' && $expiresAt && $expiresAt->isPast()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function applyStatusMismatchFilter(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where(function (Builder $query) {
|
||||||
|
$query->where(function (Builder $query) {
|
||||||
|
$query->where('subscription_status', 'active')
|
||||||
|
->whereDoesntHave('activeResellerPackage');
|
||||||
|
})->orWhere(function (Builder $query) {
|
||||||
|
$query->where('subscription_status', '!=', 'active')
|
||||||
|
->whereHas('activeResellerPackage');
|
||||||
|
})->orWhere(function (Builder $query) {
|
||||||
|
$query->where('subscription_status', 'active')
|
||||||
|
->whereNotNull('subscription_expires_at')
|
||||||
|
->where('subscription_expires_at', '<', now());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function transactionAgeColor(?Carbon $state): string
|
||||||
|
{
|
||||||
|
if (! $state) {
|
||||||
|
return 'gray';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($state->lt(now()->subDays(TenantCheckoutHealthResource::TRANSACTION_WINDOW_DAYS))) {
|
||||||
|
return 'danger';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'success';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\DailyOps\Resources\TenantCheckoutHealths;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\DailyOps\DailyOpsCluster;
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\TenantCheckoutHealths\Pages\ListTenantCheckoutHealths;
|
||||||
|
use App\Filament\Clusters\DailyOps\Resources\TenantCheckoutHealths\Tables\TenantCheckoutHealthTable;
|
||||||
|
use App\Models\CheckoutSession;
|
||||||
|
use App\Models\Tenant;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
class TenantCheckoutHealthResource extends Resource
|
||||||
|
{
|
||||||
|
public const TRANSACTION_WINDOW_DAYS = 30;
|
||||||
|
|
||||||
|
public const DEFAULT_PROVIDER = CheckoutSession::PROVIDER_PAYPAL;
|
||||||
|
|
||||||
|
protected static ?string $model = Tenant::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-credit-card';
|
||||||
|
|
||||||
|
protected static ?string $cluster = DailyOpsCluster::class;
|
||||||
|
|
||||||
|
protected static ?string $slug = 'checkout-health';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 20;
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return TenantCheckoutHealthTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canCreate(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('admin.checkout_health.navigation.label');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): UnitEnum|string|null
|
||||||
|
{
|
||||||
|
return __('admin.nav.billing');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
$provider = static::provider();
|
||||||
|
$windowStart = now()->subDays(self::TRANSACTION_WINDOW_DAYS);
|
||||||
|
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->with(['activeResellerPackage.package'])
|
||||||
|
->withExists('activeResellerPackage as has_active_reseller_package')
|
||||||
|
->withCount([
|
||||||
|
'purchases as checkout_transaction_count' => fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider)
|
||||||
|
->where('refunded', false),
|
||||||
|
'purchases as checkout_transaction_count_window' => fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider)
|
||||||
|
->where('refunded', false)
|
||||||
|
->where('purchased_at', '>=', $windowStart),
|
||||||
|
'purchases as checkout_refund_count_window' => fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider)
|
||||||
|
->where('refunded', true)
|
||||||
|
->where('purchased_at', '>=', $windowStart),
|
||||||
|
'checkoutSessions as checkout_requires_action_count' => fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider)
|
||||||
|
->where('status', CheckoutSession::STATUS_REQUIRES_CUSTOMER_ACTION),
|
||||||
|
'checkoutSessions as checkout_processing_count' => fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider)
|
||||||
|
->where('status', CheckoutSession::STATUS_PROCESSING),
|
||||||
|
'checkoutSessions as checkout_expired_count' => fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider)
|
||||||
|
->whereNotIn('status', [
|
||||||
|
CheckoutSession::STATUS_COMPLETED,
|
||||||
|
CheckoutSession::STATUS_CANCELLED,
|
||||||
|
])
|
||||||
|
->whereNotNull('expires_at')
|
||||||
|
->where('expires_at', '<', now()),
|
||||||
|
])
|
||||||
|
->withSum([
|
||||||
|
'purchases as checkout_transaction_total' => fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider)
|
||||||
|
->where('refunded', false),
|
||||||
|
], 'price')
|
||||||
|
->withSum([
|
||||||
|
'purchases as checkout_transaction_total_window' => fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider)
|
||||||
|
->where('refunded', false)
|
||||||
|
->where('purchased_at', '>=', $windowStart),
|
||||||
|
], 'price')
|
||||||
|
->withSum([
|
||||||
|
'purchases as checkout_refund_total_window' => fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider)
|
||||||
|
->where('refunded', true)
|
||||||
|
->where('purchased_at', '>=', $windowStart),
|
||||||
|
], 'price')
|
||||||
|
->withMax([
|
||||||
|
'purchases as last_checkout_transaction_at' => fn (Builder $query) => $query
|
||||||
|
->where('provider', $provider),
|
||||||
|
], 'purchased_at');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListTenantCheckoutHealths::route('/'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function provider(): string
|
||||||
|
{
|
||||||
|
return (string) config('checkout.default_provider', self::DEFAULT_PROVIDER);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\RareAdmin\Resources\SuperAdminActionLogs\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\RareAdmin\Resources\SuperAdminActionLogs\SuperAdminActionLogResource;
|
||||||
|
use Filament\Resources\Pages\ManageRecords;
|
||||||
|
|
||||||
|
class ManageSuperAdminActionLogs extends ManageRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = SuperAdminActionLogResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\RareAdmin\Resources\SuperAdminActionLogs;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\RareAdmin\RareAdminCluster;
|
||||||
|
use App\Filament\Clusters\RareAdmin\Resources\SuperAdminActionLogs\Pages\ManageSuperAdminActionLogs;
|
||||||
|
use App\Models\SuperAdminActionLog;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
class SuperAdminActionLogResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = SuperAdminActionLog::class;
|
||||||
|
|
||||||
|
protected static ?string $cluster = RareAdminCluster::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedClipboardDocumentList;
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 95;
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'action';
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): UnitEnum|string|null
|
||||||
|
{
|
||||||
|
return __('admin.nav.infrastructure');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return 'Audit log';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canCreate(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canEdit($record): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canDelete($record): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canDeleteAny(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
//
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->recordTitleAttribute('action')
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('action')
|
||||||
|
->badge()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
TextColumn::make('actor.fullName')
|
||||||
|
->label('Actor')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('subject_type')
|
||||||
|
->label('Subject')
|
||||||
|
->formatStateUsing(fn (?string $state) => $state ? class_basename($state) : '—')
|
||||||
|
->searchable()
|
||||||
|
->toggleable(),
|
||||||
|
TextColumn::make('subject_id')
|
||||||
|
->label('Subject ID')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(),
|
||||||
|
TextColumn::make('metadata')
|
||||||
|
->label('Fields')
|
||||||
|
->formatStateUsing(function ($state): string {
|
||||||
|
if (! is_array($state)) {
|
||||||
|
return '—';
|
||||||
|
}
|
||||||
|
|
||||||
|
$fields = $state['fields'] ?? [];
|
||||||
|
|
||||||
|
return $fields ? implode(', ', $fields) : '—';
|
||||||
|
})
|
||||||
|
->toggleable(isToggledHiddenByDefault: true)
|
||||||
|
->wrap(),
|
||||||
|
TextColumn::make('source')
|
||||||
|
->label('Source')
|
||||||
|
->limit(40)
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('occurred_at')
|
||||||
|
->label('Timestamp')
|
||||||
|
->dateTime()
|
||||||
|
->sortable(),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
//
|
||||||
|
])
|
||||||
|
->recordActions([])
|
||||||
|
->toolbarActions([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ManageSuperAdminActionLogs::route('/'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\TaskCollectionResource;
|
||||||
|
use App\Filament\Resources\Pages\AuditedCreateRecord;
|
||||||
|
|
||||||
|
class CreateTaskCollection extends AuditedCreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = TaskCollectionResource::class;
|
||||||
|
|
||||||
|
protected function mutateFormDataBeforeCreate(array $data): array
|
||||||
|
{
|
||||||
|
return TaskCollectionResource::normalizeData($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\TaskCollectionResource;
|
||||||
|
use App\Filament\Resources\Pages\AuditedEditRecord;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
|
use Filament\Actions;
|
||||||
|
|
||||||
|
class EditTaskCollection extends AuditedEditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = TaskCollectionResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\DeleteAction::make()
|
||||||
|
->after(fn ($record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function mutateFormDataBeforeSave(array $data): array
|
||||||
|
{
|
||||||
|
return TaskCollectionResource::normalizeData($data, $this->record);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\TaskCollectionResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListTaskCollections extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = TaskCollectionResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\RelationManagers;
|
||||||
|
|
||||||
|
use App\Models\Task;
|
||||||
|
use Filament\Actions\AttachAction;
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DetachAction;
|
||||||
|
use Filament\Actions\DetachBulkAction;
|
||||||
|
use Filament\Resources\RelationManagers\RelationManager;
|
||||||
|
use Filament\Tables\Columns\IconColumn;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
|
class TasksRelationManager extends RelationManager
|
||||||
|
{
|
||||||
|
protected static string $relationship = 'tasks';
|
||||||
|
|
||||||
|
protected static ?string $inverseRelationship = 'taskCollections';
|
||||||
|
|
||||||
|
public function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('title')
|
||||||
|
->label(__('admin.tasks.table.title'))
|
||||||
|
->getStateUsing(fn (Task $record) => $this->formatTaskTitle($record->title))
|
||||||
|
->searchable(['title->de', 'title->en'])
|
||||||
|
->limit(60),
|
||||||
|
TextColumn::make('emotion.name')
|
||||||
|
->label(__('admin.tasks.fields.emotion'))
|
||||||
|
->getStateUsing(function (Task $record) {
|
||||||
|
$value = optional($record->emotion)->name;
|
||||||
|
if (is_array($value)) {
|
||||||
|
$locale = app()->getLocale();
|
||||||
|
|
||||||
|
return $value[$locale] ?? ($value['de'] ?? ($value['en'] ?? ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (string) ($value ?? '');
|
||||||
|
})
|
||||||
|
->sortable(),
|
||||||
|
TextColumn::make('difficulty')
|
||||||
|
->label(__('admin.tasks.fields.difficulty.label'))
|
||||||
|
->badge(),
|
||||||
|
IconColumn::make('is_active')
|
||||||
|
->label(__('admin.tasks.table.is_active'))
|
||||||
|
->boolean(),
|
||||||
|
TextColumn::make('sort_order')
|
||||||
|
->label(__('admin.tasks.table.sort_order'))
|
||||||
|
->sortable(),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
AttachAction::make()
|
||||||
|
->recordTitle(fn (Task $record) => $this->formatTaskTitle($record->title))
|
||||||
|
->recordSelectOptionsQuery(fn (Builder $query): Builder => $query->whereNull('tenant_id'))
|
||||||
|
->multiple()
|
||||||
|
->after(function (array $data): void {
|
||||||
|
$collection = $this->getOwnerRecord();
|
||||||
|
$recordIds = Arr::wrap($data['recordId'] ?? []);
|
||||||
|
|
||||||
|
if ($recordIds === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$collection->reassignTasks($recordIds);
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
DetachAction::make()
|
||||||
|
->after(function (?Task $record): void {
|
||||||
|
if (! $record) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$collectionId = $this->getOwnerRecord()->getKey();
|
||||||
|
|
||||||
|
if ($record->collection_id === $collectionId) {
|
||||||
|
$record->update(['collection_id' => null]);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DetachBulkAction::make()
|
||||||
|
->after(function (Collection $records): void {
|
||||||
|
$collectionId = $this->getOwnerRecord()->getKey();
|
||||||
|
|
||||||
|
$ids = $records
|
||||||
|
->filter(fn (Task $record) => $record->collection_id === $collectionId)
|
||||||
|
->pluck('id')
|
||||||
|
->all();
|
||||||
|
|
||||||
|
if ($ids === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Task::query()
|
||||||
|
->whereIn('id', $ids)
|
||||||
|
->update(['collection_id' => null]);
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string>|string|null $value
|
||||||
|
*/
|
||||||
|
protected function formatTaskTitle(array|string|null $value): string
|
||||||
|
{
|
||||||
|
if (is_array($value)) {
|
||||||
|
$locale = app()->getLocale();
|
||||||
|
|
||||||
|
return $value[$locale]
|
||||||
|
?? ($value['de'] ?? ($value['en'] ?? Arr::first($value) ?? ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_string($value)) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,280 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\WeeklyOps\Resources\TaskCollections;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\Pages\CreateTaskCollection;
|
||||||
|
use App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\Pages\EditTaskCollection;
|
||||||
|
use App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\Pages\ListTaskCollections;
|
||||||
|
use App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\RelationManagers\TasksRelationManager;
|
||||||
|
use App\Filament\Clusters\WeeklyOps\WeeklyOpsCluster;
|
||||||
|
use App\Models\EventType;
|
||||||
|
use App\Models\TaskCollection;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Forms\Components\MarkdownEditor;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Components\Toggle;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Components\Tabs as SchemaTabs;
|
||||||
|
use Filament\Schemas\Components\Tabs\Tab as SchemaTab;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Tables\Columns\IconColumn;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
class TaskCollectionResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = TaskCollection::class;
|
||||||
|
|
||||||
|
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $cluster = WeeklyOpsCluster::class;
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 31;
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->schema([
|
||||||
|
TextInput::make('slug')
|
||||||
|
->label(__('admin.common.slug'))
|
||||||
|
->maxLength(255)
|
||||||
|
->unique(ignoreRecord: true)
|
||||||
|
->required(),
|
||||||
|
Select::make('event_type_id')
|
||||||
|
->relationship('eventType', 'name')
|
||||||
|
->getOptionLabelFromRecordUsing(fn (EventType $record) => is_array($record->name) ? ($record->name['de'] ?? $record->name['en'] ?? __('admin.common.unnamed')) : $record->name)
|
||||||
|
->searchable()
|
||||||
|
->preload()
|
||||||
|
->label(__('admin.task_collections.fields.event_type_optional')),
|
||||||
|
SchemaTabs::make('content_tabs')
|
||||||
|
->label(__('admin.task_collections.fields.content_localization'))
|
||||||
|
->tabs([
|
||||||
|
SchemaTab::make(__('admin.common.german'))
|
||||||
|
->icon('heroicon-o-language')
|
||||||
|
->schema([
|
||||||
|
TextInput::make('name_translations.de')
|
||||||
|
->label(__('admin.task_collections.fields.name_de'))
|
||||||
|
->required(),
|
||||||
|
MarkdownEditor::make('description_translations.de')
|
||||||
|
->label(__('admin.task_collections.fields.description_de'))
|
||||||
|
->columnSpanFull(),
|
||||||
|
]),
|
||||||
|
SchemaTab::make(__('admin.common.english'))
|
||||||
|
->icon('heroicon-o-language')
|
||||||
|
->schema([
|
||||||
|
TextInput::make('name_translations.en')
|
||||||
|
->label(__('admin.task_collections.fields.name_en'))
|
||||||
|
->required(),
|
||||||
|
MarkdownEditor::make('description_translations.en')
|
||||||
|
->label(__('admin.task_collections.fields.description_en'))
|
||||||
|
->columnSpanFull(),
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
->columnSpanFull(),
|
||||||
|
Toggle::make('is_default')
|
||||||
|
->label(__('admin.task_collections.fields.is_default'))
|
||||||
|
->default(false),
|
||||||
|
TextInput::make('position')
|
||||||
|
->label(__('admin.task_collections.fields.position'))
|
||||||
|
->numeric()
|
||||||
|
->default(0),
|
||||||
|
])
|
||||||
|
->columns(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('id')
|
||||||
|
->label('#')
|
||||||
|
->sortable(),
|
||||||
|
TextColumn::make('name')
|
||||||
|
->label(__('admin.task_collections.table.name'))
|
||||||
|
->getStateUsing(fn (TaskCollection $record) => static::formatTranslation($record->name_translations))
|
||||||
|
->searchable(['name_translations->de', 'name_translations->en'])
|
||||||
|
->limit(60),
|
||||||
|
TextColumn::make('eventType.name')
|
||||||
|
->label(__('admin.task_collections.table.event_type'))
|
||||||
|
->getStateUsing(function (TaskCollection $record) {
|
||||||
|
$value = optional($record->eventType)->name;
|
||||||
|
|
||||||
|
if (is_array($value)) {
|
||||||
|
$locale = app()->getLocale();
|
||||||
|
|
||||||
|
return $value[$locale] ?? ($value['de'] ?? ($value['en'] ?? ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (string) ($value ?? '');
|
||||||
|
})
|
||||||
|
->toggleable(),
|
||||||
|
TextColumn::make('slug')
|
||||||
|
->label(__('admin.task_collections.table.slug'))
|
||||||
|
->toggleable()
|
||||||
|
->searchable(),
|
||||||
|
IconColumn::make('is_default')
|
||||||
|
->label(__('admin.task_collections.table.is_default'))
|
||||||
|
->boolean(),
|
||||||
|
TextColumn::make('position')
|
||||||
|
->label(__('admin.task_collections.table.position'))
|
||||||
|
->sortable(),
|
||||||
|
TextColumn::make('tasks_count')
|
||||||
|
->label(__('admin.task_collections.table.tasks'))
|
||||||
|
->sortable(),
|
||||||
|
TextColumn::make('events_count')
|
||||||
|
->label(__('admin.task_collections.table.events'))
|
||||||
|
->sortable(),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
SelectFilter::make('event_type_id')
|
||||||
|
->label(__('admin.task_collections.table.event_type'))
|
||||||
|
->relationship(
|
||||||
|
'eventType',
|
||||||
|
'name',
|
||||||
|
fn (Builder $query): Builder => $query->orderBy('name->de')
|
||||||
|
)
|
||||||
|
->getOptionLabelFromRecordUsing(fn (EventType $record) => is_array($record->name) ? ($record->name['de'] ?? $record->name['en'] ?? __('admin.common.unnamed')) : $record->name),
|
||||||
|
SelectFilter::make('is_default')
|
||||||
|
->label(__('admin.task_collections.table.is_default'))
|
||||||
|
->options([
|
||||||
|
'1' => __('admin.common.yes'),
|
||||||
|
'0' => __('admin.common.no'),
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
Actions\EditAction::make()
|
||||||
|
->mutateDataUsing(fn (array $data, TaskCollection $record): array => static::normalizeData($data, $record))
|
||||||
|
->after(fn (array $data, TaskCollection $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
|
Actions\DeleteAction::make()
|
||||||
|
->after(fn (TaskCollection $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
Actions\DeleteBulkAction::make()
|
||||||
|
->after(function (Collection $records): void {
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('admin.task_collections.menu');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): UnitEnum|string|null
|
||||||
|
{
|
||||||
|
return __('admin.nav.curation');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->whereNull('tenant_id')
|
||||||
|
->with('eventType')
|
||||||
|
->withCount(['tasks', 'events']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $data
|
||||||
|
*/
|
||||||
|
public static function normalizeData(array $data, ?TaskCollection $record = null): array
|
||||||
|
{
|
||||||
|
$data['tenant_id'] = null;
|
||||||
|
$data['slug'] = static::resolveSlug($data, $record);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $data
|
||||||
|
*/
|
||||||
|
protected static function resolveSlug(array $data, ?TaskCollection $record = null): string
|
||||||
|
{
|
||||||
|
$rawSlug = trim((string) ($data['slug'] ?? ''));
|
||||||
|
$translations = Arr::wrap($data['name_translations'] ?? []);
|
||||||
|
$fallbackName = (string) ($translations['en'] ?? $translations['de'] ?? '');
|
||||||
|
|
||||||
|
$base = $rawSlug !== '' ? $rawSlug : $fallbackName;
|
||||||
|
$slugBase = Str::slug($base) ?: 'collection';
|
||||||
|
|
||||||
|
$query = TaskCollection::query()->where('slug', $slugBase);
|
||||||
|
|
||||||
|
if ($record) {
|
||||||
|
$query->whereKeyNot($record->getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $query->exists()) {
|
||||||
|
return $slugBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
$candidate = $slugBase.'-'.Str::random(4);
|
||||||
|
$candidateQuery = TaskCollection::query()->where('slug', $candidate);
|
||||||
|
|
||||||
|
if ($record) {
|
||||||
|
$candidateQuery->whereKeyNot($record->getKey());
|
||||||
|
}
|
||||||
|
} while ($candidateQuery->exists());
|
||||||
|
|
||||||
|
return $candidate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string>|null $translations
|
||||||
|
*/
|
||||||
|
protected static function formatTranslation(?array $translations): string
|
||||||
|
{
|
||||||
|
if (! is_array($translations)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$locale = app()->getLocale();
|
||||||
|
|
||||||
|
return $translations[$locale]
|
||||||
|
?? ($translations['de'] ?? ($translations['en'] ?? Arr::first($translations) ?? ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListTaskCollections::route('/'),
|
||||||
|
'create' => CreateTaskCollection::route('/create'),
|
||||||
|
'edit' => EditTaskCollection::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
TasksRelationManager::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
305
app/Filament/Resources/AiStyles/AiStyleResource.php
Normal file
305
app/Filament/Resources/AiStyles/AiStyleResource.php
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\AiStyles;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\RareAdmin\RareAdminCluster;
|
||||||
|
use App\Filament\Resources\AiStyles\Pages\ManageAiStyles;
|
||||||
|
use App\Models\AiStyle;
|
||||||
|
use App\Services\AiEditing\RunwareModelSearchService;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Forms\Components\KeyValue;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Components\Toggle;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Filament\Schemas\Components\Utilities\Set;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
class AiStyleResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = AiStyle::class;
|
||||||
|
|
||||||
|
protected static ?string $cluster = RareAdminCluster::class;
|
||||||
|
|
||||||
|
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-paint-brush';
|
||||||
|
|
||||||
|
protected static UnitEnum|string|null $navigationGroup = null;
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 31;
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): UnitEnum|string|null
|
||||||
|
{
|
||||||
|
return __('admin.nav.platform');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return 'AI Styles';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema->schema([
|
||||||
|
Section::make('Style Basics')
|
||||||
|
->schema([
|
||||||
|
TextInput::make('key')
|
||||||
|
->required()
|
||||||
|
->maxLength(120)
|
||||||
|
->unique(ignoreRecord: true),
|
||||||
|
TextInput::make('name')
|
||||||
|
->required()
|
||||||
|
->maxLength(120),
|
||||||
|
TextInput::make('version')
|
||||||
|
->numeric()
|
||||||
|
->default(1)
|
||||||
|
->disabled()
|
||||||
|
->dehydrated(false)
|
||||||
|
->helperText('Auto-increments when core style configuration changes.'),
|
||||||
|
TextInput::make('category')
|
||||||
|
->maxLength(50),
|
||||||
|
TextInput::make('sort')
|
||||||
|
->numeric()
|
||||||
|
->default(0)
|
||||||
|
->required(),
|
||||||
|
Toggle::make('is_active')
|
||||||
|
->default(true),
|
||||||
|
Toggle::make('is_premium')
|
||||||
|
->default(false),
|
||||||
|
Toggle::make('requires_source_image')
|
||||||
|
->default(true),
|
||||||
|
])
|
||||||
|
->columns(3),
|
||||||
|
Section::make('Provider Binding')
|
||||||
|
->schema([
|
||||||
|
Select::make('provider')
|
||||||
|
->options([
|
||||||
|
'runware' => 'runware.ai',
|
||||||
|
])
|
||||||
|
->required()
|
||||||
|
->default('runware'),
|
||||||
|
Select::make('provider_model')
|
||||||
|
->label('Runware model (AIR)')
|
||||||
|
->searchable()
|
||||||
|
->getSearchResultsUsing(static fn (string $search): array => app(RunwareModelSearchService::class)->searchOptions($search))
|
||||||
|
->getOptionLabelUsing(static fn (mixed $value): ?string => app(RunwareModelSearchService::class)->labelForModel($value))
|
||||||
|
->helperText('Start typing to search models from runware.ai.')
|
||||||
|
->native(false)
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(static function (Set $set, ?string $state): void {
|
||||||
|
self::applySelectedRunwareModel($set, $state);
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
->columns(2),
|
||||||
|
Section::make('Runware Generation')
|
||||||
|
->schema([
|
||||||
|
TextInput::make('metadata.runware.generation.width')
|
||||||
|
->label('Width')
|
||||||
|
->numeric()
|
||||||
|
->minValue(64)
|
||||||
|
->maxValue(4096)
|
||||||
|
->step(64)
|
||||||
|
->helperText(static fn (Get $get): ?string => self::dimensionConstraintHint($get, 'width')),
|
||||||
|
TextInput::make('metadata.runware.generation.height')
|
||||||
|
->label('Height')
|
||||||
|
->numeric()
|
||||||
|
->minValue(64)
|
||||||
|
->maxValue(4096)
|
||||||
|
->step(64)
|
||||||
|
->helperText(static fn (Get $get): ?string => self::dimensionConstraintHint($get, 'height')),
|
||||||
|
TextInput::make('metadata.runware.generation.steps')
|
||||||
|
->label('Steps')
|
||||||
|
->numeric()
|
||||||
|
->minValue(1)
|
||||||
|
->maxValue(150)
|
||||||
|
->helperText(static fn (Get $get): ?string => self::rangeConstraintHint($get, 'steps')),
|
||||||
|
TextInput::make('metadata.runware.generation.cfg_scale')
|
||||||
|
->label('CFG Scale')
|
||||||
|
->numeric()
|
||||||
|
->minValue(0)
|
||||||
|
->maxValue(30)
|
||||||
|
->step(0.1)
|
||||||
|
->helperText(static fn (Get $get): ?string => self::rangeConstraintHint($get, 'cfg_scale')),
|
||||||
|
TextInput::make('metadata.runware.generation.strength')
|
||||||
|
->label('Strength')
|
||||||
|
->numeric()
|
||||||
|
->minValue(0)
|
||||||
|
->maxValue(1)
|
||||||
|
->step(0.01)
|
||||||
|
->helperText(static fn (Get $get): ?string => self::rangeConstraintHint($get, 'strength')),
|
||||||
|
Select::make('metadata.runware.generation.output_format')
|
||||||
|
->label('Output format')
|
||||||
|
->options([
|
||||||
|
'JPG' => 'JPG',
|
||||||
|
'PNG' => 'PNG',
|
||||||
|
'WEBP' => 'WEBP',
|
||||||
|
])
|
||||||
|
->default('JPG')
|
||||||
|
->native(false),
|
||||||
|
Select::make('metadata.runware.generation.delivery_method')
|
||||||
|
->label('Delivery method')
|
||||||
|
->options([
|
||||||
|
'async' => 'async (queue + poll)',
|
||||||
|
'sync' => 'sync',
|
||||||
|
])
|
||||||
|
->default('async')
|
||||||
|
->native(false),
|
||||||
|
])
|
||||||
|
->columns(3),
|
||||||
|
Section::make('Prompts')
|
||||||
|
->schema([
|
||||||
|
Textarea::make('description')
|
||||||
|
->rows(2),
|
||||||
|
Textarea::make('prompt_template')
|
||||||
|
->rows(5),
|
||||||
|
Textarea::make('negative_prompt_template')
|
||||||
|
->rows(4),
|
||||||
|
]),
|
||||||
|
Section::make('Metadata')
|
||||||
|
->schema([
|
||||||
|
KeyValue::make('metadata')
|
||||||
|
->nullable(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->defaultSort('sort')
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('key')
|
||||||
|
->searchable()
|
||||||
|
->copyable(),
|
||||||
|
Tables\Columns\TextColumn::make('name')
|
||||||
|
->searchable(),
|
||||||
|
Tables\Columns\TextColumn::make('version')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(),
|
||||||
|
Tables\Columns\TextColumn::make('provider')
|
||||||
|
->badge(),
|
||||||
|
Tables\Columns\TextColumn::make('provider_model')
|
||||||
|
->toggleable(),
|
||||||
|
Tables\Columns\IconColumn::make('is_active')
|
||||||
|
->boolean(),
|
||||||
|
Tables\Columns\IconColumn::make('is_premium')
|
||||||
|
->boolean(),
|
||||||
|
Tables\Columns\TextColumn::make('sort')
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->since()
|
||||||
|
->toggleable(),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
Tables\Filters\TernaryFilter::make('is_active'),
|
||||||
|
Tables\Filters\TernaryFilter::make('is_premium'),
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
Actions\EditAction::make()
|
||||||
|
->after(fn (array $data, AiStyle $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata(array_keys($data)),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
|
Actions\DeleteAction::make()
|
||||||
|
->after(fn (AiStyle $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
Actions\DeleteBulkAction::make(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ManageAiStyles::route('/'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function applySelectedRunwareModel(Set $set, ?string $air): void
|
||||||
|
{
|
||||||
|
if (! is_string($air) || trim($air) === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$model = app(RunwareModelSearchService::class)->findByAir($air);
|
||||||
|
if (! is_array($model)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$set('metadata.runware.model.air', $model['air']);
|
||||||
|
$set('metadata.runware.model.name', $model['name']);
|
||||||
|
$set('metadata.runware.model.architecture', $model['architecture']);
|
||||||
|
$set('metadata.runware.model.category', $model['category']);
|
||||||
|
|
||||||
|
foreach ((array) ($model['constraints'] ?? []) as $key => $value) {
|
||||||
|
$set("metadata.runware.constraints.{$key}", $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
self::setIfNumeric($set, 'metadata.runware.generation.width', $model['defaults']['width'] ?? null);
|
||||||
|
self::setIfNumeric($set, 'metadata.runware.generation.height', $model['defaults']['height'] ?? null);
|
||||||
|
self::setIfNumeric($set, 'metadata.runware.generation.steps', $model['defaults']['steps'] ?? null);
|
||||||
|
self::setIfNumeric($set, 'metadata.runware.generation.cfg_scale', $model['defaults']['cfg_scale'] ?? null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function setIfNumeric(Set $set, string $path, mixed $value): void
|
||||||
|
{
|
||||||
|
if (is_numeric($value)) {
|
||||||
|
$set($path, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function dimensionConstraintHint(Get $get, string $dimension): ?string
|
||||||
|
{
|
||||||
|
$min = $get("metadata.runware.constraints.min_{$dimension}");
|
||||||
|
$max = $get("metadata.runware.constraints.max_{$dimension}");
|
||||||
|
$step = $get("metadata.runware.constraints.{$dimension}_step");
|
||||||
|
|
||||||
|
if (! is_numeric($min) && ! is_numeric($max) && ! is_numeric($step)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parts = [];
|
||||||
|
if (is_numeric($min) || is_numeric($max)) {
|
||||||
|
$parts[] = sprintf(
|
||||||
|
'Model range: %s - %s',
|
||||||
|
is_numeric($min) ? (string) (int) $min : '?',
|
||||||
|
is_numeric($max) ? (string) (int) $max : '?'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_numeric($step) && (int) $step > 0) {
|
||||||
|
$parts[] = sprintf('Step: %d', (int) $step);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $parts !== [] ? implode(' | ', $parts) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function rangeConstraintHint(Get $get, string $field): ?string
|
||||||
|
{
|
||||||
|
$min = $get("metadata.runware.constraints.min_{$field}");
|
||||||
|
$max = $get("metadata.runware.constraints.max_{$field}");
|
||||||
|
|
||||||
|
if (! is_numeric($min) && ! is_numeric($max)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'Model range: %s - %s',
|
||||||
|
is_numeric($min) ? trim((string) $min) : '?',
|
||||||
|
is_numeric($max) ? trim((string) $max) : '?'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/Filament/Resources/AiStyles/Pages/ManageAiStyles.php
Normal file
26
app/Filament/Resources/AiStyles/Pages/ManageAiStyles.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\AiStyles\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\AiStyles\AiStyleResource;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ManageRecords;
|
||||||
|
|
||||||
|
class ManageAiStyles extends ManageRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = AiStyleResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make()
|
||||||
|
->after(fn (array $data, $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'created',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata(array_keys($data)),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,15 +3,17 @@
|
|||||||
namespace App\Filament\Resources\Coupons\Pages;
|
namespace App\Filament\Resources\Coupons\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\Coupons\CouponResource;
|
use App\Filament\Resources\Coupons\CouponResource;
|
||||||
use App\Jobs\SyncCouponToPaddle;
|
use App\Filament\Resources\Pages\AuditedCreateRecord;
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
use App\Jobs\SyncCouponToLemonSqueezy;
|
||||||
|
|
||||||
class CreateCoupon extends CreateRecord
|
class CreateCoupon extends AuditedCreateRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = CouponResource::class;
|
protected static string $resource = CouponResource::class;
|
||||||
|
|
||||||
protected function afterCreate(): void
|
protected function afterCreate(): void
|
||||||
{
|
{
|
||||||
SyncCouponToPaddle::dispatch($this->record);
|
parent::afterCreate();
|
||||||
|
|
||||||
|
SyncCouponToLemonSqueezy::dispatch($this->record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,15 @@
|
|||||||
namespace App\Filament\Resources\Coupons\Pages;
|
namespace App\Filament\Resources\Coupons\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\Coupons\CouponResource;
|
use App\Filament\Resources\Coupons\CouponResource;
|
||||||
use App\Jobs\SyncCouponToPaddle;
|
use App\Filament\Resources\Pages\AuditedEditRecord;
|
||||||
|
use App\Jobs\SyncCouponToLemonSqueezy;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions\DeleteAction;
|
use Filament\Actions\DeleteAction;
|
||||||
use Filament\Actions\ForceDeleteAction;
|
use Filament\Actions\ForceDeleteAction;
|
||||||
use Filament\Actions\RestoreAction;
|
use Filament\Actions\RestoreAction;
|
||||||
use Filament\Actions\ViewAction;
|
use Filament\Actions\ViewAction;
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditCoupon extends EditRecord
|
class EditCoupon extends AuditedEditRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = CouponResource::class;
|
protected static string $resource = CouponResource::class;
|
||||||
|
|
||||||
@@ -19,14 +20,34 @@ class EditCoupon extends EditRecord
|
|||||||
return [
|
return [
|
||||||
ViewAction::make(),
|
ViewAction::make(),
|
||||||
DeleteAction::make()
|
DeleteAction::make()
|
||||||
->after(fn ($record) => SyncCouponToPaddle::dispatch($record, true)),
|
->after(function ($record): void {
|
||||||
ForceDeleteAction::make(),
|
app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
RestoreAction::make(),
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
|
||||||
|
SyncCouponToLemonSqueezy::dispatch($record, true);
|
||||||
|
}),
|
||||||
|
ForceDeleteAction::make()
|
||||||
|
->after(fn ($record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'force_deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
|
RestoreAction::make()
|
||||||
|
->after(fn ($record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'restored',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function afterSave(): void
|
protected function afterSave(): void
|
||||||
{
|
{
|
||||||
SyncCouponToPaddle::dispatch($this->record);
|
parent::afterSave();
|
||||||
|
|
||||||
|
SyncCouponToLemonSqueezy::dispatch($this->record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Resources\Coupons\Pages;
|
namespace App\Filament\Resources\Coupons\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\Coupons\CouponResource;
|
use App\Filament\Resources\Coupons\CouponResource;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
@@ -13,7 +14,13 @@ class ViewCoupon extends ViewRecord
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
EditAction::make(),
|
EditAction::make()
|
||||||
|
->after(fn (array $data, $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use Filament\Schemas\Schema;
|
|||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Filters\SelectFilter;
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class RedemptionsRelationManager extends RelationManager
|
class RedemptionsRelationManager extends RelationManager
|
||||||
{
|
{
|
||||||
@@ -20,11 +21,35 @@ class RedemptionsRelationManager extends RelationManager
|
|||||||
public function table(Table $table): Table
|
public function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->recordTitleAttribute('paddle_transaction_id')
|
->recordTitleAttribute('lemonsqueezy_order_id')
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('tenant.name')
|
TextColumn::make('tenant.name')
|
||||||
->label(__('Tenant'))
|
->label(__('Tenant'))
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
TextColumn::make('ip_address')
|
||||||
|
->label(__('IP'))
|
||||||
|
->copyable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('device_id')
|
||||||
|
->label(__('Device'))
|
||||||
|
->copyable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('user_agent')
|
||||||
|
->label(__('User agent'))
|
||||||
|
->toggleable(isToggledHiddenByDefault: true)
|
||||||
|
->wrap(),
|
||||||
|
TextColumn::make('fraud_ip')
|
||||||
|
->label(__('IP reputation'))
|
||||||
|
->badge()
|
||||||
|
->formatStateUsing(fn ($state, $record) => self::formatReputation(data_get($record->metadata, 'fraud.ip')))
|
||||||
|
->color(fn ($state, $record) => self::riskColor(data_get($record->metadata, 'fraud.ip.risk')))
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('fraud_device')
|
||||||
|
->label(__('Device reputation'))
|
||||||
|
->badge()
|
||||||
|
->formatStateUsing(fn ($state, $record) => self::formatReputation(data_get($record->metadata, 'fraud.device')))
|
||||||
|
->color(fn ($state, $record) => self::riskColor(data_get($record->metadata, 'fraud.device.risk')))
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('user.name')
|
TextColumn::make('user.name')
|
||||||
->label(__('User'))
|
->label(__('User'))
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
@@ -40,7 +65,7 @@ class RedemptionsRelationManager extends RelationManager
|
|||||||
'failed' => 'danger',
|
'failed' => 'danger',
|
||||||
default => 'warning',
|
default => 'warning',
|
||||||
}),
|
}),
|
||||||
TextColumn::make('paddle_transaction_id')
|
TextColumn::make('lemonsqueezy_order_id')
|
||||||
->label(__('Transaction'))
|
->label(__('Transaction'))
|
||||||
->copyable()
|
->copyable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
@@ -69,4 +94,30 @@ class RedemptionsRelationManager extends RelationManager
|
|||||||
->recordActions([])
|
->recordActions([])
|
||||||
->toolbarActions([]);
|
->toolbarActions([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array{risk?: string, recent_failed?: int, recent_total?: int}|null $snapshot
|
||||||
|
*/
|
||||||
|
private static function formatReputation(?array $snapshot): string
|
||||||
|
{
|
||||||
|
if (! $snapshot) {
|
||||||
|
return '—';
|
||||||
|
}
|
||||||
|
|
||||||
|
$risk = Str::headline($snapshot['risk'] ?? 'unknown');
|
||||||
|
$failed = (int) ($snapshot['recent_failed'] ?? 0);
|
||||||
|
$total = (int) ($snapshot['recent_total'] ?? 0);
|
||||||
|
|
||||||
|
return sprintf('%s (%d/%d)', $risk, $failed, $total);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function riskColor(?string $risk): string
|
||||||
|
{
|
||||||
|
return match ($risk) {
|
||||||
|
'high' => 'danger',
|
||||||
|
'medium' => 'warning',
|
||||||
|
'low' => 'success',
|
||||||
|
default => 'gray',
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,22 +123,22 @@ class CouponForm
|
|||||||
->nullable()
|
->nullable()
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
]),
|
]),
|
||||||
Section::make(__('Paddle sync'))
|
Section::make(__('Lemon Squeezy sync'))
|
||||||
->columns(2)
|
->columns(2)
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('paddle_mode')
|
Select::make('lemonsqueezy_mode')
|
||||||
->label(__('Paddle mode'))
|
->label(__('Lemon Squeezy mode'))
|
||||||
->options([
|
->options([
|
||||||
'standard' => __('Standard'),
|
'standard' => __('Standard'),
|
||||||
'custom' => __('Custom (one-off)'),
|
'custom' => __('Custom (one-off)'),
|
||||||
])
|
])
|
||||||
->default('standard'),
|
->default('standard'),
|
||||||
Placeholder::make('paddle_discount_id')
|
Placeholder::make('lemonsqueezy_discount_id')
|
||||||
->label(__('Paddle Discount ID'))
|
->label(__('Lemon Squeezy Discount ID'))
|
||||||
->content(fn ($record) => $record?->paddle_discount_id ?? '—'),
|
->content(fn ($record) => $record?->lemonsqueezy_discount_id ?? '—'),
|
||||||
Placeholder::make('paddle_last_synced_at')
|
Placeholder::make('lemonsqueezy_last_synced_at')
|
||||||
->label(__('Last synced'))
|
->label(__('Last synced'))
|
||||||
->content(fn ($record) => $record?->paddle_last_synced_at?->diffForHumans() ?? '—'),
|
->content(fn ($record) => $record?->lemonsqueezy_last_synced_at?->diffForHumans() ?? '—'),
|
||||||
Placeholder::make('redemptions_count')
|
Placeholder::make('redemptions_count')
|
||||||
->label(__('Total redemptions'))
|
->label(__('Total redemptions'))
|
||||||
->content(fn ($record) => number_format($record?->redemptions_count ?? 0)),
|
->content(fn ($record) => number_format($record?->redemptions_count ?? 0)),
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Coupons\Schemas;
|
namespace App\Filament\Resources\Coupons\Schemas;
|
||||||
|
|
||||||
|
use App\Enums\CouponStatus;
|
||||||
|
use App\Enums\CouponType;
|
||||||
use Filament\Infolists\Components\KeyValueEntry;
|
use Filament\Infolists\Components\KeyValueEntry;
|
||||||
use Filament\Infolists\Components\Section;
|
|
||||||
use Filament\Infolists\Components\TextEntry;
|
use Filament\Infolists\Components\TextEntry;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -22,11 +24,11 @@ class CouponInfolist
|
|||||||
TextEntry::make('status')
|
TextEntry::make('status')
|
||||||
->label(__('Status'))
|
->label(__('Status'))
|
||||||
->badge()
|
->badge()
|
||||||
->formatStateUsing(fn ($state) => Str::headline($state)),
|
->formatStateUsing(fn ($state) => static::formatEnumState($state)),
|
||||||
TextEntry::make('type')
|
TextEntry::make('type')
|
||||||
->label(__('Discount type'))
|
->label(__('Discount type'))
|
||||||
->badge()
|
->badge()
|
||||||
->formatStateUsing(fn ($state) => Str::headline($state)),
|
->formatStateUsing(fn ($state) => static::formatEnumState($state)),
|
||||||
TextEntry::make('amount')
|
TextEntry::make('amount')
|
||||||
->label(__('Amount'))
|
->label(__('Amount'))
|
||||||
->formatStateUsing(fn ($state, $record) => $record?->type?->value === 'percentage'
|
->formatStateUsing(fn ($state, $record) => $record?->type?->value === 'percentage'
|
||||||
@@ -61,21 +63,38 @@ class CouponInfolist
|
|||||||
TextEntry::make('description')->label(__('Description'))->columnSpanFull(),
|
TextEntry::make('description')->label(__('Description'))->columnSpanFull(),
|
||||||
KeyValueEntry::make('metadata')->label(__('Metadata'))->columnSpanFull(),
|
KeyValueEntry::make('metadata')->label(__('Metadata'))->columnSpanFull(),
|
||||||
]),
|
]),
|
||||||
Section::make(__('Paddle'))
|
Section::make(__('Lemon Squeezy'))
|
||||||
->columns(3)
|
->columns(3)
|
||||||
->schema([
|
->schema([
|
||||||
TextEntry::make('paddle_discount_id')
|
TextEntry::make('lemonsqueezy_discount_id')
|
||||||
->label(__('Discount ID'))
|
->label(__('Discount ID'))
|
||||||
->copyable()
|
->copyable()
|
||||||
->placeholder('—'),
|
->placeholder('—'),
|
||||||
TextEntry::make('paddle_last_synced_at')
|
TextEntry::make('lemonsqueezy_last_synced_at')
|
||||||
->label(__('Last synced'))
|
->label(__('Last synced'))
|
||||||
->state(fn ($record) => $record?->paddle_last_synced_at?->diffForHumans() ?? '—'),
|
->state(fn ($record) => $record?->lemonsqueezy_last_synced_at?->diffForHumans() ?? '—'),
|
||||||
TextEntry::make('paddle_mode')
|
TextEntry::make('lemonsqueezy_mode')
|
||||||
->label(__('Mode'))
|
->label(__('Mode'))
|
||||||
->badge()
|
->badge()
|
||||||
->placeholder('standard'),
|
->placeholder('standard'),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function formatEnumState(mixed $state): string
|
||||||
|
{
|
||||||
|
if ($state instanceof CouponType || $state instanceof CouponStatus) {
|
||||||
|
return $state->label();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($state instanceof \BackedEnum) {
|
||||||
|
return Str::headline($state->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_string($state)) {
|
||||||
|
return Str::headline($state);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ namespace App\Filament\Resources\Coupons\Tables;
|
|||||||
|
|
||||||
use App\Enums\CouponStatus;
|
use App\Enums\CouponStatus;
|
||||||
use App\Enums\CouponType;
|
use App\Enums\CouponType;
|
||||||
use App\Jobs\SyncCouponToPaddle;
|
use App\Jobs\SyncCouponToLemonSqueezy;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
@@ -18,6 +19,7 @@ use Filament\Tables\Filters\SelectFilter;
|
|||||||
use Filament\Tables\Filters\TernaryFilter;
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
use Filament\Tables\Filters\TrashedFilter;
|
use Filament\Tables\Filters\TrashedFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class CouponsTable
|
class CouponsTable
|
||||||
@@ -38,7 +40,7 @@ class CouponsTable
|
|||||||
TextColumn::make('type')
|
TextColumn::make('type')
|
||||||
->label(__('Type'))
|
->label(__('Type'))
|
||||||
->badge()
|
->badge()
|
||||||
->formatStateUsing(fn ($state) => Str::headline($state))
|
->formatStateUsing(fn ($state) => static::formatEnumState($state))
|
||||||
->sortable(),
|
->sortable(),
|
||||||
TextColumn::make('amount')
|
TextColumn::make('amount')
|
||||||
->label(__('Amount'))
|
->label(__('Amount'))
|
||||||
@@ -57,7 +59,7 @@ class CouponsTable
|
|||||||
->label(__('Status'))
|
->label(__('Status'))
|
||||||
->badge()
|
->badge()
|
||||||
->sortable()
|
->sortable()
|
||||||
->formatStateUsing(fn ($state) => Str::headline($state)),
|
->formatStateUsing(fn ($state) => static::formatEnumState($state)),
|
||||||
TextColumn::make('starts_at')
|
TextColumn::make('starts_at')
|
||||||
->label(__('Starts'))
|
->label(__('Starts'))
|
||||||
->date()
|
->date()
|
||||||
@@ -95,19 +97,75 @@ class CouponsTable
|
|||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
ViewAction::make(),
|
ViewAction::make(),
|
||||||
EditAction::make(),
|
EditAction::make()
|
||||||
|
->after(fn (array $data, $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
Action::make('sync')
|
Action::make('sync')
|
||||||
->label(__('Sync to Paddle'))
|
->label(__('Sync to Lemon Squeezy'))
|
||||||
->icon('heroicon-m-arrow-path')
|
->icon('heroicon-m-arrow-path')
|
||||||
->action(fn ($record) => SyncCouponToPaddle::dispatch($record))
|
->action(fn ($record) => SyncCouponToLemonSqueezy::dispatch($record))
|
||||||
->requiresConfirmation(),
|
->requiresConfirmation(),
|
||||||
])
|
])
|
||||||
->toolbarActions([
|
->toolbarActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
DeleteBulkAction::make(),
|
DeleteBulkAction::make()
|
||||||
ForceDeleteBulkAction::make(),
|
->after(function (Collection $records): void {
|
||||||
RestoreBulkAction::make(),
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
ForceDeleteBulkAction::make()
|
||||||
|
->after(function (Collection $records): void {
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->recordModelMutation(
|
||||||
|
'force_deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
RestoreBulkAction::make()
|
||||||
|
->after(function (Collection $records): void {
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->recordModelMutation(
|
||||||
|
'restored',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function formatEnumState(mixed $state): string
|
||||||
|
{
|
||||||
|
if ($state instanceof CouponType || $state instanceof CouponStatus) {
|
||||||
|
return $state->label();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($state instanceof \BackedEnum) {
|
||||||
|
return Str::headline($state->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_string($state)) {
|
||||||
|
return Str::headline($state);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
78
app/Filament/Resources/DataExportResource.php
Normal file
78
app/Filament/Resources/DataExportResource.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\RareAdmin\RareAdminCluster;
|
||||||
|
use App\Filament\Resources\DataExportResource\Pages\CreateDataExport;
|
||||||
|
use App\Filament\Resources\DataExportResource\Pages\ListDataExports;
|
||||||
|
use App\Filament\Resources\DataExportResource\Schemas\DataExportForm;
|
||||||
|
use App\Filament\Resources\DataExportResource\Tables\DataExportTable;
|
||||||
|
use App\Models\DataExport;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
class DataExportResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = DataExport::class;
|
||||||
|
|
||||||
|
protected static ?string $cluster = RareAdminCluster::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedArrowDownTray;
|
||||||
|
|
||||||
|
protected static UnitEnum|string|null $navigationGroup = null;
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 50;
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return DataExportForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return DataExportTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('admin.data_exports.navigation.label');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): UnitEnum|string|null
|
||||||
|
{
|
||||||
|
return __('admin.nav.platform');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()->with(['tenant', 'event', 'user']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListDataExports::route('/'),
|
||||||
|
'create' => CreateDataExport::route('/create'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canEdit($record): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canDelete($record): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canDeleteAny(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\DataExportResource\Pages;
|
||||||
|
|
||||||
|
use App\Enums\DataExportScope;
|
||||||
|
use App\Filament\Resources\DataExportResource;
|
||||||
|
use App\Filament\Resources\Pages\AuditedCreateRecord;
|
||||||
|
use App\Jobs\GenerateDataExport;
|
||||||
|
use App\Models\DataExport;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
|
||||||
|
class CreateDataExport extends AuditedCreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = DataExportResource::class;
|
||||||
|
|
||||||
|
protected function mutateFormDataBeforeCreate(array $data): array
|
||||||
|
{
|
||||||
|
$data['user_id'] = Filament::auth()->id();
|
||||||
|
$data['status'] = DataExport::STATUS_PENDING;
|
||||||
|
|
||||||
|
if (($data['scope'] ?? null) !== DataExportScope::EVENT->value) {
|
||||||
|
$data['event_id'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function afterCreate(): void
|
||||||
|
{
|
||||||
|
parent::afterCreate();
|
||||||
|
|
||||||
|
GenerateDataExport::dispatch($this->record->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\DataExportResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\DataExportResource;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListDataExports extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = DataExportResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
CreateAction::make()
|
||||||
|
->label(__('admin.data_exports.actions.request')),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\DataExportResource\Schemas;
|
||||||
|
|
||||||
|
use App\Enums\DataExportScope;
|
||||||
|
use App\Models\Event;
|
||||||
|
use App\Models\Tenant;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\Toggle;
|
||||||
|
use Filament\Forms\Get;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class DataExportForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema->schema([
|
||||||
|
Section::make(__('admin.data_exports.sections.request'))
|
||||||
|
->schema([
|
||||||
|
Select::make('scope')
|
||||||
|
->label(__('admin.data_exports.fields.scope'))
|
||||||
|
->options([
|
||||||
|
DataExportScope::TENANT->value => __('admin.data_exports.scope.tenant'),
|
||||||
|
DataExportScope::EVENT->value => __('admin.data_exports.scope.event'),
|
||||||
|
])
|
||||||
|
->default(DataExportScope::TENANT->value)
|
||||||
|
->live()
|
||||||
|
->required(),
|
||||||
|
Select::make('tenant_id')
|
||||||
|
->label(__('admin.data_exports.fields.tenant'))
|
||||||
|
->options(Tenant::query()->orderBy('name')->pluck('name', 'id'))
|
||||||
|
->searchable()
|
||||||
|
->preload()
|
||||||
|
->required()
|
||||||
|
->live(),
|
||||||
|
Select::make('event_id')
|
||||||
|
->label(__('admin.data_exports.fields.event'))
|
||||||
|
->options(function (Get $get): array {
|
||||||
|
$tenantId = $get('tenant_id');
|
||||||
|
if (! $tenantId) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Event::query()
|
||||||
|
->where('tenant_id', $tenantId)
|
||||||
|
->orderByDesc('date')
|
||||||
|
->get()
|
||||||
|
->mapWithKeys(function (Event $event): array {
|
||||||
|
$name = $event->name['de'] ?? $event->name['en'] ?? $event->slug;
|
||||||
|
|
||||||
|
return [$event->id => $name];
|
||||||
|
})
|
||||||
|
->all();
|
||||||
|
})
|
||||||
|
->searchable()
|
||||||
|
->preload()
|
||||||
|
->visible(fn (Get $get): bool => $get('scope') === DataExportScope::EVENT->value)
|
||||||
|
->required(fn (Get $get): bool => $get('scope') === DataExportScope::EVENT->value)
|
||||||
|
->dehydrated(fn (Get $get): bool => $get('scope') === DataExportScope::EVENT->value),
|
||||||
|
Toggle::make('include_media')
|
||||||
|
->label(__('admin.data_exports.fields.include_media'))
|
||||||
|
->helperText(__('admin.data_exports.help.include_media')),
|
||||||
|
])
|
||||||
|
->columns(2),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\DataExportResource\Tables;
|
||||||
|
|
||||||
|
use App\Enums\DataExportScope;
|
||||||
|
use App\Jobs\GenerateDataExport;
|
||||||
|
use App\Models\DataExport;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Tables\Columns\IconColumn;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Support\Number;
|
||||||
|
|
||||||
|
class DataExportTable
|
||||||
|
{
|
||||||
|
public static function formatScope(DataExportScope|string|null $state): string
|
||||||
|
{
|
||||||
|
if ($state instanceof DataExportScope) {
|
||||||
|
$state = $state->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $state ? __('admin.data_exports.scope.'.$state) : '—';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('id')
|
||||||
|
->label(__('admin.data_exports.fields.id'))
|
||||||
|
->sortable(),
|
||||||
|
TextColumn::make('tenant.name')
|
||||||
|
->label(__('admin.data_exports.fields.tenant'))
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('event.slug')
|
||||||
|
->label(__('admin.data_exports.fields.event'))
|
||||||
|
->toggleable()
|
||||||
|
->placeholder('—'),
|
||||||
|
TextColumn::make('scope')
|
||||||
|
->label(__('admin.data_exports.fields.scope'))
|
||||||
|
->badge()
|
||||||
|
->formatStateUsing(fn (DataExportScope|string|null $state): string => self::formatScope($state)),
|
||||||
|
TextColumn::make('status')
|
||||||
|
->label(__('admin.data_exports.fields.status'))
|
||||||
|
->badge()
|
||||||
|
->formatStateUsing(fn (string $state) => __('admin.data_exports.status.'.$state))
|
||||||
|
->color(fn (string $state) => match ($state) {
|
||||||
|
DataExport::STATUS_READY => 'success',
|
||||||
|
DataExport::STATUS_FAILED => 'danger',
|
||||||
|
DataExport::STATUS_PROCESSING => 'warning',
|
||||||
|
DataExport::STATUS_CANCELED => 'gray',
|
||||||
|
default => 'gray',
|
||||||
|
}),
|
||||||
|
IconColumn::make('include_media')
|
||||||
|
->label(__('admin.data_exports.fields.include_media'))
|
||||||
|
->boolean(),
|
||||||
|
TextColumn::make('size_bytes')
|
||||||
|
->label(__('admin.data_exports.fields.size'))
|
||||||
|
->formatStateUsing(fn (?int $state) => $state ? Number::fileSize($state) : '—')
|
||||||
|
->toggleable(),
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->label(__('admin.data_exports.fields.created_at'))
|
||||||
|
->since()
|
||||||
|
->sortable(),
|
||||||
|
TextColumn::make('expires_at')
|
||||||
|
->label(__('admin.data_exports.fields.expires_at'))
|
||||||
|
->since()
|
||||||
|
->toggleable(),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
SelectFilter::make('scope')
|
||||||
|
->label(__('admin.data_exports.fields.scope'))
|
||||||
|
->options([
|
||||||
|
'tenant' => __('admin.data_exports.scope.tenant'),
|
||||||
|
'event' => __('admin.data_exports.scope.event'),
|
||||||
|
'user' => __('admin.data_exports.scope.user'),
|
||||||
|
]),
|
||||||
|
SelectFilter::make('status')
|
||||||
|
->label(__('admin.data_exports.fields.status'))
|
||||||
|
->options([
|
||||||
|
DataExport::STATUS_PENDING => __('admin.data_exports.status.pending'),
|
||||||
|
DataExport::STATUS_PROCESSING => __('admin.data_exports.status.processing'),
|
||||||
|
DataExport::STATUS_READY => __('admin.data_exports.status.ready'),
|
||||||
|
DataExport::STATUS_FAILED => __('admin.data_exports.status.failed'),
|
||||||
|
DataExport::STATUS_CANCELED => __('admin.data_exports.status.canceled'),
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
Action::make('download')
|
||||||
|
->label(__('admin.data_exports.actions.download'))
|
||||||
|
->icon('heroicon-o-arrow-down-tray')
|
||||||
|
->url(fn (DataExport $record) => route('superadmin.data-exports.download', $record))
|
||||||
|
->openUrlInNewTab()
|
||||||
|
->visible(fn (DataExport $record): bool => $record->isReady() && ! $record->hasExpired()),
|
||||||
|
Action::make('retry')
|
||||||
|
->label(__('admin.data_exports.actions.retry'))
|
||||||
|
->icon('heroicon-o-arrow-path')
|
||||||
|
->color('warning')
|
||||||
|
->requiresConfirmation()
|
||||||
|
->visible(fn (DataExport $record): bool => $record->canRetry())
|
||||||
|
->action(function (DataExport $record): void {
|
||||||
|
if (! $record->canRetry()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$record->resetForRetry();
|
||||||
|
GenerateDataExport::dispatch($record->id);
|
||||||
|
|
||||||
|
app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
source: self::class
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
Action::make('cancel')
|
||||||
|
->label(__('admin.data_exports.actions.cancel'))
|
||||||
|
->icon('heroicon-o-x-circle')
|
||||||
|
->color('danger')
|
||||||
|
->requiresConfirmation()
|
||||||
|
->visible(fn (DataExport $record): bool => $record->canCancel())
|
||||||
|
->action(function (DataExport $record): void {
|
||||||
|
if (! $record->canCancel()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$record->markCanceled();
|
||||||
|
|
||||||
|
app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
source: self::class
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
->bulkActions([]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Clusters\WeeklyOps\WeeklyOpsCluster;
|
use App\Filament\Clusters\WeeklyOps\WeeklyOpsCluster;
|
||||||
use App\Filament\Resources\EmotionResource\Pages;
|
use App\Filament\Resources\EmotionResource\Pages;
|
||||||
use App\Models\Emotion;
|
use App\Models\Emotion;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Forms\Components\MarkdownEditor;
|
use Filament\Forms\Components\MarkdownEditor;
|
||||||
@@ -17,6 +18,7 @@ use Filament\Schemas\Components\Tabs\Tab as SchemaTab;
|
|||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use UnitEnum;
|
use UnitEnum;
|
||||||
|
|
||||||
class EmotionResource extends Resource
|
class EmotionResource extends Resource
|
||||||
@@ -116,10 +118,27 @@ class EmotionResource extends Resource
|
|||||||
])
|
])
|
||||||
->filters([])
|
->filters([])
|
||||||
->actions([
|
->actions([
|
||||||
Actions\EditAction::make(),
|
Actions\EditAction::make()
|
||||||
|
->after(fn (array $data, Emotion $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
Actions\DeleteBulkAction::make(),
|
Actions\DeleteBulkAction::make()
|
||||||
|
->after(function (Collection $records): void {
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ use Illuminate\Support\Facades\Storage;
|
|||||||
class ImportEmotions extends Page
|
class ImportEmotions extends Page
|
||||||
{
|
{
|
||||||
protected static string $resource = EmotionResource::class;
|
protected static string $resource = EmotionResource::class;
|
||||||
|
|
||||||
protected string $view = 'filament.resources.emotion-resource.pages.import-emotions';
|
protected string $view = 'filament.resources.emotion-resource.pages.import-emotions';
|
||||||
|
|
||||||
protected ?string $heading = null;
|
protected ?string $heading = null;
|
||||||
|
|
||||||
public ?string $file = null;
|
public ?string $file = null;
|
||||||
@@ -36,6 +38,7 @@ class ImportEmotions extends Page
|
|||||||
$path = $this->form->getState()['file'] ?? null;
|
$path = $this->form->getState()['file'] ?? null;
|
||||||
if (! $path || ! Storage::disk('public')->exists($path)) {
|
if (! $path || ! Storage::disk('public')->exists($path)) {
|
||||||
Notification::make()->danger()->title(__('admin.notifications.file_not_found'))->send();
|
Notification::make()->danger()->title(__('admin.notifications.file_not_found'))->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Resources\EmotionResource\Pages;
|
namespace App\Filament\Resources\EmotionResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\EmotionResource;
|
use App\Filament\Resources\EmotionResource;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Resources\Pages\ManageRecords;
|
use Filament\Resources\Pages\ManageRecords;
|
||||||
|
|
||||||
@@ -13,7 +14,13 @@ class ManageEmotions extends ManageRecords
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Actions\CreateAction::make(),
|
Actions\CreateAction::make()
|
||||||
|
->after(fn (array $data, $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'created',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
Actions\Action::make('import')
|
Actions\Action::make('import')
|
||||||
->label(__('admin.common.import_csv'))
|
->label(__('admin.common.import_csv'))
|
||||||
->icon('heroicon-o-arrow-up-tray')
|
->icon('heroicon-o-arrow-up-tray')
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Exports\EventPurchaseExporter;
|
|||||||
use App\Filament\Clusters\WeeklyOps\WeeklyOpsCluster;
|
use App\Filament\Clusters\WeeklyOps\WeeklyOpsCluster;
|
||||||
use App\Filament\Resources\EventPurchaseResource\Pages;
|
use App\Filament\Resources\EventPurchaseResource\Pages;
|
||||||
use App\Models\EventPurchase;
|
use App\Models\EventPurchase;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
@@ -23,6 +24,7 @@ use Filament\Tables\Filters\SelectFilter;
|
|||||||
use Filament\Tables\Filters\TernaryFilter;
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class EventPurchaseResource extends Resource
|
class EventPurchaseResource extends Resource
|
||||||
@@ -174,11 +176,29 @@ class EventPurchaseResource extends Resource
|
|||||||
->action(function (EventPurchase $record) {
|
->action(function (EventPurchase $record) {
|
||||||
$record->update(['refunded_at' => now()]);
|
$record->update(['refunded_at' => now()]);
|
||||||
Log::info('Refund processed for purchase ID: '.$record->id);
|
Log::info('Refund processed for purchase ID: '.$record->id);
|
||||||
|
|
||||||
|
app(SuperAdminAuditLogger::class)->record(
|
||||||
|
'event_purchase.refunded',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata(['refunded_at']),
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
DeleteBulkAction::make(),
|
DeleteBulkAction::make()
|
||||||
|
->after(function (Collection $records): void {
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
ExportBulkAction::make()
|
ExportBulkAction::make()
|
||||||
->label('Export CSV')
|
->label('Export CSV')
|
||||||
->exporter(EventPurchaseExporter::class),
|
->exporter(EventPurchaseExporter::class),
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
namespace App\Filament\Resources\EventPurchaseResource\Pages;
|
namespace App\Filament\Resources\EventPurchaseResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\EventPurchaseResource;
|
use App\Filament\Resources\EventPurchaseResource;
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
use App\Filament\Resources\Pages\AuditedCreateRecord;
|
||||||
|
|
||||||
class CreateEventPurchase extends CreateRecord
|
class CreateEventPurchase extends AuditedCreateRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = EventPurchaseResource::class;
|
protected static string $resource = EventPurchaseResource::class;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,11 @@
|
|||||||
namespace App\Filament\Resources\EventPurchaseResource\Pages;
|
namespace App\Filament\Resources\EventPurchaseResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\EventPurchaseResource;
|
use App\Filament\Resources\EventPurchaseResource;
|
||||||
|
use App\Filament\Resources\Pages\AuditedEditRecord;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditEventPurchase extends EditRecord
|
class EditEventPurchase extends AuditedEditRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = EventPurchaseResource::class;
|
protected static string $resource = EventPurchaseResource::class;
|
||||||
|
|
||||||
@@ -14,7 +15,12 @@ class EditEventPurchase extends EditRecord
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Actions\ViewAction::make(),
|
Actions\ViewAction::make(),
|
||||||
Actions\DeleteAction::make(),
|
Actions\DeleteAction::make()
|
||||||
|
->after(fn ($record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ class ListEventPurchases extends ListRecords
|
|||||||
Actions\CreateAction::make(),
|
Actions\CreateAction::make(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Resources\EventPurchaseResource\Pages;
|
namespace App\Filament\Resources\EventPurchaseResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\EventPurchaseResource;
|
use App\Filament\Resources\EventPurchaseResource;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
@@ -13,7 +14,13 @@ class ViewEventPurchase extends ViewRecord
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Actions\EditAction::make(),
|
Actions\EditAction::make()
|
||||||
|
->after(fn (array $data, $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,22 +6,29 @@ use App\Filament\Clusters\DailyOps\DailyOpsCluster;
|
|||||||
use App\Filament\Resources\EventResource\Pages;
|
use App\Filament\Resources\EventResource\Pages;
|
||||||
use App\Filament\Resources\EventResource\RelationManagers\EventPackagesRelationManager;
|
use App\Filament\Resources\EventResource\RelationManagers\EventPackagesRelationManager;
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
|
use App\Models\EventJoinToken;
|
||||||
use App\Models\EventJoinTokenEvent;
|
use App\Models\EventJoinTokenEvent;
|
||||||
use App\Models\EventType;
|
use App\Models\EventType;
|
||||||
use App\Models\Tenant;
|
use App\Models\Tenant;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
|
use App\Services\EventJoinTokenService;
|
||||||
use App\Support\JoinTokenLayoutRegistry;
|
use App\Support\JoinTokenLayoutRegistry;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Forms\Components\DatePicker;
|
use Filament\Forms\Components\DatePicker;
|
||||||
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
use Filament\Forms\Components\KeyValue;
|
use Filament\Forms\Components\KeyValue;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\Toggle;
|
use Filament\Forms\Components\Toggle;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use UnitEnum;
|
use UnitEnum;
|
||||||
|
|
||||||
class EventResource extends Resource
|
class EventResource extends Resource
|
||||||
@@ -58,19 +65,32 @@ class EventResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
->unique(ignoreRecord: true)
|
->unique(ignoreRecord: true)
|
||||||
->maxLength(255),
|
->maxLength(255),
|
||||||
|
TextInput::make('join_link_display')
|
||||||
|
->label(__('admin.events.fields.join_link'))
|
||||||
|
->afterStateHydrated(function (TextInput $component, ?Event $record) {
|
||||||
|
if (! $record) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$token = $record->joinTokens()->latest()->first();
|
||||||
|
$component->state($token ? url('/e/'.$token->token) : '-');
|
||||||
|
})
|
||||||
|
->readOnly()
|
||||||
|
->dehydrated(false)
|
||||||
|
->visibleOn('edit'),
|
||||||
DatePicker::make('date')
|
DatePicker::make('date')
|
||||||
->label(__('admin.events.fields.date'))
|
->label(__('admin.events.fields.date'))
|
||||||
->required(),
|
->required(),
|
||||||
Select::make('event_type_id')
|
Select::make('event_type_id')
|
||||||
->label(__('admin.events.fields.type'))
|
->label(__('admin.events.fields.type'))
|
||||||
->options(EventType::query()->pluck('name', 'id'))
|
->options(fn () => EventType::all()->pluck('name.de', 'id'))
|
||||||
->searchable(),
|
->searchable(),
|
||||||
Select::make('package_id')
|
Select::make('package_id')
|
||||||
->label(__('admin.events.fields.package'))
|
->label(__('admin.events.fields.package'))
|
||||||
->options(\App\Models\Package::query()->where('type', 'endcustomer')->pluck('name', 'id'))
|
->options(\App\Models\Package::query()->where('type', 'endcustomer')->pluck('name', 'id'))
|
||||||
->searchable()
|
->searchable()
|
||||||
->preload()
|
->preload()
|
||||||
->required(),
|
->required()
|
||||||
|
->visibleOn('create'),
|
||||||
TextInput::make('default_locale')
|
TextInput::make('default_locale')
|
||||||
->label(__('admin.events.fields.default_locale'))
|
->label(__('admin.events.fields.default_locale'))
|
||||||
->default('de')
|
->default('de')
|
||||||
@@ -78,6 +98,10 @@ class EventResource extends Resource
|
|||||||
Toggle::make('is_active')
|
Toggle::make('is_active')
|
||||||
->label(__('admin.events.fields.is_active'))
|
->label(__('admin.events.fields.is_active'))
|
||||||
->default(true),
|
->default(true),
|
||||||
|
Toggle::make('settings.marketing_demo')
|
||||||
|
->label(__('admin.events.fields.marketing_demo'))
|
||||||
|
->helperText(__('admin.events.fields.marketing_demo_help'))
|
||||||
|
->default(false),
|
||||||
KeyValue::make('settings')
|
KeyValue::make('settings')
|
||||||
->label(__('admin.events.fields.settings'))
|
->label(__('admin.events.fields.settings'))
|
||||||
->keyLabel(__('admin.common.key'))
|
->keyLabel(__('admin.common.key'))
|
||||||
@@ -94,13 +118,13 @@ class EventResource extends Resource
|
|||||||
->columns([
|
->columns([
|
||||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||||
Tables\Columns\TextColumn::make('tenant.name')->label(__('admin.events.table.tenant'))->searchable(),
|
Tables\Columns\TextColumn::make('tenant.name')->label(__('admin.events.table.tenant'))->searchable(),
|
||||||
Tables\Columns\TextColumn::make('name.de')
|
Tables\Columns\TextColumn::make('name')
|
||||||
->label(__('admin.events.fields.name'))
|
->label(__('admin.events.fields.name'))
|
||||||
|
->formatStateUsing(fn (mixed $state): string => static::formatEventName($state))
|
||||||
->limit(30),
|
->limit(30),
|
||||||
Tables\Columns\TextColumn::make('slug')->searchable(),
|
Tables\Columns\TextColumn::make('slug')->searchable(),
|
||||||
Tables\Columns\TextColumn::make('date')->date(),
|
Tables\Columns\TextColumn::make('date')->date(),
|
||||||
Tables\Columns\IconColumn::make('is_active')->boolean(),
|
Tables\Columns\IconColumn::make('is_active')->boolean(),
|
||||||
Tables\Columns\TextColumn::make('default_locale'),
|
|
||||||
Tables\Columns\TextColumn::make('eventPackage.package.name')
|
Tables\Columns\TextColumn::make('eventPackage.package.name')
|
||||||
->label(__('admin.events.table.package'))
|
->label(__('admin.events.table.package'))
|
||||||
->badge()
|
->badge()
|
||||||
@@ -113,31 +137,30 @@ class EventResource extends Resource
|
|||||||
->badge()
|
->badge()
|
||||||
->color(fn ($state) => $state < 1 ? 'danger' : 'success')
|
->color(fn ($state) => $state < 1 ? 'danger' : 'success')
|
||||||
->getStateUsing(fn ($record) => $record->eventPackage?->remaining_photos ?? 0),
|
->getStateUsing(fn ($record) => $record->eventPackage?->remaining_photos ?? 0),
|
||||||
Tables\Columns\TextColumn::make('primary_join_token')
|
|
||||||
->label(__('admin.events.table.join'))
|
|
||||||
->getStateUsing(function ($record) {
|
|
||||||
$token = $record->joinTokens()->latest()->first();
|
|
||||||
|
|
||||||
return $token ? url('/e/'.$token->token) : __('admin.events.table.no_join_tokens');
|
|
||||||
})
|
|
||||||
->description(function ($record) {
|
|
||||||
$total = $record->joinTokens()->count();
|
|
||||||
|
|
||||||
return $total > 0
|
|
||||||
? __('admin.events.table.join_tokens_total', ['count' => $total])
|
|
||||||
: __('admin.events.table.join_tokens_missing');
|
|
||||||
})
|
|
||||||
->copyable()
|
|
||||||
->copyMessage(__('admin.events.messages.join_link_copied')),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')->since(),
|
Tables\Columns\TextColumn::make('created_at')->since(),
|
||||||
])
|
])
|
||||||
->filters([])
|
->filters([])
|
||||||
->actions([
|
->actions([
|
||||||
Actions\EditAction::make(),
|
Actions\EditAction::make()
|
||||||
|
->after(fn (array $data, Event $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
Actions\Action::make('toggle')
|
Actions\Action::make('toggle')
|
||||||
->label(__('admin.events.actions.toggle_active'))
|
->label(__('admin.events.actions.toggle_active'))
|
||||||
->icon('heroicon-o-power')
|
->icon('heroicon-o-power')
|
||||||
->action(fn ($record) => $record->update(['is_active' => ! $record->is_active])),
|
->action(function (Event $record): void {
|
||||||
|
$record->update(['is_active' => ! $record->is_active]);
|
||||||
|
|
||||||
|
app(SuperAdminAuditLogger::class)->record(
|
||||||
|
'event.toggled',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata(['is_active']),
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}),
|
||||||
Actions\Action::make('download_photos')
|
Actions\Action::make('download_photos')
|
||||||
->label(__('admin.events.actions.download_photos'))
|
->label(__('admin.events.actions.download_photos'))
|
||||||
->icon('heroicon-o-arrow-down-tray')
|
->icon('heroicon-o-arrow-down-tray')
|
||||||
@@ -150,7 +173,161 @@ class EventResource extends Resource
|
|||||||
->modalHeading(__('admin.events.modal.join_link_heading'))
|
->modalHeading(__('admin.events.modal.join_link_heading'))
|
||||||
->modalSubmitActionLabel(__('admin.common.close'))
|
->modalSubmitActionLabel(__('admin.common.close'))
|
||||||
->modalWidth('xl')
|
->modalWidth('xl')
|
||||||
->modalContent(function ($record) {
|
->registerModalActions([
|
||||||
|
Actions\Action::make('extend_join_token_expiry')
|
||||||
|
->label(__('admin.events.join_link.extend_expiry'))
|
||||||
|
->icon('heroicon-o-clock')
|
||||||
|
->color('warning')
|
||||||
|
->size('xs')
|
||||||
|
->modalHeading(function (Actions\Action $action, Event $record): string {
|
||||||
|
$token = static::resolveJoinTokenFromAction($record, $action);
|
||||||
|
|
||||||
|
return $token
|
||||||
|
? __('admin.events.join_link.extend_expiry_heading', [
|
||||||
|
'label' => $token->label ?: __('admin.events.join_link.token_default', ['id' => $token->id]),
|
||||||
|
])
|
||||||
|
: __('admin.events.join_link.extend_expiry_heading_fallback');
|
||||||
|
})
|
||||||
|
->schema(function (Event $record): array {
|
||||||
|
$minimumExpiry = app(EventJoinTokenService::class)->minimumExpiryForEvent($record);
|
||||||
|
$rules = [
|
||||||
|
'date',
|
||||||
|
'after:now',
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($minimumExpiry) {
|
||||||
|
$rules[] = 'after_or_equal:'.$minimumExpiry->toDateTimeString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
DateTimePicker::make('expires_at')
|
||||||
|
->label(__('admin.events.join_link.extend_expiry_label'))
|
||||||
|
->required()
|
||||||
|
->seconds(false)
|
||||||
|
->rules($rules)
|
||||||
|
->helperText($minimumExpiry
|
||||||
|
? __('admin.events.join_link.extend_expiry_min', [
|
||||||
|
'date' => $minimumExpiry->isoFormat('LLL'),
|
||||||
|
])
|
||||||
|
: null),
|
||||||
|
];
|
||||||
|
})
|
||||||
|
->fillForm(function (Actions\Action $action, Event $record): array {
|
||||||
|
$token = static::resolveJoinTokenFromAction($record, $action);
|
||||||
|
|
||||||
|
if (! $token) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'expires_at' => $token->expires_at,
|
||||||
|
];
|
||||||
|
})
|
||||||
|
->action(function (array $data, Actions\Action $action, Event $record): void {
|
||||||
|
$token = static::resolveJoinTokenFromAction($record, $action);
|
||||||
|
|
||||||
|
if (! $token) {
|
||||||
|
Notification::make()
|
||||||
|
->title(__('admin.events.join_link.extend_expiry_missing'))
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$expiresAt = $data['expires_at'] ?? null;
|
||||||
|
|
||||||
|
if (! $expiresAt) {
|
||||||
|
Notification::make()
|
||||||
|
->title(__('admin.events.join_link.extend_expiry_missing_date'))
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$resolvedExpiry = $expiresAt instanceof Carbon
|
||||||
|
? $expiresAt
|
||||||
|
: Carbon::parse($expiresAt);
|
||||||
|
|
||||||
|
$token->forceFill([
|
||||||
|
'expires_at' => $resolvedExpiry,
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$token,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title(__('admin.events.join_link.extend_expiry_success'))
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
}),
|
||||||
|
Actions\Action::make('set_demo_read_only')
|
||||||
|
->label(__('admin.events.join_link.demo_read_only_action'))
|
||||||
|
->icon('heroicon-o-lock-closed')
|
||||||
|
->color('gray')
|
||||||
|
->size('xs')
|
||||||
|
->modalHeading(function (Actions\Action $action, Event $record): string {
|
||||||
|
$token = static::resolveJoinTokenFromAction($record, $action);
|
||||||
|
|
||||||
|
return $token
|
||||||
|
? __('admin.events.join_link.demo_read_only_heading', [
|
||||||
|
'label' => $token->label ?: __('admin.events.join_link.token_default', ['id' => $token->id]),
|
||||||
|
])
|
||||||
|
: __('admin.events.join_link.demo_read_only_heading_fallback');
|
||||||
|
})
|
||||||
|
->schema([
|
||||||
|
Toggle::make('demo_read_only')
|
||||||
|
->label(__('admin.events.join_link.demo_read_only_label'))
|
||||||
|
->helperText(__('admin.events.join_link.demo_read_only_help')),
|
||||||
|
])
|
||||||
|
->fillForm(function (Actions\Action $action, Event $record): array {
|
||||||
|
$token = static::resolveJoinTokenFromAction($record, $action);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'demo_read_only' => (bool) Arr::get($token?->metadata ?? [], 'demo_read_only', false),
|
||||||
|
];
|
||||||
|
})
|
||||||
|
->action(function (array $data, Actions\Action $action, Event $record): void {
|
||||||
|
$token = static::resolveJoinTokenFromAction($record, $action);
|
||||||
|
|
||||||
|
if (! $token) {
|
||||||
|
Notification::make()
|
||||||
|
->title(__('admin.events.join_link.demo_read_only_missing'))
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$metadata = is_array($token->metadata) ? $token->metadata : [];
|
||||||
|
$enabled = (bool) ($data['demo_read_only'] ?? false);
|
||||||
|
|
||||||
|
if ($enabled) {
|
||||||
|
$metadata['demo_read_only'] = true;
|
||||||
|
} else {
|
||||||
|
unset($metadata['demo_read_only']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$token->metadata = empty($metadata) ? null : $metadata;
|
||||||
|
$token->save();
|
||||||
|
|
||||||
|
app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$token,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title(__('admin.events.join_link.demo_read_only_success'))
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
->modalContent(function (Actions\Action $action, $record) {
|
||||||
$tokens = $record->joinTokens()
|
$tokens = $record->joinTokens()
|
||||||
->orderByDesc('created_at')
|
->orderByDesc('created_at')
|
||||||
->get();
|
->get();
|
||||||
@@ -220,6 +397,7 @@ class EventResource extends Resource
|
|||||||
'expires_at' => optional($token->expires_at)->toIso8601String(),
|
'expires_at' => optional($token->expires_at)->toIso8601String(),
|
||||||
'revoked_at' => optional($token->revoked_at)->toIso8601String(),
|
'revoked_at' => optional($token->revoked_at)->toIso8601String(),
|
||||||
'is_active' => $token->isActive(),
|
'is_active' => $token->isActive(),
|
||||||
|
'demo_read_only' => (bool) Arr::get($token->metadata ?? [], 'demo_read_only', false),
|
||||||
'created_at' => optional($token->created_at)->toIso8601String(),
|
'created_at' => optional($token->created_at)->toIso8601String(),
|
||||||
'layouts' => $layouts,
|
'layouts' => $layouts,
|
||||||
'layouts_url' => route('api.v1.tenant.events.join-tokens.layouts.index', [
|
'layouts_url' => route('api.v1.tenant.events.join-tokens.layouts.index', [
|
||||||
@@ -239,11 +417,23 @@ class EventResource extends Resource
|
|||||||
return view('filament.events.join-link', [
|
return view('filament.events.join-link', [
|
||||||
'event' => $record,
|
'event' => $record,
|
||||||
'tokens' => $tokens,
|
'tokens' => $tokens,
|
||||||
|
'action' => $action,
|
||||||
]);
|
]);
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
Actions\DeleteBulkAction::make(),
|
Actions\DeleteBulkAction::make()
|
||||||
|
->after(function (Collection $records): void {
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,6 +444,43 @@ class EventResource extends Resource
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed>|string|null $name
|
||||||
|
*/
|
||||||
|
private static function formatEventName(mixed $name): string
|
||||||
|
{
|
||||||
|
if (is_array($name)) {
|
||||||
|
$candidates = [
|
||||||
|
$name['de'] ?? null,
|
||||||
|
$name['en'] ?? null,
|
||||||
|
reset($name) ?: null,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($candidates as $candidate) {
|
||||||
|
if (is_string($candidate) && $candidate !== '') {
|
||||||
|
return $candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_string($name) ? $name : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function resolveJoinTokenFromAction(Event $record, Actions\Action $action): ?EventJoinToken
|
||||||
|
{
|
||||||
|
$tokenId = $action->getArguments()['token_id'] ?? null;
|
||||||
|
|
||||||
|
if (! $tokenId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $record->joinTokens()
|
||||||
|
->whereKey($tokenId)
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -3,9 +3,30 @@
|
|||||||
namespace App\Filament\Resources\EventResource\Pages;
|
namespace App\Filament\Resources\EventResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\EventResource;
|
use App\Filament\Resources\EventResource;
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
use App\Filament\Resources\Pages\AuditedCreateRecord;
|
||||||
|
|
||||||
class CreateEvent extends CreateRecord
|
class CreateEvent extends AuditedCreateRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = EventResource::class;
|
protected static string $resource = EventResource::class;
|
||||||
|
|
||||||
|
public ?int $packageId = null;
|
||||||
|
|
||||||
|
protected function mutateFormDataBeforeCreate(array $data): array
|
||||||
|
{
|
||||||
|
$this->packageId = $data['package_id'] ?? null;
|
||||||
|
unset($data['package_id']);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function afterCreate(): void
|
||||||
|
{
|
||||||
|
if ($this->packageId) {
|
||||||
|
$this->record->eventPackages()->create([
|
||||||
|
'package_id' => $this->packageId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::afterCreate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
namespace App\Filament\Resources\EventResource\Pages;
|
namespace App\Filament\Resources\EventResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\EventResource;
|
use App\Filament\Resources\EventResource;
|
||||||
use Filament\Resources\Pages\EditRecord;
|
use App\Filament\Resources\Pages\AuditedEditRecord;
|
||||||
|
|
||||||
class EditEvent extends EditRecord
|
class EditEvent extends AuditedEditRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = EventResource::class;
|
protected static string $resource = EventResource::class;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,27 +3,41 @@
|
|||||||
namespace App\Filament\Resources\EventResource\Pages;
|
namespace App\Filament\Resources\EventResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\EventResource;
|
use App\Filament\Resources\EventResource;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
|
||||||
use Filament\Resources\Pages\Page;
|
use Filament\Resources\Pages\Page;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class ManageWatermark extends Page
|
class ManageWatermark extends Page
|
||||||
{
|
{
|
||||||
|
use InteractsWithRecord;
|
||||||
|
|
||||||
protected static string $resource = EventResource::class;
|
protected static string $resource = EventResource::class;
|
||||||
|
|
||||||
protected string $view = 'filament.resources.event-resource.pages.manage-watermark';
|
protected string $view = 'filament.resources.event-resource.pages.manage-watermark';
|
||||||
|
|
||||||
public ?string $watermark_mode = 'base';
|
public ?string $watermark_mode = 'base';
|
||||||
|
|
||||||
public ?string $watermark_asset = null;
|
public ?string $watermark_asset = null;
|
||||||
|
|
||||||
public string $watermark_position = 'bottom-right';
|
public string $watermark_position = 'bottom-right';
|
||||||
|
|
||||||
public float $watermark_opacity = 0.25;
|
public float $watermark_opacity = 0.25;
|
||||||
|
|
||||||
public float $watermark_scale = 0.2;
|
public float $watermark_scale = 0.2;
|
||||||
|
|
||||||
public int $watermark_padding = 16;
|
public int $watermark_padding = 16;
|
||||||
|
|
||||||
public bool $serve_originals = false;
|
public bool $serve_originals = false;
|
||||||
|
|
||||||
public function mount(): void
|
public function mount(int|string $record): void
|
||||||
{
|
{
|
||||||
|
$this->record = $this->resolveRecord($record);
|
||||||
|
|
||||||
$event = $this->record;
|
$event = $this->record;
|
||||||
$settings = $event->settings ?? [];
|
$settings = $event->settings ?? [];
|
||||||
$watermark = Arr::get($settings, 'watermark', []);
|
$watermark = Arr::get($settings, 'watermark', []);
|
||||||
@@ -37,67 +51,62 @@ class ManageWatermark extends Page
|
|||||||
$this->serve_originals = (bool) Arr::get($settings, 'watermark_serve_originals', false);
|
$this->serve_originals = (bool) Arr::get($settings, 'watermark_serve_originals', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getForms(): array
|
public function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return [
|
return $schema->schema([
|
||||||
'form' => $this->form(
|
Section::make(__('filament-watermark.heading'))
|
||||||
$this->makeForm()
|
->schema([
|
||||||
->schema([
|
Forms\Components\Select::make('watermark_mode')
|
||||||
Forms\Components\Fieldset::make(__('filament-watermark.heading'))
|
->label(__('filament-watermark.mode.label'))
|
||||||
->schema([
|
->options([
|
||||||
Forms\Components\Select::make('watermark_mode')
|
'base' => __('filament-watermark.mode.base'),
|
||||||
->label(__('filament-watermark.mode.label'))
|
'custom' => __('filament-watermark.mode.custom'),
|
||||||
->options([
|
'off' => __('filament-watermark.mode.off'),
|
||||||
'base' => __('filament-watermark.mode.base'),
|
])
|
||||||
'custom' => __('filament-watermark.mode.custom'),
|
->required(),
|
||||||
'off' => __('filament-watermark.mode.off'),
|
Forms\Components\FileUpload::make('watermark_asset')
|
||||||
])
|
->label(__('filament-watermark.asset'))
|
||||||
->required(),
|
->disk('public')
|
||||||
Forms\Components\FileUpload::make('watermark_asset')
|
->directory('branding')
|
||||||
->label(__('filament-watermark.asset'))
|
->preserveFilenames()
|
||||||
->disk('public')
|
->image()
|
||||||
->directory('branding')
|
->visible(fn (callable $get) => $get('watermark_mode') === 'custom'),
|
||||||
->preserveFilenames()
|
Forms\Components\Select::make('watermark_position')
|
||||||
->image()
|
->label(__('filament-watermark.position'))
|
||||||
->visible(fn (callable $get) => $get('watermark_mode') === 'custom'),
|
->options([
|
||||||
Forms\Components\Select::make('watermark_position')
|
'top-left' => 'Top Left',
|
||||||
->label(__('filament-watermark.position'))
|
'top-right' => 'Top Right',
|
||||||
->options([
|
'bottom-left' => 'Bottom Left',
|
||||||
'top-left' => 'Top Left',
|
'bottom-right' => 'Bottom Right',
|
||||||
'top-right' => 'Top Right',
|
'center' => 'Center',
|
||||||
'bottom-left' => 'Bottom Left',
|
])
|
||||||
'bottom-right' => 'Bottom Right',
|
->required(),
|
||||||
'center' => 'Center',
|
Forms\Components\TextInput::make('watermark_opacity')
|
||||||
])
|
->label(__('filament-watermark.opacity'))
|
||||||
->required(),
|
->numeric()
|
||||||
Forms\Components\TextInput::make('watermark_opacity')
|
->minValue(0)
|
||||||
->label(__('filament-watermark.opacity'))
|
->maxValue(1)
|
||||||
->numeric()
|
->step(0.05)
|
||||||
->minValue(0)
|
->required(),
|
||||||
->maxValue(1)
|
Forms\Components\TextInput::make('watermark_scale')
|
||||||
->step(0.05)
|
->label(__('filament-watermark.scale'))
|
||||||
->required(),
|
->numeric()
|
||||||
Forms\Components\TextInput::make('watermark_scale')
|
->minValue(0.05)
|
||||||
->label(__('filament-watermark.scale'))
|
->maxValue(1)
|
||||||
->numeric()
|
->step(0.05)
|
||||||
->minValue(0.05)
|
->required(),
|
||||||
->maxValue(1)
|
Forms\Components\TextInput::make('watermark_padding')
|
||||||
->step(0.05)
|
->label(__('filament-watermark.padding'))
|
||||||
->required(),
|
->numeric()
|
||||||
Forms\Components\TextInput::make('watermark_padding')
|
->minValue(0)
|
||||||
->label(__('filament-watermark.padding'))
|
->required(),
|
||||||
->numeric()
|
Forms\Components\Toggle::make('serve_originals')
|
||||||
->minValue(0)
|
->label(__('filament-watermark.serve_originals'))
|
||||||
->required(),
|
->helperText('Nur Admin/Owner: falls aktiviert, werden Originale statt watermarked ausgeliefert.')
|
||||||
Forms\Components\Toggle::make('serve_originals')
|
->default(false),
|
||||||
->label(__('filament-watermark.serve_originals'))
|
])
|
||||||
->helperText('Nur Admin/Owner: falls aktiviert, werden Originale statt watermarked ausgeliefert.')
|
->columns(2),
|
||||||
->default(false),
|
]);
|
||||||
])
|
|
||||||
->columns(2),
|
|
||||||
])
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save(): void
|
public function save(): void
|
||||||
@@ -133,6 +142,17 @@ class ManageWatermark extends Page
|
|||||||
|
|
||||||
$event->forceFill(['settings' => $settings])->save();
|
$event->forceFill(['settings' => $settings])->save();
|
||||||
|
|
||||||
|
$changed = array_diff(array_keys($event->getChanges()), ['updated_at']);
|
||||||
|
|
||||||
|
if ($changed !== []) {
|
||||||
|
app(SuperAdminAuditLogger::class)->record(
|
||||||
|
'event.watermark_updated',
|
||||||
|
$event,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($changed),
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title(__('filament-watermark.saved'))
|
->title(__('filament-watermark.saved'))
|
||||||
->success()
|
->success()
|
||||||
|
|||||||
@@ -3,23 +3,22 @@
|
|||||||
namespace App\Filament\Resources\EventResource\RelationManagers;
|
namespace App\Filament\Resources\EventResource\RelationManagers;
|
||||||
|
|
||||||
use App\Models\EventPackage;
|
use App\Models\EventPackage;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\CreateAction;
|
use Filament\Actions\CreateAction;
|
||||||
use Filament\Actions\DeleteAction;
|
use Filament\Actions\DeleteAction;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
use Filament\Forms;
|
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Resources\RelationManagers\RelationManager;
|
use Filament\Resources\RelationManagers\RelationManager;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Tables;
|
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
|
||||||
|
|
||||||
class EventPackagesRelationManager extends RelationManager
|
class EventPackagesRelationManager extends RelationManager
|
||||||
{
|
{
|
||||||
@@ -59,6 +58,7 @@ class EventPackagesRelationManager extends RelationManager
|
|||||||
public function table(Table $table): Table
|
public function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
|
->modifyQueryUsing(fn (Builder $query) => $query->with('package'))
|
||||||
->recordTitleAttribute('package.name')
|
->recordTitleAttribute('package.name')
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('package.name')
|
TextColumn::make('package.name')
|
||||||
@@ -93,15 +93,43 @@ class EventPackagesRelationManager extends RelationManager
|
|||||||
])
|
])
|
||||||
->filters([])
|
->filters([])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
CreateAction::make(),
|
CreateAction::make()
|
||||||
|
->after(fn (array $data, EventPackage $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'created',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
])
|
])
|
||||||
->actions([
|
->actions([
|
||||||
EditAction::make(),
|
EditAction::make()
|
||||||
DeleteAction::make(),
|
->after(fn (array $data, EventPackage $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
|
DeleteAction::make()
|
||||||
|
->after(fn (EventPackage $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
DeleteBulkAction::make(),
|
DeleteBulkAction::make()
|
||||||
|
->after(function (Collection $records): void {
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -119,9 +147,4 @@ class EventPackagesRelationManager extends RelationManager
|
|||||||
{
|
{
|
||||||
return __('admin.events.relation_managers.event_packages.title');
|
return __('admin.events.relation_managers.event_packages.title');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTableQuery(): Builder|Relation
|
|
||||||
{
|
|
||||||
return parent::getTableQuery()->with('package');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Clusters\WeeklyOps\WeeklyOpsCluster;
|
use App\Filament\Clusters\WeeklyOps\WeeklyOpsCluster;
|
||||||
use App\Filament\Resources\EventTypeResource\Pages;
|
use App\Filament\Resources\EventTypeResource\Pages;
|
||||||
use App\Models\EventType;
|
use App\Models\EventType;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Forms\Components\KeyValue;
|
use Filament\Forms\Components\KeyValue;
|
||||||
@@ -16,6 +17,7 @@ use Filament\Schemas\Components\Tabs\Tab as SchemaTab;
|
|||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use UnitEnum;
|
use UnitEnum;
|
||||||
|
|
||||||
class EventTypeResource extends Resource
|
class EventTypeResource extends Resource
|
||||||
@@ -104,10 +106,73 @@ class EventTypeResource extends Resource
|
|||||||
])
|
])
|
||||||
->filters([])
|
->filters([])
|
||||||
->actions([
|
->actions([
|
||||||
Actions\EditAction::make(),
|
Actions\EditAction::make()
|
||||||
|
->after(fn (array $data, EventType $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
|
Actions\DeleteAction::make()
|
||||||
|
->action(function (EventType $record, Actions\DeleteAction $action) {
|
||||||
|
try {
|
||||||
|
$record->delete();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$isConstraint = ($e instanceof \Illuminate\Database\QueryException && ($e->getCode() == 23000 || ($e->errorInfo[0] ?? '') == 23000));
|
||||||
|
|
||||||
|
if ($isConstraint) {
|
||||||
|
\Filament\Notifications\Notification::make()
|
||||||
|
->title(__('admin.common.error'))
|
||||||
|
->body(__('admin.event_types.messages.delete_constraint_error'))
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$action->halt();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->after(fn (EventType $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
)),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
Actions\DeleteBulkAction::make(),
|
Actions\DeleteBulkAction::make()
|
||||||
|
->action(function (Collection $records, Actions\DeleteBulkAction $action) {
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
$deletedCount = 0;
|
||||||
|
$failedCount = 0;
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
try {
|
||||||
|
$record->delete();
|
||||||
|
$logger->recordModelMutation('deleted', $record, source: static::class);
|
||||||
|
$deletedCount++;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$isConstraint = ($e instanceof \Illuminate\Database\QueryException && ($e->getCode() == 23000 || ($e->errorInfo[0] ?? '') == 23000));
|
||||||
|
if ($isConstraint) {
|
||||||
|
$failedCount++;
|
||||||
|
} else {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($failedCount > 0) {
|
||||||
|
\Filament\Notifications\Notification::make()
|
||||||
|
->title(__('admin.common.error'))
|
||||||
|
->body(__('admin.event_types.messages.delete_constraint_error')." ($failedCount failed, $deletedCount deleted)")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
if ($deletedCount === 0) {
|
||||||
|
$action->halt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Resources\EventTypeResource\Pages;
|
namespace App\Filament\Resources\EventTypeResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\EventTypeResource;
|
use App\Filament\Resources\EventTypeResource;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Resources\Pages\ManageRecords;
|
use Filament\Resources\Pages\ManageRecords;
|
||||||
|
|
||||||
@@ -13,7 +14,13 @@ class ManageEventTypes extends ManageRecords
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Actions\CreateAction::make(),
|
Actions\CreateAction::make()
|
||||||
|
->after(fn (array $data, $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'created',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Clusters\WeeklyOps\WeeklyOpsCluster;
|
use App\Filament\Clusters\WeeklyOps\WeeklyOpsCluster;
|
||||||
use App\Filament\Resources\GiftVoucherResource\Pages;
|
use App\Filament\Resources\GiftVoucherResource\Pages;
|
||||||
use App\Models\GiftVoucher;
|
use App\Models\GiftVoucher;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use App\Services\GiftVouchers\GiftVoucherService;
|
use App\Services\GiftVouchers\GiftVoucherService;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
@@ -62,8 +63,8 @@ class GiftVoucherResource extends Resource
|
|||||||
->label('Empfänger')
|
->label('Empfänger')
|
||||||
->toggleable()
|
->toggleable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
TextColumn::make('paddle_transaction_id')
|
TextColumn::make('lemonsqueezy_order_id')
|
||||||
->label('Paddle Tx')
|
->label('Lemon Squeezy Order')
|
||||||
->toggleable()
|
->toggleable()
|
||||||
->copyable()
|
->copyable()
|
||||||
->wrap(),
|
->wrap(),
|
||||||
@@ -97,6 +98,13 @@ class GiftVoucherResource extends Resource
|
|||||||
->visible(fn (GiftVoucher $record): bool => $record->canBeRefunded())
|
->visible(fn (GiftVoucher $record): bool => $record->canBeRefunded())
|
||||||
->action(function (GiftVoucher $record, GiftVoucherService $service): void {
|
->action(function (GiftVoucher $record, GiftVoucherService $service): void {
|
||||||
$service->refund($record, 'customer_request');
|
$service->refund($record, 'customer_request');
|
||||||
|
|
||||||
|
app(SuperAdminAuditLogger::class)->record(
|
||||||
|
'gift_voucher.refunded',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata(['status', 'refunded_at']),
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
})
|
})
|
||||||
->successNotificationTitle('Gutschein erstattet'),
|
->successNotificationTitle('Gutschein erstattet'),
|
||||||
Action::make('resend')
|
Action::make('resend')
|
||||||
@@ -118,6 +126,13 @@ class GiftVoucherResource extends Resource
|
|||||||
$record,
|
$record,
|
||||||
Carbon::parse($data['recipient_delivery_scheduled_at'])
|
Carbon::parse($data['recipient_delivery_scheduled_at'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
app(SuperAdminAuditLogger::class)->record(
|
||||||
|
'gift_voucher.delivery_scheduled',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
})
|
})
|
||||||
->visible(fn (GiftVoucher $record): bool => ! empty($record->recipient_email)),
|
->visible(fn (GiftVoucher $record): bool => ! empty($record->recipient_email)),
|
||||||
Action::make('mark_redeemed')
|
Action::make('mark_redeemed')
|
||||||
@@ -136,6 +151,13 @@ class GiftVoucherResource extends Resource
|
|||||||
'manual_marked' => true,
|
'manual_marked' => true,
|
||||||
]),
|
]),
|
||||||
])->save();
|
])->save();
|
||||||
|
|
||||||
|
app(SuperAdminAuditLogger::class)->record(
|
||||||
|
'gift_voucher.marked_redeemed',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata(['status', 'redeemed_at', 'metadata']),
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
})
|
})
|
||||||
->successNotificationTitle('Als eingelöst markiert'),
|
->successNotificationTitle('Als eingelöst markiert'),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -3,11 +3,12 @@
|
|||||||
namespace App\Filament\Resources\GiftVoucherResource\Pages;
|
namespace App\Filament\Resources\GiftVoucherResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\GiftVoucherResource;
|
use App\Filament\Resources\GiftVoucherResource;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use App\Services\GiftVouchers\GiftVoucherService;
|
use App\Services\GiftVouchers\GiftVoucherService;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Forms\Components\Placeholder;
|
use Filament\Forms\Components\Placeholder;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class ListGiftVouchers extends ListRecords
|
class ListGiftVouchers extends ListRecords
|
||||||
@@ -45,24 +46,40 @@ class ListGiftVouchers extends ListRecords
|
|||||||
])
|
])
|
||||||
->action(function (array $data, GiftVoucherService $service): void {
|
->action(function (array $data, GiftVoucherService $service): void {
|
||||||
$payload = [
|
$payload = [
|
||||||
'id' => null,
|
'meta' => [
|
||||||
'metadata' => [
|
'custom_data' => [
|
||||||
'type' => 'gift_voucher',
|
'type' => 'gift_voucher',
|
||||||
'purchaser_email' => $data['purchaser_email'],
|
'purchaser_email' => $data['purchaser_email'],
|
||||||
'recipient_email' => $data['recipient_email'] ?? null,
|
'recipient_email' => $data['recipient_email'] ?? null,
|
||||||
'recipient_name' => $data['recipient_name'] ?? null,
|
'recipient_name' => $data['recipient_name'] ?? null,
|
||||||
'message' => $data['message'] ?? null,
|
'message' => $data['message'] ?? null,
|
||||||
'gift_code' => $data['code'] ?? null,
|
'gift_code' => $data['code'] ?? null,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'currency_code' => $data['currency'] ?? 'EUR',
|
'data' => [
|
||||||
'totals' => [
|
'id' => 'manual_'.Str::uuid(),
|
||||||
'grand_total' => [
|
'attributes' => [
|
||||||
'amount' => (float) $data['amount'],
|
'currency' => $data['currency'] ?? 'EUR',
|
||||||
|
'total' => (float) $data['amount'] * 100,
|
||||||
|
'user_email' => $data['purchaser_email'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$service->issueFromPaddle($payload);
|
$voucher = $service->issueFromLemonSqueezy($payload);
|
||||||
|
|
||||||
|
app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'issued',
|
||||||
|
$voucher,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata([
|
||||||
|
'amount',
|
||||||
|
'currency',
|
||||||
|
'status',
|
||||||
|
'expires_at',
|
||||||
|
'coupon_id',
|
||||||
|
]),
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
})
|
})
|
||||||
->modalHeading('Geschenkgutschein ausstellen'),
|
->modalHeading('Geschenkgutschein ausstellen'),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Clusters\RareAdmin\RareAdminCluster;
|
use App\Filament\Clusters\RareAdmin\RareAdminCluster;
|
||||||
use App\Filament\Resources\LegalPageResource\Pages;
|
use App\Filament\Resources\LegalPageResource\Pages;
|
||||||
use App\Models\LegalPage;
|
use App\Models\LegalPage;
|
||||||
|
use App\Services\Audit\SuperAdminAuditLogger;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Forms\Components\DatePicker;
|
use Filament\Forms\Components\DatePicker;
|
||||||
@@ -18,6 +19,7 @@ use Filament\Schemas\Components\Tabs\Tab as SchemaTab;
|
|||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use UnitEnum;
|
use UnitEnum;
|
||||||
|
|
||||||
class LegalPageResource extends Resource
|
class LegalPageResource extends Resource
|
||||||
@@ -99,10 +101,27 @@ class LegalPageResource extends Resource
|
|||||||
])
|
])
|
||||||
->filters([])
|
->filters([])
|
||||||
->actions([
|
->actions([
|
||||||
Actions\EditAction::make(),
|
Actions\EditAction::make()
|
||||||
|
->after(fn (array $data, LegalPage $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||||
|
'updated',
|
||||||
|
$record,
|
||||||
|
SuperAdminAuditLogger::fieldsMetadata($data),
|
||||||
|
static::class
|
||||||
|
)),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
Actions\DeleteBulkAction::make(),
|
Actions\DeleteBulkAction::make()
|
||||||
|
->after(function (Collection $records): void {
|
||||||
|
$logger = app(SuperAdminAuditLogger::class);
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$logger->recordModelMutation(
|
||||||
|
'deleted',
|
||||||
|
$record,
|
||||||
|
source: static::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user