Selaa lähdekoodia

Add project foundation, store creation, and storefront renderer

Step 1: Laravel 13 + Inertia + React + TypeScript starter kit, auth,
create-a-store flow, dashboard listing the user's own stores.

Step 2: store plan format and validator, 10 storefront sections with
2 variants each, renderer, dashboard preview, temporary sample design.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
feature/store-sections-renderer
fahmisaad 6 päivää sitten
commit
a09cf92f8c
100 muutettua tiedostoa jossa 22675 lisäystä ja 0 poistoa
  1. 18
    0
      .editorconfig
  2. 65
    0
      .env.example
  3. 11
    0
      .gitattributes
  4. 12
    0
      .github/dependabot.yml
  5. 38
    0
      .github/workflows/tests.yml
  6. 44
    0
      .gitignore
  7. 1
    0
      .npmrc
  8. 17
    0
      CLAUDE.md
  9. 239
    0
      PROGRESS.md
  10. 33
    0
      app/Actions/Fortify/CreateNewUser.php
  11. 29
    0
      app/Actions/Fortify/ResetUserPassword.php
  12. 29
    0
      app/Concerns/PasswordValidationRules.php
  13. 52
    0
      app/Concerns/ProfileValidationRules.php
  14. 44
    0
      app/Enums/StoreCategory.php
  15. 30
    0
      app/Enums/StoreLanguage.php
  16. 17
    0
      app/Enums/StoreStatus.php
  17. 8
    0
      app/Http/Controllers/Controller.php
  18. 62
    0
      app/Http/Controllers/Settings/ProfileController.php
  19. 49
    0
      app/Http/Controllers/Settings/SecurityController.php
  20. 87
    0
      app/Http/Controllers/StoreController.php
  21. 53
    0
      app/Http/Controllers/StoreDesignController.php
  22. 23
    0
      app/Http/Middleware/HandleAppearance.php
  23. 47
    0
      app/Http/Middleware/HandleInertiaRequests.php
  24. 25
    0
      app/Http/Requests/Settings/PasswordUpdateRequest.php
  25. 24
    0
      app/Http/Requests/Settings/ProfileDeleteRequest.php
  26. 33
    0
      app/Http/Requests/Settings/ProfileUpdateRequest.php
  27. 22
    0
      app/Http/Requests/Settings/TwoFactorAuthenticationRequest.php
  28. 37
    0
      app/Http/Requests/Stores/CreateStoreRequest.php
  29. 106
    0
      app/Models/Store.php
  30. 59
    0
      app/Models/User.php
  31. 50
    0
      app/Providers/AppServiceProvider.php
  32. 95
    0
      app/Providers/FortifyServiceProvider.php
  33. 183
    0
      app/StorePlan/PlanSchema.php
  34. 106
    0
      app/StorePlan/PlanValidator.php
  35. 176
    0
      app/StorePlan/SamplePlan.php
  36. 18
    0
      artisan
  37. 30
    0
      bootstrap/app.php
  38. 2
    0
      bootstrap/cache/.gitignore
  39. 9
    0
      bootstrap/providers.php
  40. 21
    0
      components.json
  41. 116
    0
      composer.json
  42. 10476
    0
      composer.lock
  43. 126
    0
      config/app.php
  44. 117
    0
      config/auth.php
  45. 136
    0
      config/cache.php
  46. 184
    0
      config/database.php
  47. 80
    0
      config/filesystems.php
  48. 157
    0
      config/fortify.php
  49. 70
    0
      config/inertia.php
  50. 140
    0
      config/logging.php
  51. 118
    0
      config/mail.php
  52. 129
    0
      config/queue.php
  53. 38
    0
      config/services.php
  54. 233
    0
      config/session.php
  55. 1
    0
      database/.gitignore
  56. 30
    0
      database/factories/StoreFactory.php
  57. 60
    0
      database/factories/UserFactory.php
  58. 49
    0
      database/migrations/0001_01_01_000000_create_users_table.php
  59. 35
    0
      database/migrations/0001_01_01_000001_create_cache_table.php
  60. 59
    0
      database/migrations/0001_01_01_000002_create_jobs_table.php
  61. 34
    0
      database/migrations/2025_08_14_170933_add_two_factor_columns_to_users_table.php
  62. 34
    0
      database/migrations/2026_11_14_000000_create_stores_table.php
  63. 28
    0
      database/migrations/2026_11_14_000001_add_plan_to_stores_table.php
  64. 25
    0
      database/seeders/DatabaseSeeder.php
  65. 6283
    0
      package-lock.json
  66. 67
    0
      package.json
  67. 13
    0
      phpstan.neon
  68. 36
    0
      phpunit.xml
  69. 3
    0
      pint.json
  70. 5
    0
      pnpm-workspace.yaml
  71. 25
    0
      public/.htaccess
  72. BIN
      public/apple-touch-icon.png
  73. BIN
      public/favicon.ico
  74. 3
    0
      public/favicon.svg
  75. 20
    0
      public/index.php
  76. 2
    0
      public/robots.txt
  77. 160
    0
      resources/css/app.css
  78. 42
    0
      resources/js/app.tsx
  79. 24
    0
      resources/js/components/alert-error.tsx
  80. 22
    0
      resources/js/components/app-content.tsx
  81. 248
    0
      resources/js/components/app-header.tsx
  82. 13
    0
      resources/js/components/app-logo-icon.tsx
  83. 20
    0
      resources/js/components/app-logo.tsx
  84. 21
    0
      resources/js/components/app-shell.tsx
  85. 18
    0
      resources/js/components/app-sidebar-header.tsx
  86. 65
    0
      resources/js/components/app-sidebar.tsx
  87. 45
    0
      resources/js/components/appearance-tabs.tsx
  88. 50
    0
      resources/js/components/breadcrumbs.tsx
  89. 120
    0
      resources/js/components/delete-user.tsx
  90. 26
    0
      resources/js/components/heading.tsx
  91. 17
    0
      resources/js/components/input-error.tsx
  92. 126
    0
      resources/js/components/manage-two-factor.tsx
  93. 49
    0
      resources/js/components/nav-footer.tsx
  94. 36
    0
      resources/js/components/nav-main.tsx
  95. 58
    0
      resources/js/components/nav-user.tsx
  96. 37
    0
      resources/js/components/password-input.tsx
  97. 23
    0
      resources/js/components/text-link.tsx
  98. 164
    0
      resources/js/components/two-factor-recovery-codes.tsx
  99. 355
    0
      resources/js/components/two-factor-setup-modal.tsx
  100. 0
    0
      resources/js/components/ui/alert.tsx

+ 18
- 0
.editorconfig Näytä tiedosto

@@ -0,0 +1,18 @@
1
+root = true
2
+
3
+[*]
4
+charset = utf-8
5
+end_of_line = lf
6
+indent_size = 4
7
+indent_style = space
8
+insert_final_newline = true
9
+trim_trailing_whitespace = true
10
+
11
+[*.md]
12
+trim_trailing_whitespace = false
13
+
14
+[*.{yml,yaml}]
15
+indent_size = 2
16
+
17
+[{compose,docker-compose}.{yml,yaml}]
18
+indent_size = 4

+ 65
- 0
.env.example Näytä tiedosto

@@ -0,0 +1,65 @@
1
+APP_NAME=Laravel
2
+APP_ENV=local
3
+APP_KEY=
4
+APP_DEBUG=true
5
+APP_URL=http://localhost:8000
6
+
7
+APP_LOCALE=en
8
+APP_FALLBACK_LOCALE=en
9
+APP_FAKER_LOCALE=en_US
10
+
11
+APP_MAINTENANCE_DRIVER=file
12
+# APP_MAINTENANCE_STORE=database
13
+
14
+# PHP_CLI_SERVER_WORKERS=4
15
+
16
+BCRYPT_ROUNDS=12
17
+
18
+LOG_CHANNEL=stack
19
+LOG_STACK=single
20
+LOG_DEPRECATIONS_CHANNEL=null
21
+LOG_LEVEL=debug
22
+
23
+DB_CONNECTION=sqlite
24
+# DB_HOST=127.0.0.1
25
+# DB_PORT=3306
26
+# DB_DATABASE=laravel
27
+# DB_USERNAME=root
28
+# DB_PASSWORD=
29
+
30
+SESSION_DRIVER=database
31
+SESSION_LIFETIME=120
32
+SESSION_ENCRYPT=false
33
+SESSION_PATH=/
34
+SESSION_DOMAIN=null
35
+
36
+BROADCAST_CONNECTION=log
37
+FILESYSTEM_DISK=local
38
+QUEUE_CONNECTION=database
39
+
40
+CACHE_STORE=database
41
+# CACHE_PREFIX=
42
+
43
+MEMCACHED_HOST=127.0.0.1
44
+
45
+REDIS_CLIENT=phpredis
46
+REDIS_HOST=127.0.0.1
47
+REDIS_PASSWORD=null
48
+REDIS_PORT=6379
49
+
50
+MAIL_MAILER=log
51
+MAIL_SCHEME=null
52
+MAIL_HOST=127.0.0.1
53
+MAIL_PORT=2525
54
+MAIL_USERNAME=null
55
+MAIL_PASSWORD=null
56
+MAIL_FROM_ADDRESS="hello@example.com"
57
+MAIL_FROM_NAME="${APP_NAME}"
58
+
59
+AWS_ACCESS_KEY_ID=
60
+AWS_SECRET_ACCESS_KEY=
61
+AWS_DEFAULT_REGION=us-east-1
62
+AWS_BUCKET=
63
+AWS_USE_PATH_STYLE_ENDPOINT=false
64
+
65
+VITE_APP_NAME="${APP_NAME}"

+ 11
- 0
.gitattributes Näytä tiedosto

@@ -0,0 +1,11 @@
1
+* text=auto eol=lf
2
+
3
+*.blade.php diff=html
4
+*.css diff=css
5
+*.html diff=html
6
+*.md diff=markdown
7
+*.php diff=php
8
+
9
+CHANGELOG.md export-ignore
10
+README.md export-ignore
11
+.github/workflows/browser-tests.yml export-ignore

+ 12
- 0
.github/dependabot.yml Näytä tiedosto

@@ -0,0 +1,12 @@
1
+version: 2
2
+updates:
3
+  - package-ecosystem: "github-actions"
4
+    directory: "/"
5
+    schedule:
6
+      interval: "weekly"
7
+    cooldown:
8
+      default-days: 5
9
+    groups:
10
+      github-actions:
11
+        patterns:
12
+          - "*"

+ 38
- 0
.github/workflows/tests.yml Näytä tiedosto

@@ -0,0 +1,38 @@
1
+name: tests
2
+
3
+on:
4
+  push:
5
+    branches:
6
+      - main
7
+  pull_request:
8
+
9
+permissions:
10
+  contents: read
11
+
12
+jobs:
13
+  ci:
14
+    runs-on: ubuntu-latest
15
+
16
+    steps:
17
+      - name: Checkout code
18
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
19
+        with:
20
+          persist-credentials: false
21
+
22
+      - name: Setup PHP
23
+        uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
24
+        with:
25
+          php-version: '8.3'
26
+          tools: composer:v2
27
+          coverage: none
28
+
29
+      - name: Setup Node
30
+        uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
31
+        with:
32
+          node-version: '22'
33
+
34
+      - name: Setup Application
35
+        run: composer setup
36
+
37
+      - name: Run CI Checks
38
+        run: composer ci:check

+ 44
- 0
.gitignore Näytä tiedosto

@@ -0,0 +1,44 @@
1
+/.phpunit.cache
2
+/bootstrap/ssr
3
+/node_modules
4
+/public/build
5
+/public/fonts-manifest.dev.json
6
+/public/hot
7
+/public/storage
8
+/storage/*.key
9
+/storage/pail
10
+/resources/js/actions
11
+/resources/js/routes
12
+/resources/js/wayfinder
13
+/vendor
14
+.DS_Store
15
+.env
16
+.env.backup
17
+.env.production
18
+.phpactor.json
19
+.phpunit.result.cache
20
+Homestead.json
21
+Homestead.yaml
22
+npm-debug.log
23
+yarn-error.log
24
+/auth.json
25
+/.fleet
26
+/.idea
27
+/.nova
28
+/.vscode
29
+/.zed
30
+/.agents
31
+/.amp
32
+/.claude
33
+/.codex
34
+/.cursor
35
+/.factory
36
+/.grok
37
+/.junie
38
+/.kiro
39
+/.pi
40
+/.mcp.json
41
+/AGENTS.md
42
+/boost.json
43
+/opencode.json
44
+/opencode.jsonc

+ 1
- 0
.npmrc Näytä tiedosto

@@ -0,0 +1 @@
1
+ignore-scripts=true

+ 17
- 0
CLAUDE.md Näytä tiedosto

@@ -0,0 +1,17 @@
1
+# AI Commerce
2
+
3
+AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
4
+
5
+## Start of every session
6
+
7
+Read `PROGRESS.md` first. It holds the plan, the decisions, the current step and the next action.
8
+
9
+## During and after work
10
+
11
+- When a task in `PROGRESS.md` is finished, tick it and update "Current step" and "Next action".
12
+- When a decision is made or changed, record it in section 2 of `PROGRESS.md`.
13
+- At the end of a session, add one line to the session log in `PROGRESS.md`.
14
+
15
+## How to talk to the user
16
+
17
+Keep replies simple and easy to understand. Plain words, short sections, explain technical terms.

+ 239
- 0
PROGRESS.md Näytä tiedosto

@@ -0,0 +1,239 @@
1
+# AI Commerce — Progress Tracker
2
+
3
+This file is the single source of truth for the project plan and status.
4
+Update it at the end of every work session.
5
+
6
+**Last updated:** 2026-11-14
7
+**Current step:** Step 3 — AI generation
8
+**Next action:** Build the swappable AI layer, then generate a store plan with Claude Sonnet 5.5 (needs an Anthropic API key)
9
+
10
+Status marks: `[ ]` not started · `[~]` in progress · `[x]` done
11
+
12
+---
13
+
14
+## 1. What we are building
15
+
16
+An AI store generator for ecommerce only, similar to amboras.com.
17
+A customer describes their brand, and the AI builds a complete online store.
18
+
19
+| Topic            | Decision                                   |
20
+| ---------------- | ------------------------------------------ |
21
+| Customers        | First-time founders and existing merchants |
22
+| Market           | Malaysia first                             |
23
+| Team             | Solo, as a business                        |
24
+| Where we develop | Local machine first, no hosting yet        |
25
+
26
+## 2. Decisions
27
+
28
+### Confirmed
29
+
30
+| Topic                         | Decision                                                       |
31
+| ----------------------------- | -------------------------------------------------------------- |
32
+| Backend                       | Laravel 13 on PHP 8.3 / 8.4                                    |
33
+| Frontend                      | React + TypeScript                                             |
34
+| Payments                      | Stripe Malaysia                                                |
35
+| AI for first store generation | Claude Sonnet 5.5 (`claude-sonnet-5-5`)                        |
36
+| Pricing rule                  | Each plan has a limited number of full regenerations per month |
37
+| Template reuse                | Later improvement (see section 6)                              |
38
+
39
+### Confirmed on 2026-11-14 (previously proposed)
40
+
41
+| Topic                 | Decision                                                              |
42
+| --------------------- | --------------------------------------------------------------------- |
43
+| Laravel + React link  | Inertia.js (official Laravel React starter kit)                       |
44
+| Styling               | Tailwind + shadcn/ui                                                  |
45
+| Database              | MySQL (already installed), one database, `store_id` on every table    |
46
+| Background jobs       | Laravel queues (database driver first, Redis later)                   |
47
+| Commerce backend      | Our own: products, cart, orders, checkout. Not built on Shopify       |
48
+| How AI builds a store | AI picks and fills pre-built React sections. It never writes raw code |
49
+| Store data            | Saved as a "store plan"; later edits change small parts of it         |
50
+| AI for small edits    | DeepSeek, called directly from Laravel (not through Hermes)           |
51
+| AI design             | One swappable AI layer, so each task can use a different model        |
52
+| Shipping              | EasyParcel                                                            |
53
+| Languages             | Bahasa Malaysia and English                                           |
54
+| WhatsApp              | Order notifications and chat button                                   |
55
+
56
+### Rule: the AI model must be easy to change
57
+
58
+Changing from Claude to another AI model (or back) must be a settings change, not a code rewrite.
59
+
60
+- All AI calls go through one place in the code (the "AI layer"). No other code talks to an AI provider directly.
61
+- Each provider (Claude, DeepSeek, others later) is one small "driver" class behind the same interface.
62
+- Each task has its own setting in `.env`: which provider and which model. Example:
63
+    - `AI_GENERATE_PROVIDER=claude`, `AI_GENERATE_MODEL=claude-sonnet-5-5`
64
+    - `AI_EDIT_PROVIDER=deepseek`, `AI_EDIT_MODEL=deepseek-chat`
65
+- Prompts and the store plan format are ours and do not depend on any provider.
66
+- Every AI result is checked against the store plan format, so a weaker model cannot break a store.
67
+- To add a new provider: write one driver class, add its API key, change the setting.
68
+
69
+### How the store plan works (added in Step 2)
70
+
71
+- A store plan is saved in the `plan` column of the `stores` table as JSON: a theme (8 colours, heading font, body font, corner radius) and an ordered list of sections.
72
+- Each section has an `id`, a `type`, a `variant` (layout) and `content` (the text).
73
+- `PlanSchema.php` is the one place that says what is allowed. `PlanValidator` checks every plan before saving and removes anything unknown. Links can only point inside the page, inside the site, or to `https`, `mailto` and `tel` addresses.
74
+- To add a new section type: add it to `PlanSchema.php` and `types.ts`, write one React component, add one line in `renderer.tsx`.
75
+- The storefront uses its own colours through `--sf-*` CSS variables, so it never mixes with the dashboard theme.
76
+
77
+### Plan prices and limits (starting numbers, adjust after real usage)
78
+
79
+| Plan                 | Price / month | Stores | Full regenerations / month | AI edits / month |
80
+| -------------------- | ------------- | ------ | -------------------------- | ---------------- |
81
+| Free trial (14 days) | RM0           | 1      | 2 in total                 | 30 in total      |
82
+| Starter              | RM39          | 1      | 3                          | 100              |
83
+| Growth               | RM99          | 3      | 10                         | 500              |
84
+| Pro                  | RM249         | 10     | 30                         | 2,000            |
85
+
86
+---
87
+
88
+## 3. Plan, step by step
89
+
90
+### Step 0 — Prepare the local machine
91
+
92
+- [x] Check installed tools (see section 4)
93
+- [x] Install PHP 8.4 (8.4.27, via Homebrew; default `php` is still 8.2)
94
+- [x] Create a MySQL database for the project (`ai_commerce`)
95
+- [x] Set up git in this folder (branch `main`, nothing committed yet)
96
+
97
+### Step 1 — Project foundation
98
+
99
+- [x] Create Laravel 13 project with the React + TypeScript starter kit (Laravel 13.42, Inertia 3, React 19)
100
+- [x] Confirm the app runs locally
101
+- [x] Register, login, logout (from the starter kit, with email verification and two-factor login; passkeys left out)
102
+- [x] "Create a store" flow (name, category, language, description)
103
+- [x] Dashboard that lists the user's stores
104
+- [x] Users only see their own stores (other people's stores give "not found")
105
+- [ ] Ongoing rule: every new store-related table gets `store_id` (applies from Step 2 on)
106
+
107
+### Step 2 — Store sections and renderer
108
+
109
+- [x] Define the "store plan" format (colours, fonts, corner radius, sections, text) and a validator that every plan must pass
110
+- [x] Build 10 React sections, each with 2 layout variants: header, hero, product grid, featured product, about, testimonials, FAQ, newsletter, contact, footer
111
+- [x] Renderer that turns a store plan into a storefront page
112
+- [x] Preview a store inside the dashboard (desktop and mobile size, plus open as full page)
113
+- [x] One hand-written sample plan to prove the renderer works ("Apply sample design" button; temporary until Step 3)
114
+- [ ] Known gaps, to do later: mobile menu for header links; real images (placeholders for now); newsletter form does not save
115
+
116
+### Step 3 — AI generation
117
+
118
+- [ ] Swappable AI layer: one interface, one driver per provider, provider and model chosen per task in `.env`
119
+- [ ] Test: switch the generation model in `.env` and confirm it works with no code change
120
+- [ ] Claude Sonnet 5.5 for first store generation
121
+- [ ] DeepSeek for small edits
122
+- [ ] Run generation as a background job with a progress screen
123
+- [ ] Check the AI result is a valid store plan before saving
124
+- [ ] Edit by chat ("make the banner darker")
125
+- [ ] Count and limit regenerations and edits per plan
126
+
127
+### Step 4 — Commerce
128
+
129
+- [ ] Products: create, edit, images, price, stock
130
+- [ ] Product page and collection page
131
+- [ ] Cart
132
+- [ ] Checkout with Stripe Malaysia (test mode)
133
+- [ ] Orders list for the merchant
134
+- [ ] Order confirmation email
135
+
136
+### Step 5 — Publishing
137
+
138
+- [ ] Publish a store to a subdomain (local: `storename.localhost`)
139
+- [ ] Custom domains (after hosting is chosen)
140
+
141
+### Step 6 — Our own subscription billing
142
+
143
+- [ ] Plans table matching the price table above
144
+- [ ] Subscribe, upgrade, cancel through Stripe
145
+- [ ] Free trial of 14 days
146
+- [ ] Enforce plan limits (stores, regenerations, edits)
147
+
148
+### Step 7 — Malaysia features
149
+
150
+- [ ] FPX, DuitNow QR and e-wallets at checkout
151
+- [ ] EasyParcel shipping rates and labels
152
+- [ ] Bahasa Malaysia and English store generation
153
+- [ ] WhatsApp order notifications and chat button
154
+
155
+### Step 8 — Before launch
156
+
157
+- [ ] Choose hosting and deploy
158
+- [ ] Privacy policy and terms of service (name the AI providers)
159
+- [ ] Backup AI provider in case one is down
160
+- [ ] Spending caps on every AI account
161
+
162
+---
163
+
164
+## 4. Local machine (checked 2026-11-14)
165
+
166
+| Tool       | Status                                                                                                              |
167
+| ---------- | ------------------------------------------------------------------------------------------------------------------- |
168
+| PHP        | 8.4.27 at `/opt/homebrew/opt/php@8.4/bin/php` (used by this project). Default `php` is 8.2.30; 8.5.5 also installed |
169
+| Composer   | 2.9.7                                                                                                               |
170
+| Node / npm | 24.14.1 / 11.11.0                                                                                                   |
171
+| MySQL      | 9.6.0                                                                                                               |
172
+| PostgreSQL | Not installed (not needed, using MySQL)                                                                             |
173
+| Redis      | Not installed (not needed yet)                                                                                      |
174
+
175
+## 4a. How to run the app locally
176
+
177
+This project needs PHP 8.4, which is not the default `php` on this machine. In each new terminal, run this first:
178
+
179
+```bash
180
+export PATH="/opt/homebrew/opt/php@8.4/bin:$PATH"
181
+```
182
+
183
+Then, from the project folder:
184
+
185
+| Task                                | Command                                    |
186
+| ----------------------------------- | ------------------------------------------ |
187
+| Start the app (server, queue, Vite) | `composer run dev`                         |
188
+| Open the app                        | http://localhost:8000                      |
189
+| Run all tests                       | `php artisan test`                         |
190
+| Check PHP style and types           | `composer lint` and `composer types:check` |
191
+| Check frontend                      | `npm run check` and `npm run types:check`  |
192
+| Rebuild frontend for tests          | `npm run build`                            |
193
+
194
+- Database: MySQL, database `ai_commerce`, settings in `.env`.
195
+- Local test login: created by `php artisan db:seed`. Email is in `database/seeders/DatabaseSeeder.php`, password in `database/factories/UserFactory.php`.
196
+- Emails (such as verification links) are written to `storage/logs/laravel.log`, not sent.
197
+
198
+## 4b. Where things are in the code
199
+
200
+| Thing                                 | Location                                                                    |
201
+| ------------------------------------- | --------------------------------------------------------------------------- |
202
+| Store model                           | `app/Models/Store.php`                                                      |
203
+| Store screens logic                   | `app/Http/Controllers/StoreController.php`                                  |
204
+| Store categories, languages, statuses | `app/Enums/`                                                                |
205
+| Store form rules                      | `app/Http/Requests/Stores/CreateStoreRequest.php`                           |
206
+| Screens                               | `resources/js/pages/dashboard.tsx`, `resources/js/pages/stores/`            |
207
+| Store tests                           | `tests/Feature/Stores/`                                                     |
208
+| Store plan format (the rules)         | `app/StorePlan/PlanSchema.php`                                              |
209
+| Store plan checker                    | `app/StorePlan/PlanValidator.php`                                           |
210
+| Sample plan                           | `app/StorePlan/SamplePlan.php`                                              |
211
+| Preview and sample design logic       | `app/Http/Controllers/StoreDesignController.php`                            |
212
+| Store plan format (frontend types)    | `resources/js/storefront/types.ts`                                          |
213
+| Storefront renderer and sections      | `resources/js/storefront/renderer.tsx`, `resources/js/storefront/sections/` |
214
+
215
+## 5. Open questions
216
+
217
+- When to make the first git commit (all work so far is uncommitted, on branch `feature/store-sections-renderer`)
218
+- Anthropic API key and DeepSeek API key for Step 3
219
+- Hosting provider (decide at Step 8)
220
+
221
+## 6. Later improvements
222
+
223
+- **Template library:** save the design skeleton of good generated stores (colours, fonts, section order, style labels, never customer content). Match new customers to a skeleton and let the cheap model personalise it, so the expensive model is skipped. Start the library by generating 30–50 designs ourselves.
224
+- Show three matched designs for the customer to choose from.
225
+- Import products from Shopee, TikTok Shop, Shopify.
226
+- LHDN e-invoicing.
227
+- AI product photography, email flows, SEO tools.
228
+
229
+---
230
+
231
+## 7. Session log
232
+
233
+Add one line per work session: date, what was done, what is next.
234
+
235
+| Date       | Done                                                                                                                                                                                                                                            | Next                                                            |
236
+| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
237
+| 2026-11-14 | Planning. Chose stack, market, payments, AI models, plan prices. Checked local tools. Created this file. All proposed decisions confirmed. Added the rule that the AI model must be easy to change.                                             | Install PHP 8.4, create the Laravel project (Step 0 and Step 1) |
238
+| 2026-11-14 | Installed PHP 8.4. Created the Laravel 13 + React project, MySQL database and git repo. Built create-a-store flow and dashboard. 51 tests pass; login and store creation checked in the browser. Step 0 and Step 1 done.                        | Step 2: store plan format, sections, renderer                   |
239
+| 2026-11-14 | Step 2 done on branch `feature/store-sections-renderer`: store plan format and validator, 10 sections with 2 variants each, renderer, dashboard preview, sample design. 69 tests pass; storefront checked in the browser on desktop and mobile. | Step 3: swappable AI layer and store generation                 |

+ 33
- 0
app/Actions/Fortify/CreateNewUser.php Näytä tiedosto

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+namespace App\Actions\Fortify;
4
+
5
+use App\Concerns\PasswordValidationRules;
6
+use App\Concerns\ProfileValidationRules;
7
+use App\Models\User;
8
+use Illuminate\Support\Facades\Validator;
9
+use Laravel\Fortify\Contracts\CreatesNewUsers;
10
+
11
+class CreateNewUser implements CreatesNewUsers
12
+{
13
+    use PasswordValidationRules, ProfileValidationRules;
14
+
15
+    /**
16
+     * Validate and create a newly registered user.
17
+     *
18
+     * @param  array<string, string>  $input
19
+     */
20
+    public function create(array $input): User
21
+    {
22
+        Validator::make($input, [
23
+            ...$this->profileRules(),
24
+            'password' => $this->passwordRules(),
25
+        ])->validate();
26
+
27
+        return User::create([
28
+            'name' => $input['name'],
29
+            'email' => $input['email'],
30
+            'password' => $input['password'],
31
+        ]);
32
+    }
33
+}

+ 29
- 0
app/Actions/Fortify/ResetUserPassword.php Näytä tiedosto

@@ -0,0 +1,29 @@
1
+<?php
2
+
3
+namespace App\Actions\Fortify;
4
+
5
+use App\Concerns\PasswordValidationRules;
6
+use App\Models\User;
7
+use Illuminate\Support\Facades\Validator;
8
+use Laravel\Fortify\Contracts\ResetsUserPasswords;
9
+
10
+class ResetUserPassword implements ResetsUserPasswords
11
+{
12
+    use PasswordValidationRules;
13
+
14
+    /**
15
+     * Validate and reset the user's forgotten password.
16
+     *
17
+     * @param  array<string, string>  $input
18
+     */
19
+    public function reset(User $user, array $input): void
20
+    {
21
+        Validator::make($input, [
22
+            'password' => $this->passwordRules(),
23
+        ])->validate();
24
+
25
+        $user->forceFill([
26
+            'password' => $input['password'],
27
+        ])->save();
28
+    }
29
+}

+ 29
- 0
app/Concerns/PasswordValidationRules.php Näytä tiedosto

@@ -0,0 +1,29 @@
1
+<?php
2
+
3
+namespace App\Concerns;
4
+
5
+use Illuminate\Contracts\Validation\ValidationRule;
6
+use Illuminate\Validation\Rules\Password;
7
+
8
+trait PasswordValidationRules
9
+{
10
+    /**
11
+     * Get the validation rules used to validate passwords.
12
+     *
13
+     * @return array<int, Password|ValidationRule|array<mixed>|string>
14
+     */
15
+    protected function passwordRules(): array
16
+    {
17
+        return ['required', 'string', Password::default(), 'confirmed'];
18
+    }
19
+
20
+    /**
21
+     * Get the validation rules used to validate the current password.
22
+     *
23
+     * @return array<int, Password|ValidationRule|array<mixed>|string>
24
+     */
25
+    protected function currentPasswordRules(): array
26
+    {
27
+        return ['required', 'string', 'current_password'];
28
+    }
29
+}

+ 52
- 0
app/Concerns/ProfileValidationRules.php Näytä tiedosto

@@ -0,0 +1,52 @@
1
+<?php
2
+
3
+namespace App\Concerns;
4
+
5
+use App\Models\User;
6
+use Illuminate\Contracts\Validation\ValidationRule;
7
+use Illuminate\Validation\Rule;
8
+use Illuminate\Validation\Rules\Unique;
9
+
10
+trait ProfileValidationRules
11
+{
12
+    /**
13
+     * Get the validation rules used to validate user profiles.
14
+     *
15
+     * @return array<string, array<int, Unique|ValidationRule|array<mixed>|string>>
16
+     */
17
+    protected function profileRules(?int $userId = null): array
18
+    {
19
+        return [
20
+            'name' => $this->nameRules(),
21
+            'email' => $this->emailRules($userId),
22
+        ];
23
+    }
24
+
25
+    /**
26
+     * Get the validation rules used to validate user names.
27
+     *
28
+     * @return array<int, Unique|ValidationRule|array<mixed>|string>
29
+     */
30
+    protected function nameRules(): array
31
+    {
32
+        return ['required', 'string', 'max:255'];
33
+    }
34
+
35
+    /**
36
+     * Get the validation rules used to validate user emails.
37
+     *
38
+     * @return array<int, Unique|ValidationRule|array<mixed>|string>
39
+     */
40
+    protected function emailRules(?int $userId = null): array
41
+    {
42
+        return [
43
+            'required',
44
+            'string',
45
+            'email',
46
+            'max:255',
47
+            $userId === null
48
+                ? Rule::unique(User::class)
49
+                : Rule::unique(User::class)->ignore($userId),
50
+        ];
51
+    }
52
+}

+ 44
- 0
app/Enums/StoreCategory.php Näytä tiedosto

@@ -0,0 +1,44 @@
1
+<?php
2
+
3
+namespace App\Enums;
4
+
5
+enum StoreCategory: string
6
+{
7
+    case Fashion = 'fashion';
8
+    case Beauty = 'beauty';
9
+    case Food = 'food';
10
+    case Home = 'home';
11
+    case Electronics = 'electronics';
12
+    case Health = 'health';
13
+    case Kids = 'kids';
14
+    case Digital = 'digital';
15
+    case Other = 'other';
16
+
17
+    public function label(): string
18
+    {
19
+        return match ($this) {
20
+            self::Fashion => 'Fashion & apparel',
21
+            self::Beauty => 'Beauty & skincare',
22
+            self::Food => 'Food & beverage',
23
+            self::Home => 'Home & living',
24
+            self::Electronics => 'Electronics & gadgets',
25
+            self::Health => 'Health & wellness',
26
+            self::Kids => 'Baby & kids',
27
+            self::Digital => 'Digital products',
28
+            self::Other => 'Other',
29
+        };
30
+    }
31
+
32
+    /**
33
+     * Options for a select input.
34
+     *
35
+     * @return list<array{value: string, label: string}>
36
+     */
37
+    public static function options(): array
38
+    {
39
+        return array_map(
40
+            fn (self $category) => ['value' => $category->value, 'label' => $category->label()],
41
+            self::cases(),
42
+        );
43
+    }
44
+}

+ 30
- 0
app/Enums/StoreLanguage.php Näytä tiedosto

@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+namespace App\Enums;
4
+
5
+enum StoreLanguage: string
6
+{
7
+    case English = 'en';
8
+    case Malay = 'ms';
9
+
10
+    public function label(): string
11
+    {
12
+        return match ($this) {
13
+            self::English => 'English',
14
+            self::Malay => 'Bahasa Malaysia',
15
+        };
16
+    }
17
+
18
+    /**
19
+     * Options for a select input.
20
+     *
21
+     * @return list<array{value: string, label: string}>
22
+     */
23
+    public static function options(): array
24
+    {
25
+        return array_map(
26
+            fn (self $language) => ['value' => $language->value, 'label' => $language->label()],
27
+            self::cases(),
28
+        );
29
+    }
30
+}

+ 17
- 0
app/Enums/StoreStatus.php Näytä tiedosto

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace App\Enums;
4
+
5
+enum StoreStatus: string
6
+{
7
+    case Draft = 'draft';
8
+    case Published = 'published';
9
+
10
+    public function label(): string
11
+    {
12
+        return match ($this) {
13
+            self::Draft => 'Draft',
14
+            self::Published => 'Published',
15
+        };
16
+    }
17
+}

+ 8
- 0
app/Http/Controllers/Controller.php Näytä tiedosto

@@ -0,0 +1,8 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers;
4
+
5
+abstract class Controller
6
+{
7
+    //
8
+}

+ 62
- 0
app/Http/Controllers/Settings/ProfileController.php Näytä tiedosto

@@ -0,0 +1,62 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Settings;
4
+
5
+use App\Http\Controllers\Controller;
6
+use App\Http\Requests\Settings\ProfileDeleteRequest;
7
+use App\Http\Requests\Settings\ProfileUpdateRequest;
8
+use Illuminate\Contracts\Auth\MustVerifyEmail;
9
+use Illuminate\Http\RedirectResponse;
10
+use Illuminate\Http\Request;
11
+use Illuminate\Support\Facades\Auth;
12
+use Inertia\Inertia;
13
+use Inertia\Response;
14
+
15
+class ProfileController extends Controller
16
+{
17
+    /**
18
+     * Show the user's profile settings page.
19
+     */
20
+    public function edit(Request $request): Response
21
+    {
22
+        return Inertia::render('settings/profile', [
23
+            'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
24
+            'status' => $request->session()->get('status'),
25
+        ]);
26
+    }
27
+
28
+    /**
29
+     * Update the user's profile information.
30
+     */
31
+    public function update(ProfileUpdateRequest $request): RedirectResponse
32
+    {
33
+        $request->user()->fill($request->validated());
34
+
35
+        if ($request->user()->isDirty('email')) {
36
+            $request->user()->email_verified_at = null;
37
+        }
38
+
39
+        $request->user()->save();
40
+
41
+        Inertia::flash('toast', ['type' => 'success', 'message' => __('Profile updated.')]);
42
+
43
+        return to_route('profile.edit');
44
+    }
45
+
46
+    /**
47
+     * Delete the user's profile.
48
+     */
49
+    public function destroy(ProfileDeleteRequest $request): RedirectResponse
50
+    {
51
+        $user = $request->user();
52
+
53
+        Auth::logout();
54
+
55
+        $user->delete();
56
+
57
+        $request->session()->invalidate();
58
+        $request->session()->regenerateToken();
59
+
60
+        return redirect('/');
61
+    }
62
+}

+ 49
- 0
app/Http/Controllers/Settings/SecurityController.php Näytä tiedosto

@@ -0,0 +1,49 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Settings;
4
+
5
+use App\Http\Controllers\Controller;
6
+use App\Http\Requests\Settings\PasswordUpdateRequest;
7
+use App\Http\Requests\Settings\TwoFactorAuthenticationRequest;
8
+use Illuminate\Http\RedirectResponse;
9
+use Illuminate\Validation\Rules\Password;
10
+use Inertia\Inertia;
11
+use Inertia\Response;
12
+use Laravel\Fortify\Features;
13
+
14
+class SecurityController extends Controller
15
+{
16
+    /**
17
+     * Show the user's security settings page.
18
+     */
19
+    public function edit(TwoFactorAuthenticationRequest $request): Response
20
+    {
21
+        $props = [
22
+            'canManageTwoFactor' => Features::canManageTwoFactorAuthentication(),
23
+            'passwordRules' => Password::defaults()->toPasswordRulesString(),
24
+        ];
25
+
26
+        if (Features::canManageTwoFactorAuthentication()) {
27
+            $request->ensureStateIsValid();
28
+
29
+            $props['twoFactorEnabled'] = $request->user()->hasEnabledTwoFactorAuthentication();
30
+            $props['requiresConfirmation'] = Features::optionEnabled(Features::twoFactorAuthentication(), 'confirm');
31
+        }
32
+
33
+        return Inertia::render('settings/security', $props);
34
+    }
35
+
36
+    /**
37
+     * Update the user's password.
38
+     */
39
+    public function update(PasswordUpdateRequest $request): RedirectResponse
40
+    {
41
+        $request->user()->update([
42
+            'password' => $request->password,
43
+        ]);
44
+
45
+        Inertia::flash('toast', ['type' => 'success', 'message' => __('Password updated.')]);
46
+
47
+        return back();
48
+    }
49
+}

+ 87
- 0
app/Http/Controllers/StoreController.php Näytä tiedosto

@@ -0,0 +1,87 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers;
4
+
5
+use App\Enums\StoreCategory;
6
+use App\Enums\StoreLanguage;
7
+use App\Http\Requests\Stores\CreateStoreRequest;
8
+use App\Models\Store;
9
+use Illuminate\Http\RedirectResponse;
10
+use Illuminate\Http\Request;
11
+use Inertia\Inertia;
12
+use Inertia\Response;
13
+
14
+class StoreController extends Controller
15
+{
16
+    /**
17
+     * Show the dashboard with the user's own stores.
18
+     */
19
+    public function index(Request $request): Response
20
+    {
21
+        return Inertia::render('dashboard', [
22
+            'stores' => $request->user()
23
+                ->stores()
24
+                ->latest()
25
+                ->get()
26
+                ->map(fn (Store $store) => $this->present($store)),
27
+        ]);
28
+    }
29
+
30
+    /**
31
+     * Show the "create a store" form.
32
+     */
33
+    public function create(): Response
34
+    {
35
+        return Inertia::render('stores/create', [
36
+            'categories' => StoreCategory::options(),
37
+            'languages' => StoreLanguage::options(),
38
+        ]);
39
+    }
40
+
41
+    /**
42
+     * Save a new store for the current user.
43
+     */
44
+    public function store(CreateStoreRequest $request): RedirectResponse
45
+    {
46
+        $store = $request->user()->stores()->create($request->validated());
47
+
48
+        Inertia::flash('toast', ['type' => 'success', 'message' => __('Store created.')]);
49
+
50
+        return to_route('stores.show', $store->slug);
51
+    }
52
+
53
+    /**
54
+     * Show one store. Looking it up through the user means other people's stores give a 404.
55
+     */
56
+    public function show(Request $request, string $slug): Response
57
+    {
58
+        $store = $request->user()->stores()->where('slug', $slug)->firstOrFail();
59
+
60
+        return Inertia::render('stores/show', [
61
+            'store' => $this->present($store),
62
+        ]);
63
+    }
64
+
65
+    /**
66
+     * The store fields the frontend is allowed to see.
67
+     *
68
+     * @return array<string, mixed>
69
+     */
70
+    private function present(Store $store): array
71
+    {
72
+        return [
73
+            'id' => $store->id,
74
+            'name' => $store->name,
75
+            'slug' => $store->slug,
76
+            'category' => $store->category->value,
77
+            'category_label' => $store->category->label(),
78
+            'description' => $store->description,
79
+            'language' => $store->language->value,
80
+            'language_label' => $store->language->label(),
81
+            'status' => $store->status->value,
82
+            'status_label' => $store->status->label(),
83
+            'has_design' => $store->plan !== null,
84
+            'created_at' => $store->created_at?->toIso8601String(),
85
+        ];
86
+    }
87
+}

+ 53
- 0
app/Http/Controllers/StoreDesignController.php Näytä tiedosto

@@ -0,0 +1,53 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers;
4
+
5
+use App\Models\Store;
6
+use App\StorePlan\PlanSchema;
7
+use App\StorePlan\PlanValidator;
8
+use App\StorePlan\SamplePlan;
9
+use Illuminate\Http\RedirectResponse;
10
+use Illuminate\Http\Request;
11
+use Inertia\Inertia;
12
+use Inertia\Response;
13
+
14
+class StoreDesignController extends Controller
15
+{
16
+    /**
17
+     * Show the storefront as a full page, drawn from the store's saved plan.
18
+     */
19
+    public function preview(Request $request, string $slug): Response
20
+    {
21
+        $store = $this->ownedStore($request, $slug);
22
+
23
+        abort_if($store->plan === null, 404);
24
+
25
+        return Inertia::render('stores/preview', [
26
+            'storeName' => $store->name,
27
+            'language' => $store->language->value,
28
+            'plan' => $store->plan,
29
+            'fonts' => PlanSchema::FONTS,
30
+        ]);
31
+    }
32
+
33
+    /**
34
+     * Give the store the hand-written sample design.
35
+     * Temporary: this is replaced by AI generation in Step 3.
36
+     */
37
+    public function applySample(Request $request, PlanValidator $validator, string $slug): RedirectResponse
38
+    {
39
+        $store = $this->ownedStore($request, $slug);
40
+
41
+        $store->plan = $validator->validate(SamplePlan::for($store));
42
+        $store->save();
43
+
44
+        Inertia::flash('toast', ['type' => 'success', 'message' => __('Sample design applied.')]);
45
+
46
+        return to_route('stores.show', $store->slug);
47
+    }
48
+
49
+    private function ownedStore(Request $request, string $slug): Store
50
+    {
51
+        return $request->user()->stores()->where('slug', $slug)->firstOrFail();
52
+    }
53
+}

+ 23
- 0
app/Http/Middleware/HandleAppearance.php Näytä tiedosto

@@ -0,0 +1,23 @@
1
+<?php
2
+
3
+namespace App\Http\Middleware;
4
+
5
+use Closure;
6
+use Illuminate\Http\Request;
7
+use Illuminate\Support\Facades\View;
8
+use Symfony\Component\HttpFoundation\Response;
9
+
10
+class HandleAppearance
11
+{
12
+    /**
13
+     * Handle an incoming request.
14
+     *
15
+     * @param  Closure(Request): (Response)  $next
16
+     */
17
+    public function handle(Request $request, Closure $next): Response
18
+    {
19
+        View::share('appearance', $request->cookie('appearance') ?? 'system');
20
+
21
+        return $next($request);
22
+    }
23
+}

+ 47
- 0
app/Http/Middleware/HandleInertiaRequests.php Näytä tiedosto

@@ -0,0 +1,47 @@
1
+<?php
2
+
3
+namespace App\Http\Middleware;
4
+
5
+use Illuminate\Http\Request;
6
+use Inertia\Middleware;
7
+
8
+class HandleInertiaRequests extends Middleware
9
+{
10
+    /**
11
+     * The root template that's loaded on the first page visit.
12
+     *
13
+     * @see https://inertiajs.com/server-side-setup#root-template
14
+     *
15
+     * @var string
16
+     */
17
+    protected $rootView = 'app';
18
+
19
+    /**
20
+     * Determines the current asset version.
21
+     *
22
+     * @see https://inertiajs.com/asset-versioning
23
+     */
24
+    public function version(Request $request): ?string
25
+    {
26
+        return parent::version($request);
27
+    }
28
+
29
+    /**
30
+     * Define the props that are shared by default.
31
+     *
32
+     * @see https://inertiajs.com/shared-data
33
+     *
34
+     * @return array<string, mixed>
35
+     */
36
+    public function share(Request $request): array
37
+    {
38
+        return [
39
+            ...parent::share($request),
40
+            'name' => config('app.name'),
41
+            'auth' => [
42
+                'user' => $request->user(),
43
+            ],
44
+            'sidebarOpen' => ! $request->hasCookie('sidebar_state') || $request->cookie('sidebar_state') === 'true',
45
+        ];
46
+    }
47
+}

+ 25
- 0
app/Http/Requests/Settings/PasswordUpdateRequest.php Näytä tiedosto

@@ -0,0 +1,25 @@
1
+<?php
2
+
3
+namespace App\Http\Requests\Settings;
4
+
5
+use App\Concerns\PasswordValidationRules;
6
+use Illuminate\Contracts\Validation\ValidationRule;
7
+use Illuminate\Foundation\Http\FormRequest;
8
+
9
+class PasswordUpdateRequest extends FormRequest
10
+{
11
+    use PasswordValidationRules;
12
+
13
+    /**
14
+     * Get the validation rules that apply to the request.
15
+     *
16
+     * @return array<string, ValidationRule|array<mixed>|string>
17
+     */
18
+    public function rules(): array
19
+    {
20
+        return [
21
+            'current_password' => $this->currentPasswordRules(),
22
+            'password' => $this->passwordRules(),
23
+        ];
24
+    }
25
+}

+ 24
- 0
app/Http/Requests/Settings/ProfileDeleteRequest.php Näytä tiedosto

@@ -0,0 +1,24 @@
1
+<?php
2
+
3
+namespace App\Http\Requests\Settings;
4
+
5
+use App\Concerns\PasswordValidationRules;
6
+use Illuminate\Contracts\Validation\ValidationRule;
7
+use Illuminate\Foundation\Http\FormRequest;
8
+
9
+class ProfileDeleteRequest extends FormRequest
10
+{
11
+    use PasswordValidationRules;
12
+
13
+    /**
14
+     * Get the validation rules that apply to the request.
15
+     *
16
+     * @return array<string, ValidationRule|array<mixed>|string>
17
+     */
18
+    public function rules(): array
19
+    {
20
+        return [
21
+            'password' => $this->currentPasswordRules(),
22
+        ];
23
+    }
24
+}

+ 33
- 0
app/Http/Requests/Settings/ProfileUpdateRequest.php Näytä tiedosto

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+namespace App\Http\Requests\Settings;
4
+
5
+use App\Concerns\ProfileValidationRules;
6
+use Illuminate\Contracts\Validation\ValidationRule;
7
+use Illuminate\Foundation\Http\FormRequest;
8
+use Illuminate\Support\Str;
9
+
10
+class ProfileUpdateRequest extends FormRequest
11
+{
12
+    use ProfileValidationRules;
13
+
14
+    /**
15
+     * Prepare the data for validation.
16
+     */
17
+    protected function prepareForValidation(): void
18
+    {
19
+        if (config('fortify.lowercase_usernames') && is_string($this->input('email'))) {
20
+            $this->merge(['email' => Str::lower($this->input('email'))]);
21
+        }
22
+    }
23
+
24
+    /**
25
+     * Get the validation rules that apply to the request.
26
+     *
27
+     * @return array<string, ValidationRule|array<mixed>|string>
28
+     */
29
+    public function rules(): array
30
+    {
31
+        return $this->profileRules($this->user()->id);
32
+    }
33
+}

+ 22
- 0
app/Http/Requests/Settings/TwoFactorAuthenticationRequest.php Näytä tiedosto

@@ -0,0 +1,22 @@
1
+<?php
2
+
3
+namespace App\Http\Requests\Settings;
4
+
5
+use Illuminate\Contracts\Validation\ValidationRule;
6
+use Illuminate\Foundation\Http\FormRequest;
7
+use Laravel\Fortify\InteractsWithTwoFactorState;
8
+
9
+class TwoFactorAuthenticationRequest extends FormRequest
10
+{
11
+    use InteractsWithTwoFactorState;
12
+
13
+    /**
14
+     * Get the validation rules that apply to the request.
15
+     *
16
+     * @return array<string, ValidationRule|array<mixed>|string>
17
+     */
18
+    public function rules(): array
19
+    {
20
+        return [];
21
+    }
22
+}

+ 37
- 0
app/Http/Requests/Stores/CreateStoreRequest.php Näytä tiedosto

@@ -0,0 +1,37 @@
1
+<?php
2
+
3
+namespace App\Http\Requests\Stores;
4
+
5
+use App\Enums\StoreCategory;
6
+use App\Enums\StoreLanguage;
7
+use Illuminate\Contracts\Validation\ValidationRule;
8
+use Illuminate\Foundation\Http\FormRequest;
9
+use Illuminate\Validation\Rule;
10
+
11
+class CreateStoreRequest extends FormRequest
12
+{
13
+    /**
14
+     * Get the validation rules that apply to the request.
15
+     *
16
+     * @return array<string, ValidationRule|array<mixed>|string>
17
+     */
18
+    public function rules(): array
19
+    {
20
+        return [
21
+            'name' => ['required', 'string', 'min:2', 'max:60'],
22
+            'category' => ['required', Rule::enum(StoreCategory::class)],
23
+            'description' => ['required', 'string', 'min:20', 'max:1000'],
24
+            'language' => ['required', Rule::enum(StoreLanguage::class)],
25
+        ];
26
+    }
27
+
28
+    /**
29
+     * @return array<string, string>
30
+     */
31
+    public function messages(): array
32
+    {
33
+        return [
34
+            'description.min' => 'Tell us a little more about your brand (at least :min characters).',
35
+        ];
36
+    }
37
+}

+ 106
- 0
app/Models/Store.php Näytä tiedosto

@@ -0,0 +1,106 @@
1
+<?php
2
+
3
+namespace App\Models;
4
+
5
+use App\Enums\StoreCategory;
6
+use App\Enums\StoreLanguage;
7
+use App\Enums\StoreStatus;
8
+use Database\Factories\StoreFactory;
9
+use Illuminate\Database\Eloquent\Attributes\Fillable;
10
+use Illuminate\Database\Eloquent\Factories\HasFactory;
11
+use Illuminate\Database\Eloquent\Model;
12
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
13
+use Illuminate\Support\Carbon;
14
+use Illuminate\Support\Str;
15
+
16
+/**
17
+ * A merchant's online store. Every store-related table points back here with `store_id`.
18
+ *
19
+ * @property int $id
20
+ * @property int $user_id
21
+ * @property string $name
22
+ * @property string $slug
23
+ * @property StoreCategory $category
24
+ * @property string $description
25
+ * @property StoreLanguage $language
26
+ * @property StoreStatus $status
27
+ * @property array<string, mixed>|null $plan
28
+ * @property Carbon|null $created_at
29
+ * @property Carbon|null $updated_at
30
+ */
31
+#[Fillable(['name', 'category', 'description', 'language'])]
32
+class Store extends Model
33
+{
34
+    /** @use HasFactory<StoreFactory> */
35
+    use HasFactory;
36
+
37
+    /**
38
+     * Slugs that can never be used, because they will clash with our own subdomains.
39
+     *
40
+     * @var list<string>
41
+     */
42
+    public const array RESERVED_SLUGS = ['www', 'app', 'api', 'admin', 'dashboard', 'mail', 'store', 'stores', 'create'];
43
+
44
+    /**
45
+     * Default values for new stores.
46
+     *
47
+     * @var array<string, string>
48
+     */
49
+    protected $attributes = [
50
+        'language' => 'en',
51
+        'status' => 'draft',
52
+    ];
53
+
54
+    protected static function booted(): void
55
+    {
56
+        static::creating(function (Store $store) {
57
+            if (blank($store->slug)) {
58
+                $store->slug = static::uniqueSlug($store->name);
59
+            }
60
+        });
61
+    }
62
+
63
+    /**
64
+     * Build a web-safe slug from a store name that no other store is using.
65
+     */
66
+    public static function uniqueSlug(string $name): string
67
+    {
68
+        $base = Str::slug($name) ?: 'store';
69
+        $slug = $base;
70
+        $suffix = 2;
71
+
72
+        while (in_array($slug, self::RESERVED_SLUGS, true) || static::query()->where('slug', $slug)->exists()) {
73
+            $slug = $base.'-'.$suffix++;
74
+        }
75
+
76
+        return $slug;
77
+    }
78
+
79
+    public function getRouteKeyName(): string
80
+    {
81
+        return 'slug';
82
+    }
83
+
84
+    /**
85
+     * @return BelongsTo<User, $this>
86
+     */
87
+    public function user(): BelongsTo
88
+    {
89
+        return $this->belongsTo(User::class);
90
+    }
91
+
92
+    /**
93
+     * Get the attributes that should be cast.
94
+     *
95
+     * @return array<string, string>
96
+     */
97
+    protected function casts(): array
98
+    {
99
+        return [
100
+            'category' => StoreCategory::class,
101
+            'language' => StoreLanguage::class,
102
+            'status' => StoreStatus::class,
103
+            'plan' => 'array',
104
+        ];
105
+    }
106
+}

+ 59
- 0
app/Models/User.php Näytä tiedosto

@@ -0,0 +1,59 @@
1
+<?php
2
+
3
+namespace App\Models;
4
+
5
+use Database\Factories\UserFactory;
6
+use Illuminate\Contracts\Auth\MustVerifyEmail;
7
+use Illuminate\Database\Eloquent\Attributes\Fillable;
8
+use Illuminate\Database\Eloquent\Attributes\Hidden;
9
+use Illuminate\Database\Eloquent\Factories\HasFactory;
10
+use Illuminate\Database\Eloquent\Relations\HasMany;
11
+use Illuminate\Foundation\Auth\User as Authenticatable;
12
+use Illuminate\Notifications\Notifiable;
13
+use Illuminate\Support\Carbon;
14
+use Laravel\Fortify\TwoFactorAuthenticatable;
15
+
16
+/**
17
+ * @property int $id
18
+ * @property string $name
19
+ * @property string $email
20
+ * @property Carbon|null $email_verified_at
21
+ * @property string $password
22
+ * @property string|null $two_factor_secret
23
+ * @property string|null $two_factor_recovery_codes
24
+ * @property Carbon|null $two_factor_confirmed_at
25
+ * @property string|null $remember_token
26
+ * @property Carbon|null $created_at
27
+ * @property Carbon|null $updated_at
28
+ */
29
+#[Fillable(['name', 'email', 'password'])]
30
+#[Hidden(['password', 'two_factor_secret', 'two_factor_recovery_codes', 'remember_token'])]
31
+class User extends Authenticatable implements MustVerifyEmail
32
+{
33
+    /** @use HasFactory<UserFactory> */
34
+    use HasFactory, Notifiable, TwoFactorAuthenticatable;
35
+
36
+    /**
37
+     * Get the attributes that should be cast.
38
+     *
39
+     * @return array<string, string>
40
+     */
41
+    protected function casts(): array
42
+    {
43
+        return [
44
+            'email_verified_at' => 'datetime',
45
+            'password' => 'hashed',
46
+            'two_factor_confirmed_at' => 'datetime',
47
+        ];
48
+    }
49
+
50
+    /**
51
+     * The stores this user owns.
52
+     *
53
+     * @return HasMany<Store, $this>
54
+     */
55
+    public function stores(): HasMany
56
+    {
57
+        return $this->hasMany(Store::class);
58
+    }
59
+}

+ 50
- 0
app/Providers/AppServiceProvider.php Näytä tiedosto

@@ -0,0 +1,50 @@
1
+<?php
2
+
3
+namespace App\Providers;
4
+
5
+use Carbon\CarbonImmutable;
6
+use Illuminate\Support\Facades\Date;
7
+use Illuminate\Support\Facades\DB;
8
+use Illuminate\Support\ServiceProvider;
9
+use Illuminate\Validation\Rules\Password;
10
+
11
+class AppServiceProvider extends ServiceProvider
12
+{
13
+    /**
14
+     * Register any application services.
15
+     */
16
+    public function register(): void
17
+    {
18
+        //
19
+    }
20
+
21
+    /**
22
+     * Bootstrap any application services.
23
+     */
24
+    public function boot(): void
25
+    {
26
+        $this->configureDefaults();
27
+    }
28
+
29
+    /**
30
+     * Configure default behaviors for production-ready applications.
31
+     */
32
+    protected function configureDefaults(): void
33
+    {
34
+        Date::use(CarbonImmutable::class);
35
+
36
+        DB::prohibitDestructiveCommands(
37
+            app()->isProduction(),
38
+        );
39
+
40
+        Password::defaults(fn (): ?Password => app()->isProduction()
41
+            ? Password::min(12)
42
+                ->mixedCase()
43
+                ->letters()
44
+                ->numbers()
45
+                ->symbols()
46
+                ->uncompromised()
47
+            : null,
48
+        );
49
+    }
50
+}

+ 95
- 0
app/Providers/FortifyServiceProvider.php Näytä tiedosto

@@ -0,0 +1,95 @@
1
+<?php
2
+
3
+namespace App\Providers;
4
+
5
+use App\Actions\Fortify\CreateNewUser;
6
+use App\Actions\Fortify\ResetUserPassword;
7
+use Illuminate\Cache\RateLimiting\Limit;
8
+use Illuminate\Http\Request;
9
+use Illuminate\Support\Facades\RateLimiter;
10
+use Illuminate\Support\ServiceProvider;
11
+use Illuminate\Support\Str;
12
+use Illuminate\Validation\Rules\Password;
13
+use Inertia\Inertia;
14
+use Laravel\Fortify\Features;
15
+use Laravel\Fortify\Fortify;
16
+
17
+class FortifyServiceProvider extends ServiceProvider
18
+{
19
+    /**
20
+     * Register any application services.
21
+     */
22
+    public function register(): void
23
+    {
24
+        //
25
+    }
26
+
27
+    /**
28
+     * Bootstrap any application services.
29
+     */
30
+    public function boot(): void
31
+    {
32
+        $this->configureActions();
33
+        $this->configureViews();
34
+        $this->configureRateLimiting();
35
+    }
36
+
37
+    /**
38
+     * Configure Fortify actions.
39
+     */
40
+    private function configureActions(): void
41
+    {
42
+        Fortify::resetUserPasswordsUsing(ResetUserPassword::class);
43
+        Fortify::createUsersUsing(CreateNewUser::class);
44
+    }
45
+
46
+    /**
47
+     * Configure Fortify views.
48
+     */
49
+    private function configureViews(): void
50
+    {
51
+        Fortify::loginView(fn (Request $request) => Inertia::render('auth/login', [
52
+            'canResetPassword' => Features::enabled(Features::resetPasswords()),
53
+            'status' => $request->session()->get('status'),
54
+        ]));
55
+
56
+        Fortify::resetPasswordView(fn (Request $request) => Inertia::render('auth/reset-password', [
57
+            'email' => $request->email,
58
+            'token' => $request->route('token'),
59
+            'passwordRules' => Password::defaults()->toPasswordRulesString(),
60
+        ]));
61
+
62
+        Fortify::requestPasswordResetLinkView(fn (Request $request) => Inertia::render('auth/forgot-password', [
63
+            'status' => $request->session()->get('status'),
64
+        ]));
65
+
66
+        Fortify::verifyEmailView(fn (Request $request) => Inertia::render('auth/verify-email', [
67
+            'status' => $request->session()->get('status'),
68
+        ]));
69
+
70
+        Fortify::registerView(fn () => Inertia::render('auth/register', [
71
+            'passwordRules' => Password::defaults()->toPasswordRulesString(),
72
+        ]));
73
+
74
+        Fortify::twoFactorChallengeView(fn () => Inertia::render('auth/two-factor-challenge'));
75
+
76
+        Fortify::confirmPasswordView(fn () => Inertia::render('auth/confirm-password'));
77
+    }
78
+
79
+    /**
80
+     * Configure rate limiting.
81
+     */
82
+    private function configureRateLimiting(): void
83
+    {
84
+        RateLimiter::for('two-factor', function (Request $request) {
85
+            return Limit::perMinute(5)->by($request->session()->get('login.id'));
86
+        });
87
+
88
+        RateLimiter::for('login', function (Request $request) {
89
+            $throttleKey = Str::transliterate(Str::lower($request->input(Fortify::username())).'|'.$request->ip());
90
+
91
+            return Limit::perMinute(5)->by($throttleKey);
92
+        });
93
+
94
+    }
95
+}

+ 183
- 0
app/StorePlan/PlanSchema.php Näytä tiedosto

@@ -0,0 +1,183 @@
1
+<?php
2
+
3
+namespace App\StorePlan;
4
+
5
+/**
6
+ * The single definition of what a "store plan" may contain.
7
+ *
8
+ * A store plan is the saved design of a store: a theme plus an ordered list of sections.
9
+ * It belongs to us, not to any AI provider. Whoever writes a plan (a person, Claude,
10
+ * DeepSeek, anything later) must produce this shape, and PlanValidator checks it.
11
+ *
12
+ * Keep this file in step with resources/js/storefront/types.ts.
13
+ */
14
+final class PlanSchema
15
+{
16
+    public const int VERSION = 1;
17
+
18
+    /**
19
+     * Theme colours every plan must define, as 6-digit hex values.
20
+     *
21
+     * @var list<string>
22
+     */
23
+    public const array COLORS = [
24
+        'background',
25
+        'surface',
26
+        'foreground',
27
+        'muted',
28
+        'primary',
29
+        'primaryForeground',
30
+        'accent',
31
+        'border',
32
+    ];
33
+
34
+    /**
35
+     * Fonts the storefront can load. Key is what the plan stores, value is the font family name.
36
+     *
37
+     * @var array<string, string>
38
+     */
39
+    public const array FONTS = [
40
+        'inter' => 'Inter',
41
+        'dm-sans' => 'DM Sans',
42
+        'poppins' => 'Poppins',
43
+        'manrope' => 'Manrope',
44
+        'space-grotesk' => 'Space Grotesk',
45
+        'playfair-display' => 'Playfair Display',
46
+        'lora' => 'Lora',
47
+        'fraunces' => 'Fraunces',
48
+    ];
49
+
50
+    /**
51
+     * How rounded corners are.
52
+     *
53
+     * @var list<string>
54
+     */
55
+    public const array RADII = ['none', 'small', 'medium', 'large', 'full'];
56
+
57
+    /**
58
+     * Section types and the layout variants each one supports.
59
+     *
60
+     * @var array<string, list<string>>
61
+     */
62
+    public const array SECTIONS = [
63
+        'header' => ['simple', 'centered'],
64
+        'hero' => ['centered', 'split'],
65
+        'product_grid' => ['grid', 'minimal'],
66
+        'featured_product' => ['image-left', 'image-right'],
67
+        'about' => ['simple', 'with-stats'],
68
+        'testimonials' => ['cards', 'single'],
69
+        'faq' => ['list', 'two-column'],
70
+        'newsletter' => ['banner', 'card'],
71
+        'contact' => ['simple', 'card'],
72
+        'footer' => ['simple', 'centered'],
73
+    ];
74
+
75
+    public const int MAX_SECTIONS = 20;
76
+
77
+    /**
78
+     * Links may only point inside the page, inside the site, or to safe outside targets.
79
+     * This blocks things like "javascript:" links.
80
+     */
81
+    public const string LINK_PATTERN = '/^(#[A-Za-z0-9_-]*|\/(?!\/)[^\s]*|https:\/\/[^\s]+|mailto:[^\s]+|tel:[0-9+\-\s]+)$/';
82
+
83
+    public const string COLOR_PATTERN = '/^#[0-9A-Fa-f]{6}$/';
84
+
85
+    public const string SECTION_ID_PATTERN = '/^[a-z][a-z0-9-]{0,39}$/';
86
+
87
+    /**
88
+     * Validation rules for the content of one section type.
89
+     * Keys are relative to the section's "content" object.
90
+     *
91
+     * @return array<string, list<string>>
92
+     */
93
+    public static function contentRules(string $type): array
94
+    {
95
+        $text = fn (int $max) => ['required', 'string', 'max:'.$max];
96
+        $optionalText = fn (int $max) => ['nullable', 'string', 'max:'.$max];
97
+        $link = ['required', 'string', 'max:300', 'regex:'.self::LINK_PATTERN];
98
+        $price = ['required', 'numeric', 'min:0', 'max:999999'];
99
+
100
+        return match ($type) {
101
+            'header' => [
102
+                'logoText' => $text(40),
103
+                'links' => ['present', 'array', 'max:6'],
104
+                'links.*.label' => $text(30),
105
+                'links.*.href' => $link,
106
+                'cta' => ['nullable', 'array'],
107
+                'cta.label' => ['required_with:cta', 'string', 'max:30'],
108
+                'cta.href' => ['required_with:cta', 'string', 'max:300', 'regex:'.self::LINK_PATTERN],
109
+            ],
110
+            'hero' => [
111
+                'eyebrow' => $optionalText(60),
112
+                'headline' => $text(120),
113
+                'subheadline' => $text(300),
114
+                'primaryCta' => ['required', 'array'],
115
+                'primaryCta.label' => $text(30),
116
+                'primaryCta.href' => $link,
117
+                'secondaryCta' => ['nullable', 'array'],
118
+                'secondaryCta.label' => ['required_with:secondaryCta', 'string', 'max:30'],
119
+                'secondaryCta.href' => ['required_with:secondaryCta', 'string', 'max:300', 'regex:'.self::LINK_PATTERN],
120
+            ],
121
+            'product_grid' => [
122
+                'heading' => $text(80),
123
+                'subheading' => $optionalText(200),
124
+                'items' => ['required', 'array', 'min:2', 'max:8'],
125
+                'items.*.name' => $text(80),
126
+                'items.*.price' => $price,
127
+                'items.*.badge' => $optionalText(20),
128
+            ],
129
+            'featured_product' => [
130
+                'eyebrow' => $optionalText(60),
131
+                'name' => $text(80),
132
+                'description' => $text(500),
133
+                'price' => $price,
134
+                'bullets' => ['present', 'array', 'max:5'],
135
+                'bullets.*' => $text(100),
136
+                'cta' => ['required', 'array'],
137
+                'cta.label' => $text(30),
138
+                'cta.href' => $link,
139
+            ],
140
+            'about' => [
141
+                'heading' => $text(80),
142
+                'body' => $text(1200),
143
+                'stats' => ['present', 'array', 'max:4'],
144
+                'stats.*.value' => $text(12),
145
+                'stats.*.label' => $text(40),
146
+            ],
147
+            'testimonials' => [
148
+                'heading' => $text(80),
149
+                'items' => ['required', 'array', 'min:1', 'max:6'],
150
+                'items.*.quote' => $text(400),
151
+                'items.*.name' => $text(60),
152
+                'items.*.role' => $optionalText(60),
153
+            ],
154
+            'faq' => [
155
+                'heading' => $text(80),
156
+                'items' => ['required', 'array', 'min:1', 'max:10'],
157
+                'items.*.question' => $text(160),
158
+                'items.*.answer' => $text(600),
159
+            ],
160
+            'newsletter' => [
161
+                'heading' => $text(80),
162
+                'body' => $optionalText(240),
163
+                'placeholder' => $text(40),
164
+                'buttonLabel' => $text(30),
165
+            ],
166
+            'contact' => [
167
+                'heading' => $text(80),
168
+                'body' => $optionalText(300),
169
+                'email' => ['nullable', 'email', 'max:120'],
170
+                'phone' => $optionalText(30),
171
+                'whatsapp' => ['nullable', 'string', 'regex:/^[0-9]{8,15}$/'],
172
+                'address' => $optionalText(200),
173
+            ],
174
+            'footer' => [
175
+                'text' => $text(160),
176
+                'links' => ['present', 'array', 'max:8'],
177
+                'links.*.label' => $text(30),
178
+                'links.*.href' => $link,
179
+            ],
180
+            default => [],
181
+        };
182
+    }
183
+}

+ 106
- 0
app/StorePlan/PlanValidator.php Näytä tiedosto

@@ -0,0 +1,106 @@
1
+<?php
2
+
3
+namespace App\StorePlan;
4
+
5
+use Illuminate\Support\Facades\Validator;
6
+use Illuminate\Validation\Rule;
7
+use Illuminate\Validation\ValidationException;
8
+
9
+/**
10
+ * Checks that a store plan follows PlanSchema, and strips anything the schema does not know.
11
+ *
12
+ * Every plan passes through here before it is saved, no matter who wrote it.
13
+ * This is what stops a weak or misbehaving AI model from breaking a store.
14
+ */
15
+final class PlanValidator
16
+{
17
+    /**
18
+     * Return the cleaned plan, or throw if it is not valid.
19
+     *
20
+     * @param  array<mixed>  $plan
21
+     * @return array<string, mixed>
22
+     *
23
+     * @throws ValidationException
24
+     */
25
+    public function validate(array $plan): array
26
+    {
27
+        $rules = [
28
+            'version' => ['required', 'integer', Rule::in([PlanSchema::VERSION])],
29
+            'theme' => ['required', 'array'],
30
+            'theme.colors' => ['required', 'array'],
31
+            'theme.fonts' => ['required', 'array'],
32
+            'theme.fonts.heading' => ['required', Rule::in(array_keys(PlanSchema::FONTS))],
33
+            'theme.fonts.body' => ['required', Rule::in(array_keys(PlanSchema::FONTS))],
34
+            'theme.radius' => ['required', Rule::in(PlanSchema::RADII)],
35
+            'sections' => ['required', 'array', 'min:1', 'max:'.PlanSchema::MAX_SECTIONS],
36
+            'sections.*' => ['required', 'array'],
37
+            'sections.*.id' => ['required', 'string', 'distinct', 'regex:'.PlanSchema::SECTION_ID_PATTERN],
38
+            'sections.*.type' => ['required', Rule::in(array_keys(PlanSchema::SECTIONS))],
39
+            'sections.*.content' => ['required', 'array'],
40
+        ];
41
+
42
+        foreach (PlanSchema::COLORS as $color) {
43
+            $rules['theme.colors.'.$color] = ['required', 'string', 'regex:'.PlanSchema::COLOR_PATTERN];
44
+        }
45
+
46
+        // Each section gets rules that depend on its own type.
47
+        foreach ($this->sections($plan) as $index => $section) {
48
+            $type = is_array($section) ? ($section['type'] ?? null) : null;
49
+
50
+            if (! is_string($type) || ! isset(PlanSchema::SECTIONS[$type])) {
51
+                continue;
52
+            }
53
+
54
+            $rules["sections.$index.variant"] = ['required', Rule::in(PlanSchema::SECTIONS[$type])];
55
+
56
+            foreach (PlanSchema::contentRules($type) as $field => $fieldRules) {
57
+                $rules["sections.$index.content.$field"] = array_map(
58
+                    fn (string $rule) => $this->qualify($rule, "sections.$index.content."),
59
+                    $fieldRules,
60
+                );
61
+            }
62
+        }
63
+
64
+        /** @var array<string, mixed> $clean */
65
+        $clean = Validator::make($plan, $rules)->validate();
66
+
67
+        return $clean;
68
+    }
69
+
70
+    /**
71
+     * Whether the plan is valid, without throwing.
72
+     *
73
+     * @param  array<mixed>  $plan
74
+     */
75
+    public function passes(array $plan): bool
76
+    {
77
+        try {
78
+            $this->validate($plan);
79
+
80
+            return true;
81
+        } catch (ValidationException) {
82
+            return false;
83
+        }
84
+    }
85
+
86
+    /**
87
+     * @param  array<mixed>  $plan
88
+     * @return array<mixed>
89
+     */
90
+    private function sections(array $plan): array
91
+    {
92
+        return is_array($plan['sections'] ?? null) ? $plan['sections'] : [];
93
+    }
94
+
95
+    /**
96
+     * Rules such as "required_with:cta" name another field. Point them at the full path.
97
+     */
98
+    private function qualify(string $rule, string $prefix): string
99
+    {
100
+        if (str_starts_with($rule, 'required_with:')) {
101
+            return 'required_with:'.$prefix.substr($rule, strlen('required_with:'));
102
+        }
103
+
104
+        return $rule;
105
+    }
106
+}

+ 176
- 0
app/StorePlan/SamplePlan.php Näytä tiedosto

@@ -0,0 +1,176 @@
1
+<?php
2
+
3
+namespace App\StorePlan;
4
+
5
+use App\Models\Store;
6
+
7
+/**
8
+ * A hand-written plan used to prove the renderer works before AI generation exists.
9
+ * It uses every section type once.
10
+ */
11
+final class SamplePlan
12
+{
13
+    /**
14
+     * @return array<string, mixed>
15
+     */
16
+    public static function for(Store $store): array
17
+    {
18
+        $name = $store->name;
19
+
20
+        return [
21
+            'version' => PlanSchema::VERSION,
22
+            'theme' => [
23
+                'colors' => [
24
+                    'background' => '#FBF7F0',
25
+                    'surface' => '#F3EADB',
26
+                    'foreground' => '#2A1A12',
27
+                    'muted' => '#7A6557',
28
+                    'primary' => '#B4411F',
29
+                    'primaryForeground' => '#FFF8F0',
30
+                    'accent' => '#E2A93B',
31
+                    'border' => '#E3D5C0',
32
+                ],
33
+                'fonts' => ['heading' => 'fraunces', 'body' => 'dm-sans'],
34
+                'radius' => 'medium',
35
+            ],
36
+            'sections' => [
37
+                [
38
+                    'id' => 'header',
39
+                    'type' => 'header',
40
+                    'variant' => 'simple',
41
+                    'content' => [
42
+                        'logoText' => $name,
43
+                        'links' => [
44
+                            ['label' => 'Shop', 'href' => '#products'],
45
+                            ['label' => 'Our story', 'href' => '#about'],
46
+                            ['label' => 'FAQ', 'href' => '#faq'],
47
+                            ['label' => 'Contact', 'href' => '#contact'],
48
+                        ],
49
+                        'cta' => ['label' => 'Shop now', 'href' => '#products'],
50
+                    ],
51
+                ],
52
+                [
53
+                    'id' => 'hero',
54
+                    'type' => 'hero',
55
+                    'variant' => 'split',
56
+                    'content' => [
57
+                        'eyebrow' => 'Small batch · Made in Malaysia',
58
+                        'headline' => 'Sambal the way grandma made it',
59
+                        'subheadline' => 'Slow-cooked for six hours with fresh chillies and no preservatives. One spoon turns plain rice into a meal.',
60
+                        'primaryCta' => ['label' => 'Shop the range', 'href' => '#products'],
61
+                        'secondaryCta' => ['label' => 'Our story', 'href' => '#about'],
62
+                    ],
63
+                ],
64
+                [
65
+                    'id' => 'products',
66
+                    'type' => 'product_grid',
67
+                    'variant' => 'grid',
68
+                    'content' => [
69
+                        'heading' => 'Best sellers',
70
+                        'subheading' => 'Cooked fresh every week and delivered across Malaysia.',
71
+                        'items' => [
72
+                            ['name' => 'Sambal Ikan Bilis', 'price' => 18.90, 'badge' => 'Best seller'],
73
+                            ['name' => 'Sambal Hijau', 'price' => 16.90, 'badge' => null],
74
+                            ['name' => 'Sambal Petai', 'price' => 21.90, 'badge' => 'New'],
75
+                            ['name' => 'Sambal Belacan', 'price' => 15.90, 'badge' => null],
76
+                        ],
77
+                    ],
78
+                ],
79
+                [
80
+                    'id' => 'featured',
81
+                    'type' => 'featured_product',
82
+                    'variant' => 'image-right',
83
+                    'content' => [
84
+                        'eyebrow' => 'Gift set',
85
+                        'name' => 'The Family Trio',
86
+                        'description' => 'Three of our most loved sambals in one box. A good first order, and an easy gift for anyone who misses home cooking.',
87
+                        'price' => 49.90,
88
+                        'bullets' => [
89
+                            'Three 180g jars',
90
+                            'Keeps for 3 months unopened',
91
+                            'Free delivery in Peninsular Malaysia',
92
+                        ],
93
+                        'cta' => ['label' => 'Add to cart', 'href' => '#products'],
94
+                    ],
95
+                ],
96
+                [
97
+                    'id' => 'about',
98
+                    'type' => 'about',
99
+                    'variant' => 'with-stats',
100
+                    'content' => [
101
+                        'heading' => 'A family recipe, three generations old',
102
+                        'body' => "$name began in a home kitchen, with a recipe passed from grandmother to mother to daughter. We still cook in small batches, taste every pot, and use chillies bought from the same farms each week.",
103
+                        'stats' => [
104
+                            ['value' => '6 hrs', 'label' => 'Slow-cooked per batch'],
105
+                            ['value' => '0', 'label' => 'Preservatives'],
106
+                            ['value' => '12k+', 'label' => 'Jars delivered'],
107
+                        ],
108
+                    ],
109
+                ],
110
+                [
111
+                    'id' => 'testimonials',
112
+                    'type' => 'testimonials',
113
+                    'variant' => 'cards',
114
+                    'content' => [
115
+                        'heading' => 'What customers say',
116
+                        'items' => [
117
+                            ['quote' => 'Tastes exactly like my late mother\'s sambal. I order four jars every month.', 'name' => 'Aishah R.', 'role' => 'Shah Alam'],
118
+                            ['quote' => 'Spicy, but balanced. My kids now ask for it with every meal.', 'name' => 'Daniel L.', 'role' => 'Penang'],
119
+                            ['quote' => 'Arrived well packed and fresh. The petai one is dangerous.', 'name' => 'Farah N.', 'role' => 'Johor Bahru'],
120
+                        ],
121
+                    ],
122
+                ],
123
+                [
124
+                    'id' => 'faq',
125
+                    'type' => 'faq',
126
+                    'variant' => 'list',
127
+                    'content' => [
128
+                        'heading' => 'Common questions',
129
+                        'items' => [
130
+                            ['question' => 'How long does it keep?', 'answer' => 'Three months unopened. After opening, keep it in the fridge and finish within four weeks.'],
131
+                            ['question' => 'How spicy is it?', 'answer' => 'Most of our sambals are medium. Sambal Hijau is the mildest and Sambal Belacan is the hottest.'],
132
+                            ['question' => 'Do you deliver to East Malaysia?', 'answer' => 'Yes. Delivery to Sabah and Sarawak takes three to five working days.'],
133
+                        ],
134
+                    ],
135
+                ],
136
+                [
137
+                    'id' => 'newsletter',
138
+                    'type' => 'newsletter',
139
+                    'variant' => 'banner',
140
+                    'content' => [
141
+                        'heading' => 'Get 10% off your first order',
142
+                        'body' => 'Join our list for new flavours and recipes. No spam.',
143
+                        'placeholder' => 'Your email address',
144
+                        'buttonLabel' => 'Sign up',
145
+                    ],
146
+                ],
147
+                [
148
+                    'id' => 'contact',
149
+                    'type' => 'contact',
150
+                    'variant' => 'simple',
151
+                    'content' => [
152
+                        'heading' => 'Talk to us',
153
+                        'body' => 'Questions about an order, or want to stock our sambal? We reply within a day.',
154
+                        'email' => 'hello@example.com',
155
+                        'phone' => '+60 12-345 6789',
156
+                        'whatsapp' => '60123456789',
157
+                        'address' => 'Shah Alam, Selangor',
158
+                    ],
159
+                ],
160
+                [
161
+                    'id' => 'footer',
162
+                    'type' => 'footer',
163
+                    'variant' => 'simple',
164
+                    'content' => [
165
+                        'text' => "© $name. All rights reserved.",
166
+                        'links' => [
167
+                            ['label' => 'Shop', 'href' => '#products'],
168
+                            ['label' => 'FAQ', 'href' => '#faq'],
169
+                            ['label' => 'Contact', 'href' => '#contact'],
170
+                        ],
171
+                    ],
172
+                ],
173
+            ],
174
+        ];
175
+    }
176
+}

+ 18
- 0
artisan Näytä tiedosto

@@ -0,0 +1,18 @@
1
+#!/usr/bin/env php
2
+<?php
3
+
4
+use Illuminate\Foundation\Application;
5
+use Symfony\Component\Console\Input\ArgvInput;
6
+
7
+define('LARAVEL_START', microtime(true));
8
+
9
+// Register the Composer autoloader...
10
+require __DIR__.'/vendor/autoload.php';
11
+
12
+// Bootstrap Laravel and handle the command...
13
+/** @var Application $app */
14
+$app = require_once __DIR__.'/bootstrap/app.php';
15
+
16
+$status = $app->handleCommand(new ArgvInput);
17
+
18
+exit($status);

+ 30
- 0
bootstrap/app.php Näytä tiedosto

@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+use App\Http\Middleware\HandleAppearance;
4
+use App\Http\Middleware\HandleInertiaRequests;
5
+use Illuminate\Foundation\Application;
6
+use Illuminate\Foundation\Configuration\Exceptions;
7
+use Illuminate\Foundation\Configuration\Middleware;
8
+use Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets;
9
+use Illuminate\Http\Request;
10
+
11
+return Application::configure(basePath: dirname(__DIR__))
12
+    ->withRouting(
13
+        web: __DIR__.'/../routes/web.php',
14
+        commands: __DIR__.'/../routes/console.php',
15
+        health: '/up',
16
+    )
17
+    ->withMiddleware(function (Middleware $middleware): void {
18
+        $middleware->encryptCookies(except: ['appearance', 'sidebar_state']);
19
+
20
+        $middleware->web(append: [
21
+            HandleAppearance::class,
22
+            HandleInertiaRequests::class,
23
+            AddLinkHeadersForPreloadedAssets::class,
24
+        ]);
25
+    })
26
+    ->withExceptions(function (Exceptions $exceptions): void {
27
+        $exceptions->shouldRenderJsonWhen(
28
+            fn (Request $request) => $request->is('api/*') || $request->expectsJson(),
29
+        );
30
+    })->create();

+ 2
- 0
bootstrap/cache/.gitignore Näytä tiedosto

@@ -0,0 +1,2 @@
1
+*
2
+!.gitignore

+ 9
- 0
bootstrap/providers.php Näytä tiedosto

@@ -0,0 +1,9 @@
1
+<?php
2
+
3
+use App\Providers\AppServiceProvider;
4
+use App\Providers\FortifyServiceProvider;
5
+
6
+return [
7
+    AppServiceProvider::class,
8
+    FortifyServiceProvider::class,
9
+];

+ 21
- 0
components.json Näytä tiedosto

@@ -0,0 +1,21 @@
1
+{
2
+    "$schema": "https://ui.shadcn.com/schema.json",
3
+    "style": "new-york",
4
+    "rsc": false,
5
+    "tsx": true,
6
+    "tailwind": {
7
+        "config": "",
8
+        "css": "resources/css/app.css",
9
+        "baseColor": "neutral",
10
+        "cssVariables": true,
11
+        "prefix": ""
12
+    },
13
+    "aliases": {
14
+        "components": "@/components",
15
+        "utils": "@/lib/utils",
16
+        "ui": "@/components/ui",
17
+        "lib": "@/lib",
18
+        "hooks": "@/hooks"
19
+    },
20
+    "iconLibrary": "lucide"
21
+}

+ 116
- 0
composer.json Näytä tiedosto

@@ -0,0 +1,116 @@
1
+{
2
+    "$schema": "https://getcomposer.org/schema.json",
3
+    "name": "laravel/react-starter-kit",
4
+    "type": "project",
5
+    "description": "The skeleton application for the Laravel framework.",
6
+    "keywords": [
7
+        "laravel",
8
+        "framework"
9
+    ],
10
+    "license": "MIT",
11
+    "require": {
12
+        "php": "^8.3",
13
+        "inertiajs/inertia-laravel": "^3.0",
14
+        "laravel/chisel": "^0.1.0",
15
+        "laravel/fortify": "^1.37.2",
16
+        "laravel/framework": "^13.17",
17
+        "laravel/tinker": "^3.0",
18
+        "laravel/wayfinder": "^0.1.14"
19
+    },
20
+    "require-dev": {
21
+        "fakerphp/faker": "^1.24",
22
+        "larastan/larastan": "^3.9",
23
+        "laravel/pail": "^1.2.5",
24
+        "laravel/pao": "^1.0.6",
25
+        "laravel/pint": "^1.27",
26
+        "laravel/sail": "^1.53",
27
+        "mockery/mockery": "^1.6",
28
+        "nunomaduro/collision": "^8.9.3",
29
+        "phpunit/phpunit": "^12.5.23"
30
+    },
31
+    "autoload": {
32
+        "psr-4": {
33
+            "App\\": "app/",
34
+            "Database\\Factories\\": "database/factories/",
35
+            "Database\\Seeders\\": "database/seeders/"
36
+        }
37
+    },
38
+    "autoload-dev": {
39
+        "psr-4": {
40
+            "Tests\\": "tests/"
41
+        }
42
+    },
43
+    "scripts": {
44
+        "setup": [
45
+            "composer install",
46
+            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
47
+            "@php artisan key:generate",
48
+            "@php artisan migrate --force",
49
+            "npm install",
50
+            "npm run build"
51
+        ],
52
+        "dev": [
53
+            "Composer\\Config::disableProcessTimeout",
54
+            "@php artisan dev"
55
+        ],
56
+        "lint": [
57
+            "pint --parallel"
58
+        ],
59
+        "lint:check": [
60
+            "pint --parallel --test"
61
+        ],
62
+        "ci:check": [
63
+            "Composer\\Config::disableProcessTimeout",
64
+            "npm run check",
65
+            "npm run types:check",
66
+            "@test"
67
+        ],
68
+        "types:check": [
69
+            "phpstan analyse"
70
+        ],
71
+        "test": [
72
+            "@php artisan config:clear --ansi",
73
+            "@lint:check",
74
+            "@types:check",
75
+            "@php artisan test"
76
+        ],
77
+        "post-autoload-dump": [
78
+            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
79
+            "@php artisan package:discover --ansi"
80
+        ],
81
+        "post-update-cmd": [
82
+            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
83
+        ],
84
+        "post-root-package-install": [
85
+            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
86
+        ],
87
+        "post-create-project-cmd": [
88
+            "@php artisan key:generate --ansi",
89
+            "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
90
+            "@php artisan migrate --graceful --ansi"
91
+        ],
92
+        "pre-package-uninstall": [
93
+            "Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
94
+        ]
95
+    },
96
+    "extra": {
97
+        "laravel": {
98
+            "dont-discover": [],
99
+            "installer": {
100
+                "post-create-project": [
101
+                ]
102
+            }
103
+        }
104
+    },
105
+    "config": {
106
+        "optimize-autoloader": true,
107
+        "preferred-install": "dist",
108
+        "sort-packages": true,
109
+        "allow-plugins": {
110
+            "pestphp/pest-plugin": true,
111
+            "php-http/discovery": true
112
+        }
113
+    },
114
+    "minimum-stability": "stable",
115
+    "prefer-stable": true
116
+}

+ 10476
- 0
composer.lock
File diff suppressed because it is too large
Näytä tiedosto


+ 126
- 0
config/app.php Näytä tiedosto

@@ -0,0 +1,126 @@
1
+<?php
2
+
3
+return [
4
+
5
+    /*
6
+    |--------------------------------------------------------------------------
7
+    | Application Name
8
+    |--------------------------------------------------------------------------
9
+    |
10
+    | This value is the name of your application, which will be used when the
11
+    | framework needs to place the application's name in a notification or
12
+    | other UI elements where an application name needs to be displayed.
13
+    |
14
+    */
15
+
16
+    'name' => env('APP_NAME', 'Laravel'),
17
+
18
+    /*
19
+    |--------------------------------------------------------------------------
20
+    | Application Environment
21
+    |--------------------------------------------------------------------------
22
+    |
23
+    | This value determines the "environment" your application is currently
24
+    | running in. This may determine how you prefer to configure various
25
+    | services the application utilizes. Set this in your ".env" file.
26
+    |
27
+    */
28
+
29
+    'env' => env('APP_ENV', 'production'),
30
+
31
+    /*
32
+    |--------------------------------------------------------------------------
33
+    | Application Debug Mode
34
+    |--------------------------------------------------------------------------
35
+    |
36
+    | When your application is in debug mode, detailed error messages with
37
+    | stack traces will be shown on every error that occurs within your
38
+    | application. If disabled, a simple generic error page is shown.
39
+    |
40
+    */
41
+
42
+    'debug' => (bool) env('APP_DEBUG', false),
43
+
44
+    /*
45
+    |--------------------------------------------------------------------------
46
+    | Application URL
47
+    |--------------------------------------------------------------------------
48
+    |
49
+    | This URL is used by the console to properly generate URLs when using
50
+    | the Artisan command line tool. You should set this to the root of
51
+    | the application so that it's available within Artisan commands.
52
+    |
53
+    */
54
+
55
+    'url' => env('APP_URL', 'http://localhost'),
56
+
57
+    /*
58
+    |--------------------------------------------------------------------------
59
+    | Application Timezone
60
+    |--------------------------------------------------------------------------
61
+    |
62
+    | Here you may specify the default timezone for your application, which
63
+    | will be used by the PHP date and date-time functions. The timezone
64
+    | is set to "UTC" by default as it is suitable for most use cases.
65
+    |
66
+    */
67
+
68
+    'timezone' => 'UTC',
69
+
70
+    /*
71
+    |--------------------------------------------------------------------------
72
+    | Application Locale Configuration
73
+    |--------------------------------------------------------------------------
74
+    |
75
+    | The application locale determines the default locale that will be used
76
+    | by Laravel's translation / localization methods. This option can be
77
+    | set to any locale for which you plan to have translation strings.
78
+    |
79
+    */
80
+
81
+    'locale' => env('APP_LOCALE', 'en'),
82
+
83
+    'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
84
+
85
+    'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
86
+
87
+    /*
88
+    |--------------------------------------------------------------------------
89
+    | Encryption Key
90
+    |--------------------------------------------------------------------------
91
+    |
92
+    | This key is utilized by Laravel's encryption services and should be set
93
+    | to a random, 32 character string to ensure that all encrypted values
94
+    | are secure. You should do this prior to deploying the application.
95
+    |
96
+    */
97
+
98
+    'cipher' => 'AES-256-CBC',
99
+
100
+    'key' => env('APP_KEY'),
101
+
102
+    'previous_keys' => [
103
+        ...array_filter(
104
+            explode(',', (string) env('APP_PREVIOUS_KEYS', '')),
105
+        ),
106
+    ],
107
+
108
+    /*
109
+    |--------------------------------------------------------------------------
110
+    | Maintenance Mode Driver
111
+    |--------------------------------------------------------------------------
112
+    |
113
+    | These configuration options determine the driver used to determine and
114
+    | manage Laravel's "maintenance mode" status. The "cache" driver will
115
+    | allow maintenance mode to be controlled across multiple machines.
116
+    |
117
+    | Supported drivers: "file", "cache", "array"
118
+    |
119
+    */
120
+
121
+    'maintenance' => [
122
+        'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
123
+        'store' => env('APP_MAINTENANCE_STORE', 'database'),
124
+    ],
125
+
126
+];

+ 117
- 0
config/auth.php Näytä tiedosto

@@ -0,0 +1,117 @@
1
+<?php
2
+
3
+use App\Models\User;
4
+
5
+return [
6
+
7
+    /*
8
+    |--------------------------------------------------------------------------
9
+    | Authentication Defaults
10
+    |--------------------------------------------------------------------------
11
+    |
12
+    | This option defines the default authentication "guard" and password
13
+    | reset "broker" for your application. You may change these values
14
+    | as required, but they're a perfect start for most applications.
15
+    |
16
+    */
17
+
18
+    'defaults' => [
19
+        'guard' => env('AUTH_GUARD', 'web'),
20
+        'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
21
+    ],
22
+
23
+    /*
24
+    |--------------------------------------------------------------------------
25
+    | Authentication Guards
26
+    |--------------------------------------------------------------------------
27
+    |
28
+    | Next, you may define every authentication guard for your application.
29
+    | Of course, a great default configuration has been defined for you
30
+    | which utilizes session storage plus the Eloquent user provider.
31
+    |
32
+    | All authentication guards have a user provider, which defines how the
33
+    | users are actually retrieved out of your database or other storage
34
+    | system used by the application. Typically, Eloquent is utilized.
35
+    |
36
+    | Supported: "session"
37
+    |
38
+    */
39
+
40
+    'guards' => [
41
+        'web' => [
42
+            'driver' => 'session',
43
+            'provider' => 'users',
44
+        ],
45
+    ],
46
+
47
+    /*
48
+    |--------------------------------------------------------------------------
49
+    | User Providers
50
+    |--------------------------------------------------------------------------
51
+    |
52
+    | All authentication guards have a user provider, which defines how the
53
+    | users are actually retrieved out of your database or other storage
54
+    | system used by the application. Typically, Eloquent is utilized.
55
+    |
56
+    | If you have multiple user tables or models you may configure multiple
57
+    | providers to represent the model / table. These providers may then
58
+    | be assigned to any extra authentication guards you have defined.
59
+    |
60
+    | Supported: "database", "eloquent"
61
+    |
62
+    */
63
+
64
+    'providers' => [
65
+        'users' => [
66
+            'driver' => 'eloquent',
67
+            'model' => env('AUTH_MODEL', User::class),
68
+        ],
69
+
70
+        // 'users' => [
71
+        //     'driver' => 'database',
72
+        //     'table' => 'users',
73
+        // ],
74
+    ],
75
+
76
+    /*
77
+    |--------------------------------------------------------------------------
78
+    | Resetting Passwords
79
+    |--------------------------------------------------------------------------
80
+    |
81
+    | These configuration options specify the behavior of Laravel's password
82
+    | reset functionality, including the table utilized for token storage
83
+    | and the user provider that is invoked to actually retrieve users.
84
+    |
85
+    | The expiry time is the number of minutes that each reset token will be
86
+    | considered valid. This security feature keeps tokens short-lived so
87
+    | they have less time to be guessed. You may change this as needed.
88
+    |
89
+    | The throttle setting is the number of seconds a user must wait before
90
+    | generating more password reset tokens. This prevents the user from
91
+    | quickly generating a very large amount of password reset tokens.
92
+    |
93
+    */
94
+
95
+    'passwords' => [
96
+        'users' => [
97
+            'provider' => 'users',
98
+            'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
99
+            'expire' => 60,
100
+            'throttle' => 60,
101
+        ],
102
+    ],
103
+
104
+    /*
105
+    |--------------------------------------------------------------------------
106
+    | Password Confirmation Timeout
107
+    |--------------------------------------------------------------------------
108
+    |
109
+    | Here you may define the number of seconds before a password confirmation
110
+    | window expires and users are asked to re-enter their password via the
111
+    | confirmation screen. By default, the timeout lasts for three hours.
112
+    |
113
+    */
114
+
115
+    'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
116
+
117
+];

+ 136
- 0
config/cache.php Näytä tiedosto

@@ -0,0 +1,136 @@
1
+<?php
2
+
3
+use Illuminate\Support\Str;
4
+
5
+return [
6
+
7
+    /*
8
+    |--------------------------------------------------------------------------
9
+    | Default Cache Store
10
+    |--------------------------------------------------------------------------
11
+    |
12
+    | This option controls the default cache store that will be used by the
13
+    | framework. This connection is utilized if another isn't explicitly
14
+    | specified when running a cache operation inside the application.
15
+    |
16
+    */
17
+
18
+    'default' => env('CACHE_STORE', 'database'),
19
+
20
+    /*
21
+    |--------------------------------------------------------------------------
22
+    | Cache Stores
23
+    |--------------------------------------------------------------------------
24
+    |
25
+    | Here you may define all of the cache "stores" for your application as
26
+    | well as their drivers. You may even define multiple stores for the
27
+    | same cache driver to group types of items stored in your caches.
28
+    |
29
+    | Supported drivers: "array", "database", "file", "memcached",
30
+    |                    "redis", "dynamodb", "storage", "octane",
31
+    |                    "session", "failover", "null"
32
+    |
33
+    */
34
+
35
+    'stores' => [
36
+
37
+        'array' => [
38
+            'driver' => 'array',
39
+            'serialize' => false,
40
+        ],
41
+
42
+        'database' => [
43
+            'driver' => 'database',
44
+            'connection' => env('DB_CACHE_CONNECTION'),
45
+            'table' => env('DB_CACHE_TABLE', 'cache'),
46
+            'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
47
+            'lock_table' => env('DB_CACHE_LOCK_TABLE'),
48
+        ],
49
+
50
+        'file' => [
51
+            'driver' => 'file',
52
+            'path' => storage_path('framework/cache/data'),
53
+            'lock_path' => storage_path('framework/cache/locks'),
54
+        ],
55
+
56
+        'storage' => [
57
+            'driver' => 'storage',
58
+            'disk' => env('CACHE_STORAGE_DISK'),
59
+            'path' => env('CACHE_STORAGE_PATH', 'framework/cache/data'),
60
+        ],
61
+
62
+        'memcached' => [
63
+            'driver' => 'memcached',
64
+            'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
65
+            'sasl' => [
66
+                env('MEMCACHED_USERNAME'),
67
+                env('MEMCACHED_PASSWORD'),
68
+            ],
69
+            'options' => [
70
+                // Memcached::OPT_CONNECT_TIMEOUT => 2000,
71
+            ],
72
+            'servers' => [
73
+                [
74
+                    'host' => env('MEMCACHED_HOST', '127.0.0.1'),
75
+                    'port' => env('MEMCACHED_PORT', 11211),
76
+                    'weight' => 100,
77
+                ],
78
+            ],
79
+        ],
80
+
81
+        'redis' => [
82
+            'driver' => 'redis',
83
+            'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
84
+            'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
85
+        ],
86
+
87
+        'dynamodb' => [
88
+            'driver' => 'dynamodb',
89
+            'key' => env('AWS_ACCESS_KEY_ID'),
90
+            'secret' => env('AWS_SECRET_ACCESS_KEY'),
91
+            'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
92
+            'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
93
+            'endpoint' => env('DYNAMODB_ENDPOINT'),
94
+        ],
95
+
96
+        'octane' => [
97
+            'driver' => 'octane',
98
+        ],
99
+
100
+        'failover' => [
101
+            'driver' => 'failover',
102
+            'stores' => [
103
+                'database',
104
+                'array',
105
+            ],
106
+        ],
107
+
108
+    ],
109
+
110
+    /*
111
+    |--------------------------------------------------------------------------
112
+    | Cache Key Prefix
113
+    |--------------------------------------------------------------------------
114
+    |
115
+    | When utilizing the APC, database, memcached, Redis, and DynamoDB cache
116
+    | stores, there might be other applications using the same cache. For
117
+    | that reason, you may prefix every cache key to avoid collisions.
118
+    |
119
+    */
120
+
121
+    'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
122
+
123
+    /*
124
+    |--------------------------------------------------------------------------
125
+    | Serializable Classes
126
+    |--------------------------------------------------------------------------
127
+    |
128
+    | This value determines the classes that can be unserialized from cache
129
+    | storage. By default, no PHP classes will be unserialized from your
130
+    | cache to prevent gadget chain attacks if your APP_KEY is leaked.
131
+    |
132
+    */
133
+
134
+    'serializable_classes' => false,
135
+
136
+];

+ 184
- 0
config/database.php Näytä tiedosto

@@ -0,0 +1,184 @@
1
+<?php
2
+
3
+use Illuminate\Support\Str;
4
+use Pdo\Mysql;
5
+
6
+return [
7
+
8
+    /*
9
+    |--------------------------------------------------------------------------
10
+    | Default Database Connection Name
11
+    |--------------------------------------------------------------------------
12
+    |
13
+    | Here you may specify which of the database connections below you wish
14
+    | to use as your default connection for database operations. This is
15
+    | the connection which will be utilized unless another connection
16
+    | is explicitly specified when you execute a query / statement.
17
+    |
18
+    */
19
+
20
+    'default' => env('DB_CONNECTION', 'sqlite'),
21
+
22
+    /*
23
+    |--------------------------------------------------------------------------
24
+    | Database Connections
25
+    |--------------------------------------------------------------------------
26
+    |
27
+    | Below are all of the database connections defined for your application.
28
+    | An example configuration is provided for each database system which
29
+    | is supported by Laravel. You're free to add / remove connections.
30
+    |
31
+    */
32
+
33
+    'connections' => [
34
+
35
+        'sqlite' => [
36
+            'driver' => 'sqlite',
37
+            'url' => env('DB_URL'),
38
+            'database' => env('DB_DATABASE', database_path('database.sqlite')),
39
+            'prefix' => '',
40
+            'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
41
+            'busy_timeout' => null,
42
+            'journal_mode' => null,
43
+            'synchronous' => null,
44
+            'transaction_mode' => 'DEFERRED',
45
+        ],
46
+
47
+        'mysql' => [
48
+            'driver' => 'mysql',
49
+            'url' => env('DB_URL'),
50
+            'host' => env('DB_HOST', '127.0.0.1'),
51
+            'port' => env('DB_PORT', '3306'),
52
+            'database' => env('DB_DATABASE', 'laravel'),
53
+            'username' => env('DB_USERNAME', 'root'),
54
+            'password' => env('DB_PASSWORD', ''),
55
+            'unix_socket' => env('DB_SOCKET', ''),
56
+            'charset' => env('DB_CHARSET', 'utf8mb4'),
57
+            'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
58
+            'prefix' => '',
59
+            'prefix_indexes' => true,
60
+            'strict' => true,
61
+            'engine' => null,
62
+            'options' => extension_loaded('pdo_mysql') ? array_filter([
63
+                Mysql::ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
64
+            ]) : [],
65
+        ],
66
+
67
+        'mariadb' => [
68
+            'driver' => 'mariadb',
69
+            'url' => env('DB_URL'),
70
+            'host' => env('DB_HOST', '127.0.0.1'),
71
+            'port' => env('DB_PORT', '3306'),
72
+            'database' => env('DB_DATABASE', 'laravel'),
73
+            'username' => env('DB_USERNAME', 'root'),
74
+            'password' => env('DB_PASSWORD', ''),
75
+            'unix_socket' => env('DB_SOCKET', ''),
76
+            'charset' => env('DB_CHARSET', 'utf8mb4'),
77
+            'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
78
+            'prefix' => '',
79
+            'prefix_indexes' => true,
80
+            'strict' => true,
81
+            'engine' => null,
82
+            'options' => extension_loaded('pdo_mysql') ? array_filter([
83
+                Mysql::ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
84
+            ]) : [],
85
+        ],
86
+
87
+        'pgsql' => [
88
+            'driver' => 'pgsql',
89
+            'url' => env('DB_URL'),
90
+            'host' => env('DB_HOST', '127.0.0.1'),
91
+            'port' => env('DB_PORT', '5432'),
92
+            'database' => env('DB_DATABASE', 'laravel'),
93
+            'username' => env('DB_USERNAME', 'root'),
94
+            'password' => env('DB_PASSWORD', ''),
95
+            'charset' => env('DB_CHARSET', 'utf8'),
96
+            'prefix' => '',
97
+            'prefix_indexes' => true,
98
+            'search_path' => 'public',
99
+            'sslmode' => env('DB_SSLMODE', 'prefer'),
100
+        ],
101
+
102
+        'sqlsrv' => [
103
+            'driver' => 'sqlsrv',
104
+            'url' => env('DB_URL'),
105
+            'host' => env('DB_HOST', 'localhost'),
106
+            'port' => env('DB_PORT', '1433'),
107
+            'database' => env('DB_DATABASE', 'laravel'),
108
+            'username' => env('DB_USERNAME', 'root'),
109
+            'password' => env('DB_PASSWORD', ''),
110
+            'charset' => env('DB_CHARSET', 'utf8'),
111
+            'prefix' => '',
112
+            'prefix_indexes' => true,
113
+            // 'encrypt' => env('DB_ENCRYPT', 'yes'),
114
+            // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
115
+        ],
116
+
117
+    ],
118
+
119
+    /*
120
+    |--------------------------------------------------------------------------
121
+    | Migration Repository Table
122
+    |--------------------------------------------------------------------------
123
+    |
124
+    | This table keeps track of all the migrations that have already run for
125
+    | your application. Using this information, we can determine which of
126
+    | the migrations on disk haven't actually been run on the database.
127
+    |
128
+    */
129
+
130
+    'migrations' => [
131
+        'table' => 'migrations',
132
+        'update_date_on_publish' => true,
133
+    ],
134
+
135
+    /*
136
+    |--------------------------------------------------------------------------
137
+    | Redis Databases
138
+    |--------------------------------------------------------------------------
139
+    |
140
+    | Redis is an open source, fast, and advanced key-value store that also
141
+    | provides a richer body of commands than a typical key-value system
142
+    | such as Memcached. You may define your connection settings here.
143
+    |
144
+    */
145
+
146
+    'redis' => [
147
+
148
+        'client' => env('REDIS_CLIENT', 'phpredis'),
149
+
150
+        'options' => [
151
+            'cluster' => env('REDIS_CLUSTER', 'redis'),
152
+            'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
153
+            'persistent' => env('REDIS_PERSISTENT', false),
154
+        ],
155
+
156
+        'default' => [
157
+            'url' => env('REDIS_URL'),
158
+            'host' => env('REDIS_HOST', '127.0.0.1'),
159
+            'username' => env('REDIS_USERNAME'),
160
+            'password' => env('REDIS_PASSWORD'),
161
+            'port' => env('REDIS_PORT', '6379'),
162
+            'database' => env('REDIS_DB', '0'),
163
+            'max_retries' => env('REDIS_MAX_RETRIES', 3),
164
+            'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
165
+            'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
166
+            'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
167
+        ],
168
+
169
+        'cache' => [
170
+            'url' => env('REDIS_URL'),
171
+            'host' => env('REDIS_HOST', '127.0.0.1'),
172
+            'username' => env('REDIS_USERNAME'),
173
+            'password' => env('REDIS_PASSWORD'),
174
+            'port' => env('REDIS_PORT', '6379'),
175
+            'database' => env('REDIS_CACHE_DB', '1'),
176
+            'max_retries' => env('REDIS_MAX_RETRIES', 3),
177
+            'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
178
+            'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
179
+            'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
180
+        ],
181
+
182
+    ],
183
+
184
+];

+ 80
- 0
config/filesystems.php Näytä tiedosto

@@ -0,0 +1,80 @@
1
+<?php
2
+
3
+return [
4
+
5
+    /*
6
+    |--------------------------------------------------------------------------
7
+    | Default Filesystem Disk
8
+    |--------------------------------------------------------------------------
9
+    |
10
+    | Here you may specify the default filesystem disk that should be used
11
+    | by the framework. The "local" disk, as well as a variety of cloud
12
+    | based disks are available to your application for file storage.
13
+    |
14
+    */
15
+
16
+    'default' => env('FILESYSTEM_DISK', 'local'),
17
+
18
+    /*
19
+    |--------------------------------------------------------------------------
20
+    | Filesystem Disks
21
+    |--------------------------------------------------------------------------
22
+    |
23
+    | Below you may configure as many filesystem disks as necessary, and you
24
+    | may even configure multiple disks for the same driver. Examples for
25
+    | most supported storage drivers are configured here for reference.
26
+    |
27
+    | Supported drivers: "local", "ftp", "sftp", "s3"
28
+    |
29
+    */
30
+
31
+    'disks' => [
32
+
33
+        'local' => [
34
+            'driver' => 'local',
35
+            'root' => storage_path('app/private'),
36
+            'serve' => true,
37
+            'throw' => false,
38
+            'report' => false,
39
+        ],
40
+
41
+        'public' => [
42
+            'driver' => 'local',
43
+            'root' => storage_path('app/public'),
44
+            'url' => rtrim((string) env('APP_URL', 'http://localhost'), '/').'/storage',
45
+            'visibility' => 'public',
46
+            'throw' => false,
47
+            'report' => false,
48
+        ],
49
+
50
+        's3' => [
51
+            'driver' => 's3',
52
+            'key' => env('AWS_ACCESS_KEY_ID'),
53
+            'secret' => env('AWS_SECRET_ACCESS_KEY'),
54
+            'region' => env('AWS_DEFAULT_REGION'),
55
+            'bucket' => env('AWS_BUCKET'),
56
+            'url' => env('AWS_URL'),
57
+            'endpoint' => env('AWS_ENDPOINT'),
58
+            'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
59
+            'throw' => false,
60
+            'report' => false,
61
+        ],
62
+
63
+    ],
64
+
65
+    /*
66
+    |--------------------------------------------------------------------------
67
+    | Symbolic Links
68
+    |--------------------------------------------------------------------------
69
+    |
70
+    | Here you may configure the symbolic links that will be created when the
71
+    | `storage:link` Artisan command is executed. The array keys should be
72
+    | the locations of the links and the values should be their targets.
73
+    |
74
+    */
75
+
76
+    'links' => [
77
+        public_path('storage') => storage_path('app/public'),
78
+    ],
79
+
80
+];

+ 157
- 0
config/fortify.php Näytä tiedosto

@@ -0,0 +1,157 @@
1
+<?php
2
+
3
+use Laravel\Fortify\Features;
4
+
5
+return [
6
+
7
+    /*
8
+    |--------------------------------------------------------------------------
9
+    | Fortify Guard
10
+    |--------------------------------------------------------------------------
11
+    |
12
+    | Here you may specify which authentication guard Fortify will use while
13
+    | authenticating users. This value should correspond with one of your
14
+    | guards that is already present in your "auth" configuration file.
15
+    |
16
+    */
17
+
18
+    'guard' => 'web',
19
+
20
+    /*
21
+    |--------------------------------------------------------------------------
22
+    | Fortify Password Broker
23
+    |--------------------------------------------------------------------------
24
+    |
25
+    | Here you may specify which password broker Fortify can use when a user
26
+    | is resetting their password. This configured value should match one
27
+    | of your password brokers setup in your "auth" configuration file.
28
+    |
29
+    */
30
+
31
+    'passwords' => 'users',
32
+
33
+    /*
34
+    |--------------------------------------------------------------------------
35
+    | Username / Email
36
+    |--------------------------------------------------------------------------
37
+    |
38
+    | This value defines which model attribute should be considered as your
39
+    | application's "username" field. Typically, this might be the email
40
+    | address of the users but you are free to change this value here.
41
+    |
42
+    | Out of the box, Fortify expects forgot password and reset password
43
+    | requests to have a field named 'email'. If the application uses
44
+    | another name for the field you may define it below as needed.
45
+    |
46
+    */
47
+
48
+    'username' => 'email',
49
+
50
+    'email' => 'email',
51
+
52
+    /*
53
+    |--------------------------------------------------------------------------
54
+    | Lowercase Usernames
55
+    |--------------------------------------------------------------------------
56
+    |
57
+    | This value defines whether usernames should be lowercased before saving
58
+    | them in the database, as some database system string fields are case
59
+    | sensitive. You may disable this for your application if necessary.
60
+    |
61
+    */
62
+
63
+    'lowercase_usernames' => true,
64
+
65
+    /*
66
+    |--------------------------------------------------------------------------
67
+    | Home Path
68
+    |--------------------------------------------------------------------------
69
+    |
70
+    | Here you may configure the path where users will get redirected during
71
+    | authentication or password reset when the operations are successful
72
+    | and the user is authenticated. You are free to change this value.
73
+    |
74
+    */
75
+
76
+    'home' => '/dashboard',
77
+
78
+    /*
79
+    |--------------------------------------------------------------------------
80
+    | Fortify Routes Prefix / Subdomain
81
+    |--------------------------------------------------------------------------
82
+    |
83
+    | Here you may specify which prefix Fortify will assign to all the routes
84
+    | that it registers with the application. If necessary, you may change
85
+    | subdomain under which all of the Fortify routes will be available.
86
+    |
87
+    */
88
+
89
+    'prefix' => '',
90
+
91
+    'domain' => null,
92
+
93
+    /*
94
+    |--------------------------------------------------------------------------
95
+    | Fortify Routes Middleware
96
+    |--------------------------------------------------------------------------
97
+    |
98
+    | Here you may specify which middleware Fortify will assign to the routes
99
+    | that it registers with the application. If necessary, you may change
100
+    | these middleware but typically this provided default is preferred.
101
+    |
102
+    */
103
+
104
+    'middleware' => ['web'],
105
+
106
+    /*
107
+    |--------------------------------------------------------------------------
108
+    | Rate Limiting
109
+    |--------------------------------------------------------------------------
110
+    |
111
+    | By default, Fortify will throttle logins to five requests per minute for
112
+    | every email and IP address combination. However, if you would like to
113
+    | specify a custom rate limiter to call then you may specify it here.
114
+    |
115
+    */
116
+
117
+    'limiters' => [
118
+        'login' => 'login',
119
+        'two-factor' => 'two-factor',
120
+    ],
121
+
122
+    /*
123
+    |--------------------------------------------------------------------------
124
+    | Register View Routes
125
+    |--------------------------------------------------------------------------
126
+    |
127
+    | Here you may specify if the routes returning views should be disabled as
128
+    | you may not need them when building your own application. This may be
129
+    | especially true if you're writing a custom single-page application.
130
+    |
131
+    */
132
+
133
+    'views' => true,
134
+
135
+    /*
136
+    |--------------------------------------------------------------------------
137
+    | Features
138
+    |--------------------------------------------------------------------------
139
+    |
140
+    | Some of the Fortify features are optional. You may disable the features
141
+    | by removing them from this array. You're free to only remove some of
142
+    | these features, or you can even remove all of these if you need to.
143
+    |
144
+    */
145
+
146
+    'features' => [
147
+        Features::registration(),
148
+        Features::resetPasswords(),
149
+        Features::emailVerification(),
150
+        Features::twoFactorAuthentication([
151
+            'confirm' => true,
152
+            'confirmPassword' => true,
153
+            // 'window' => 0
154
+        ]),
155
+    ],
156
+
157
+];

+ 70
- 0
config/inertia.php Näytä tiedosto

@@ -0,0 +1,70 @@
1
+<?php
2
+
3
+return [
4
+
5
+    /*
6
+    |--------------------------------------------------------------------------
7
+    | Server Side Rendering
8
+    |--------------------------------------------------------------------------
9
+    |
10
+    | These options configures if and how Inertia uses Server Side Rendering
11
+    | to pre-render each initial request made to your application's pages
12
+    | so that server rendered HTML is delivered for the user's browser.
13
+    |
14
+    | See: https://inertiajs.com/server-side-rendering
15
+    |
16
+    */
17
+
18
+    'ssr' => [
19
+        'enabled' => true,
20
+        'url' => 'http://127.0.0.1:13714',
21
+        // 'bundle' => base_path('bootstrap/ssr/ssr.mjs'),
22
+
23
+    ],
24
+
25
+    /*
26
+    |--------------------------------------------------------------------------
27
+    | Pages
28
+    |--------------------------------------------------------------------------
29
+    |
30
+    | These options configure how Inertia discovers page components on the
31
+    | filesystem. The paths and extensions are used to locate components
32
+    | when rendering responses and during testing assertions.
33
+    |
34
+    */
35
+
36
+    'pages' => [
37
+
38
+        'paths' => [
39
+            resource_path('js/pages'),
40
+        ],
41
+
42
+        'extensions' => [
43
+            'js',
44
+            'jsx',
45
+            'svelte',
46
+            'ts',
47
+            'tsx',
48
+            'vue',
49
+        ],
50
+
51
+    ],
52
+
53
+    /*
54
+    |--------------------------------------------------------------------------
55
+    | Testing
56
+    |--------------------------------------------------------------------------
57
+    |
58
+    | The values described here are used to locate Inertia components on the
59
+    | filesystem. For instance, when using `assertInertia`, the assertion
60
+    | attempts to locate the component as a file relative to the paths.
61
+    |
62
+    */
63
+
64
+    'testing' => [
65
+
66
+        'ensure_pages_exist' => true,
67
+
68
+    ],
69
+
70
+];

+ 140
- 0
config/logging.php Näytä tiedosto

@@ -0,0 +1,140 @@
1
+<?php
2
+
3
+use Monolog\Handler\NullHandler;
4
+use Monolog\Handler\StreamHandler;
5
+use Monolog\Handler\SyslogUdpHandler;
6
+use Monolog\Processor\PsrLogMessageProcessor;
7
+
8
+return [
9
+
10
+    /*
11
+    |--------------------------------------------------------------------------
12
+    | Default Log Channel
13
+    |--------------------------------------------------------------------------
14
+    |
15
+    | This option defines the default log channel that is utilized to write
16
+    | messages to your logs. The value provided here should match one of
17
+    | the channels present in the list of "channels" configured below.
18
+    |
19
+    */
20
+
21
+    'default' => env('LOG_CHANNEL', 'stack'),
22
+
23
+    /*
24
+    |--------------------------------------------------------------------------
25
+    | Deprecations Log Channel
26
+    |--------------------------------------------------------------------------
27
+    |
28
+    | This option controls the log channel that should be used to log warnings
29
+    | regarding deprecated PHP and library features. This allows you to get
30
+    | your application ready for upcoming major versions of dependencies.
31
+    |
32
+    */
33
+
34
+    'deprecations' => [
35
+        'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
36
+        'trace' => env('LOG_DEPRECATIONS_TRACE', false),
37
+    ],
38
+
39
+    /*
40
+    |--------------------------------------------------------------------------
41
+    | Log Channels
42
+    |--------------------------------------------------------------------------
43
+    |
44
+    | Here you may configure the log channels for your application. Laravel
45
+    | utilizes the Monolog PHP logging library, which includes a variety
46
+    | of powerful log handlers and formatters that you're free to use.
47
+    |
48
+    | Available drivers: "single", "daily", "monthly", "slack", "syslog",
49
+    |                    "errorlog", "monolog", "custom", "stack"
50
+    |
51
+    */
52
+
53
+    'channels' => [
54
+
55
+        'stack' => [
56
+            'driver' => 'stack',
57
+            'channels' => explode(',', (string) env('LOG_STACK', 'single')),
58
+            'ignore_exceptions' => false,
59
+        ],
60
+
61
+        'single' => [
62
+            'driver' => 'single',
63
+            'path' => storage_path('logs/laravel.log'),
64
+            'level' => env('LOG_LEVEL', 'debug'),
65
+            'replace_placeholders' => true,
66
+        ],
67
+
68
+        'daily' => [
69
+            'driver' => 'daily',
70
+            'path' => storage_path('logs/laravel.log'),
71
+            'level' => env('LOG_LEVEL', 'debug'),
72
+            'max_files' => env('LOG_DAILY_DAYS', 14),
73
+            'replace_placeholders' => true,
74
+        ],
75
+
76
+        'monthly' => [
77
+            'driver' => 'monthly',
78
+            'path' => storage_path('logs/laravel.log'),
79
+            'level' => env('LOG_LEVEL', 'debug'),
80
+            'max_files' => 3,
81
+            'replace_placeholders' => true,
82
+        ],
83
+
84
+        'slack' => [
85
+            'driver' => 'slack',
86
+            'url' => env('LOG_SLACK_WEBHOOK_URL'),
87
+            'username' => env('LOG_SLACK_USERNAME', env('APP_NAME', 'Laravel')),
88
+            'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
89
+            'level' => env('LOG_LEVEL', 'critical'),
90
+            'replace_placeholders' => true,
91
+        ],
92
+
93
+        'papertrail' => [
94
+            'driver' => 'monolog',
95
+            'level' => env('LOG_LEVEL', 'debug'),
96
+            'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
97
+            'handler_with' => [
98
+                'host' => env('PAPERTRAIL_URL'),
99
+                'port' => env('PAPERTRAIL_PORT'),
100
+                'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
101
+            ],
102
+            'processors' => [PsrLogMessageProcessor::class],
103
+        ],
104
+
105
+        'stderr' => [
106
+            'driver' => 'monolog',
107
+            'level' => env('LOG_LEVEL', 'debug'),
108
+            'handler' => StreamHandler::class,
109
+            'handler_with' => [
110
+                'stream' => 'php://stderr',
111
+            ],
112
+            'formatter' => env('LOG_STDERR_FORMATTER'),
113
+            'processors' => [PsrLogMessageProcessor::class],
114
+        ],
115
+
116
+        'syslog' => [
117
+            'driver' => 'syslog',
118
+            'level' => env('LOG_LEVEL', 'debug'),
119
+            'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
120
+            'replace_placeholders' => true,
121
+        ],
122
+
123
+        'errorlog' => [
124
+            'driver' => 'errorlog',
125
+            'level' => env('LOG_LEVEL', 'debug'),
126
+            'replace_placeholders' => true,
127
+        ],
128
+
129
+        'null' => [
130
+            'driver' => 'monolog',
131
+            'handler' => NullHandler::class,
132
+        ],
133
+
134
+        'emergency' => [
135
+            'path' => storage_path('logs/laravel.log'),
136
+        ],
137
+
138
+    ],
139
+
140
+];

+ 118
- 0
config/mail.php Näytä tiedosto

@@ -0,0 +1,118 @@
1
+<?php
2
+
3
+return [
4
+
5
+    /*
6
+    |--------------------------------------------------------------------------
7
+    | Default Mailer
8
+    |--------------------------------------------------------------------------
9
+    |
10
+    | This option controls the default mailer that is used to send all email
11
+    | messages unless another mailer is explicitly specified when sending
12
+    | the message. All additional mailers can be configured within the
13
+    | "mailers" array. Examples of each type of mailer are provided.
14
+    |
15
+    */
16
+
17
+    'default' => env('MAIL_MAILER', 'log'),
18
+
19
+    /*
20
+    |--------------------------------------------------------------------------
21
+    | Mailer Configurations
22
+    |--------------------------------------------------------------------------
23
+    |
24
+    | Here you may configure all of the mailers used by your application plus
25
+    | their respective settings. Several examples have been configured for
26
+    | you and you are free to add your own as your application requires.
27
+    |
28
+    | Laravel supports a variety of mail "transport" drivers that can be used
29
+    | when delivering an email. You may specify which one you're using for
30
+    | your mailers below. You may also add additional mailers if needed.
31
+    |
32
+    | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
33
+    |            "postmark", "resend", "log", "array",
34
+    |            "failover", "roundrobin"
35
+    |
36
+    */
37
+
38
+    'mailers' => [
39
+
40
+        'smtp' => [
41
+            'transport' => 'smtp',
42
+            'scheme' => env('MAIL_SCHEME'),
43
+            'url' => env('MAIL_URL'),
44
+            'host' => env('MAIL_HOST', '127.0.0.1'),
45
+            'port' => env('MAIL_PORT', 2525),
46
+            'username' => env('MAIL_USERNAME'),
47
+            'password' => env('MAIL_PASSWORD'),
48
+            'timeout' => null,
49
+            'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
50
+        ],
51
+
52
+        'ses' => [
53
+            'transport' => 'ses',
54
+        ],
55
+
56
+        'postmark' => [
57
+            'transport' => 'postmark',
58
+            // 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
59
+            // 'client' => [
60
+            //     'timeout' => 5,
61
+            // ],
62
+        ],
63
+
64
+        'resend' => [
65
+            'transport' => 'resend',
66
+        ],
67
+
68
+        'sendmail' => [
69
+            'transport' => 'sendmail',
70
+            'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
71
+        ],
72
+
73
+        'log' => [
74
+            'transport' => 'log',
75
+            'channel' => env('MAIL_LOG_CHANNEL'),
76
+        ],
77
+
78
+        'array' => [
79
+            'transport' => 'array',
80
+        ],
81
+
82
+        'failover' => [
83
+            'transport' => 'failover',
84
+            'mailers' => [
85
+                'smtp',
86
+                'log',
87
+            ],
88
+            'retry_after' => 60,
89
+        ],
90
+
91
+        'roundrobin' => [
92
+            'transport' => 'roundrobin',
93
+            'mailers' => [
94
+                'ses',
95
+                'postmark',
96
+            ],
97
+            'retry_after' => 60,
98
+        ],
99
+
100
+    ],
101
+
102
+    /*
103
+    |--------------------------------------------------------------------------
104
+    | Global "From" Address
105
+    |--------------------------------------------------------------------------
106
+    |
107
+    | You may wish for all emails sent by your application to be sent from
108
+    | the same address. Here you may specify a name and address that is
109
+    | used globally for all emails that are sent by your application.
110
+    |
111
+    */
112
+
113
+    'from' => [
114
+        'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
115
+        'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
116
+    ],
117
+
118
+];

+ 129
- 0
config/queue.php Näytä tiedosto

@@ -0,0 +1,129 @@
1
+<?php
2
+
3
+return [
4
+
5
+    /*
6
+    |--------------------------------------------------------------------------
7
+    | Default Queue Connection Name
8
+    |--------------------------------------------------------------------------
9
+    |
10
+    | Laravel's queue supports a variety of backends via a single, unified
11
+    | API, giving you convenient access to each backend using identical
12
+    | syntax for each. The default queue connection is defined below.
13
+    |
14
+    */
15
+
16
+    'default' => env('QUEUE_CONNECTION', 'database'),
17
+
18
+    /*
19
+    |--------------------------------------------------------------------------
20
+    | Queue Connections
21
+    |--------------------------------------------------------------------------
22
+    |
23
+    | Here you may configure the connection options for every queue backend
24
+    | used by your application. An example configuration is provided for
25
+    | each backend supported by Laravel. You're also free to add more.
26
+    |
27
+    | Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
28
+    |          "deferred", "background", "failover", "null"
29
+    |
30
+    */
31
+
32
+    'connections' => [
33
+
34
+        'sync' => [
35
+            'driver' => 'sync',
36
+        ],
37
+
38
+        'database' => [
39
+            'driver' => 'database',
40
+            'connection' => env('DB_QUEUE_CONNECTION'),
41
+            'table' => env('DB_QUEUE_TABLE', 'jobs'),
42
+            'queue' => env('DB_QUEUE', 'default'),
43
+            'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
44
+            'after_commit' => false,
45
+        ],
46
+
47
+        'beanstalkd' => [
48
+            'driver' => 'beanstalkd',
49
+            'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
50
+            'queue' => env('BEANSTALKD_QUEUE', 'default'),
51
+            'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
52
+            'block_for' => 0,
53
+            'after_commit' => false,
54
+        ],
55
+
56
+        'sqs' => [
57
+            'driver' => 'sqs',
58
+            'key' => env('AWS_ACCESS_KEY_ID'),
59
+            'secret' => env('AWS_SECRET_ACCESS_KEY'),
60
+            'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
61
+            'queue' => env('SQS_QUEUE', 'default'),
62
+            'suffix' => env('SQS_SUFFIX'),
63
+            'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
64
+            'after_commit' => false,
65
+        ],
66
+
67
+        'redis' => [
68
+            'driver' => 'redis',
69
+            'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
70
+            'queue' => env('REDIS_QUEUE', 'default'),
71
+            'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
72
+            'block_for' => null,
73
+            'after_commit' => false,
74
+        ],
75
+
76
+        'deferred' => [
77
+            'driver' => 'deferred',
78
+        ],
79
+
80
+        'background' => [
81
+            'driver' => 'background',
82
+        ],
83
+
84
+        'failover' => [
85
+            'driver' => 'failover',
86
+            'connections' => [
87
+                'database',
88
+                'deferred',
89
+            ],
90
+        ],
91
+
92
+    ],
93
+
94
+    /*
95
+    |--------------------------------------------------------------------------
96
+    | Job Batching
97
+    |--------------------------------------------------------------------------
98
+    |
99
+    | The following options configure the database and table that store job
100
+    | batching information. These options can be updated to any database
101
+    | connection and table which has been defined by your application.
102
+    |
103
+    */
104
+
105
+    'batching' => [
106
+        'database' => env('DB_CONNECTION', 'sqlite'),
107
+        'table' => 'job_batches',
108
+    ],
109
+
110
+    /*
111
+    |--------------------------------------------------------------------------
112
+    | Failed Queue Jobs
113
+    |--------------------------------------------------------------------------
114
+    |
115
+    | These options configure the behavior of failed queue job logging so you
116
+    | can control how and where failed jobs are stored. Laravel ships with
117
+    | support for storing failed jobs in a simple file or in a database.
118
+    |
119
+    | Supported drivers: "database-uuids", "dynamodb", "file", "null"
120
+    |
121
+    */
122
+
123
+    'failed' => [
124
+        'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
125
+        'database' => env('DB_CONNECTION', 'sqlite'),
126
+        'table' => 'failed_jobs',
127
+    ],
128
+
129
+];

+ 38
- 0
config/services.php Näytä tiedosto

@@ -0,0 +1,38 @@
1
+<?php
2
+
3
+return [
4
+
5
+    /*
6
+    |--------------------------------------------------------------------------
7
+    | Third Party Services
8
+    |--------------------------------------------------------------------------
9
+    |
10
+    | This file is for storing the credentials for third party services such
11
+    | as Resend, Postmark, AWS, and more. This file provides the de facto
12
+    | location for this type of information, allowing packages to have
13
+    | a conventional file to locate the various service credentials.
14
+    |
15
+    */
16
+
17
+    'postmark' => [
18
+        'key' => env('POSTMARK_API_KEY'),
19
+    ],
20
+
21
+    'resend' => [
22
+        'key' => env('RESEND_API_KEY'),
23
+    ],
24
+
25
+    'ses' => [
26
+        'key' => env('AWS_ACCESS_KEY_ID'),
27
+        'secret' => env('AWS_SECRET_ACCESS_KEY'),
28
+        'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
29
+    ],
30
+
31
+    'slack' => [
32
+        'notifications' => [
33
+            'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
34
+            'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
35
+        ],
36
+    ],
37
+
38
+];

+ 233
- 0
config/session.php Näytä tiedosto

@@ -0,0 +1,233 @@
1
+<?php
2
+
3
+use Illuminate\Support\Str;
4
+
5
+return [
6
+
7
+    /*
8
+    |--------------------------------------------------------------------------
9
+    | Default Session Driver
10
+    |--------------------------------------------------------------------------
11
+    |
12
+    | This option determines the default session driver that is utilized for
13
+    | incoming requests. Laravel supports a variety of storage options to
14
+    | persist session data. Database storage is a great default choice.
15
+    |
16
+    | Supported: "file", "cookie", "database", "memcached",
17
+    |            "redis", "dynamodb", "array"
18
+    |
19
+    */
20
+
21
+    'driver' => env('SESSION_DRIVER', 'database'),
22
+
23
+    /*
24
+    |--------------------------------------------------------------------------
25
+    | Session Lifetime
26
+    |--------------------------------------------------------------------------
27
+    |
28
+    | Here you may specify the number of minutes that you wish the session
29
+    | to be allowed to remain idle before it expires. If you want them
30
+    | to expire immediately when the browser is closed then you may
31
+    | indicate that via the expire_on_close configuration option.
32
+    |
33
+    */
34
+
35
+    'lifetime' => (int) env('SESSION_LIFETIME', 120),
36
+
37
+    'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
38
+
39
+    /*
40
+    |--------------------------------------------------------------------------
41
+    | Session Encryption
42
+    |--------------------------------------------------------------------------
43
+    |
44
+    | This option allows you to easily specify that all of your session data
45
+    | should be encrypted before it's stored. All encryption is performed
46
+    | automatically by Laravel and you may use the session like normal.
47
+    |
48
+    */
49
+
50
+    'encrypt' => env('SESSION_ENCRYPT', false),
51
+
52
+    /*
53
+    |--------------------------------------------------------------------------
54
+    | Session File Location
55
+    |--------------------------------------------------------------------------
56
+    |
57
+    | When utilizing the "file" session driver, the session files are placed
58
+    | on disk. The default storage location is defined here; however, you
59
+    | are free to provide another location where they should be stored.
60
+    |
61
+    */
62
+
63
+    'files' => storage_path('framework/sessions'),
64
+
65
+    /*
66
+    |--------------------------------------------------------------------------
67
+    | Session Database Connection
68
+    |--------------------------------------------------------------------------
69
+    |
70
+    | When using the "database" or "redis" session drivers, you may specify a
71
+    | connection that should be used to manage these sessions. This should
72
+    | correspond to a connection in your database configuration options.
73
+    |
74
+    */
75
+
76
+    'connection' => env('SESSION_CONNECTION'),
77
+
78
+    /*
79
+    |--------------------------------------------------------------------------
80
+    | Session Database Table
81
+    |--------------------------------------------------------------------------
82
+    |
83
+    | When using the "database" session driver, you may specify the table to
84
+    | be used to store sessions. Of course, a sensible default is defined
85
+    | for you; however, you're welcome to change this to another table.
86
+    |
87
+    */
88
+
89
+    'table' => env('SESSION_TABLE', 'sessions'),
90
+
91
+    /*
92
+    |--------------------------------------------------------------------------
93
+    | Session Cache Store
94
+    |--------------------------------------------------------------------------
95
+    |
96
+    | When using one of the framework's cache driven session backends, you may
97
+    | define the cache store which should be used to store the session data
98
+    | between requests. This must match one of your defined cache stores.
99
+    |
100
+    | Affects: "dynamodb", "memcached", "redis"
101
+    |
102
+    */
103
+
104
+    'store' => env('SESSION_STORE'),
105
+
106
+    /*
107
+    |--------------------------------------------------------------------------
108
+    | Session Sweeping Lottery
109
+    |--------------------------------------------------------------------------
110
+    |
111
+    | Some session drivers must manually sweep their storage location to get
112
+    | rid of old sessions from storage. Here are the chances that it will
113
+    | happen on a given request. By default, the odds are 2 out of 100.
114
+    |
115
+    */
116
+
117
+    'lottery' => [2, 100],
118
+
119
+    /*
120
+    |--------------------------------------------------------------------------
121
+    | Session Cookie Name
122
+    |--------------------------------------------------------------------------
123
+    |
124
+    | Here you may change the name of the session cookie that is created by
125
+    | the framework. Typically, you should not need to change this value
126
+    | since doing so does not grant a meaningful security improvement.
127
+    |
128
+    */
129
+
130
+    'cookie' => env(
131
+        'SESSION_COOKIE',
132
+        Str::slug((string) env('APP_NAME', 'laravel')).'-session',
133
+    ),
134
+
135
+    /*
136
+    |--------------------------------------------------------------------------
137
+    | Session Cookie Path
138
+    |--------------------------------------------------------------------------
139
+    |
140
+    | The session cookie path determines the path for which the cookie will
141
+    | be regarded as available. Typically, this will be the root path of
142
+    | your application, but you're free to change this when necessary.
143
+    |
144
+    */
145
+
146
+    'path' => env('SESSION_PATH', '/'),
147
+
148
+    /*
149
+    |--------------------------------------------------------------------------
150
+    | Session Cookie Domain
151
+    |--------------------------------------------------------------------------
152
+    |
153
+    | This value determines the domain and subdomains the session cookie is
154
+    | available to. By default, the cookie will be available to the root
155
+    | domain without subdomains. Typically, this shouldn't be changed.
156
+    |
157
+    */
158
+
159
+    'domain' => env('SESSION_DOMAIN'),
160
+
161
+    /*
162
+    |--------------------------------------------------------------------------
163
+    | HTTPS Only Cookies
164
+    |--------------------------------------------------------------------------
165
+    |
166
+    | By setting this option to true, session cookies will only be sent back
167
+    | to the server if the browser has a HTTPS connection. This will keep
168
+    | the cookie from being sent to you when it can't be done securely.
169
+    |
170
+    */
171
+
172
+    'secure' => env('SESSION_SECURE_COOKIE'),
173
+
174
+    /*
175
+    |--------------------------------------------------------------------------
176
+    | HTTP Access Only
177
+    |--------------------------------------------------------------------------
178
+    |
179
+    | Setting this value to true will prevent JavaScript from accessing the
180
+    | value of the cookie and the cookie will only be accessible through
181
+    | the HTTP protocol. It's unlikely you should disable this option.
182
+    |
183
+    */
184
+
185
+    'http_only' => env('SESSION_HTTP_ONLY', true),
186
+
187
+    /*
188
+    |--------------------------------------------------------------------------
189
+    | Same-Site Cookies
190
+    |--------------------------------------------------------------------------
191
+    |
192
+    | This option determines how your cookies behave when cross-site requests
193
+    | take place, and can be used to mitigate CSRF attacks. By default, we
194
+    | will set this value to "lax" to permit secure cross-site requests.
195
+    |
196
+    | See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
197
+    |
198
+    | Supported: "lax", "strict", "none", null
199
+    |
200
+    */
201
+
202
+    'same_site' => env('SESSION_SAME_SITE', 'lax'),
203
+
204
+    /*
205
+    |--------------------------------------------------------------------------
206
+    | Partitioned Cookies
207
+    |--------------------------------------------------------------------------
208
+    |
209
+    | Setting this value to true will tie the cookie to the top-level site for
210
+    | a cross-site context. Partitioned cookies are accepted by the browser
211
+    | when flagged "secure" and the Same-Site attribute is set to "none".
212
+    |
213
+    */
214
+
215
+    'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
216
+
217
+    /*
218
+    |--------------------------------------------------------------------------
219
+    | Session Serialization
220
+    |--------------------------------------------------------------------------
221
+    |
222
+    | This value controls the serialization strategy for session data, which
223
+    | is JSON by default. Setting this to "php" allows the storage of PHP
224
+    | objects in the session but can make an application vulnerable to
225
+    | "gadget chain" serialization attacks if the APP_KEY is leaked.
226
+    |
227
+    | Supported: "json", "php"
228
+    |
229
+    */
230
+
231
+    'serialization' => 'json',
232
+
233
+];

+ 1
- 0
database/.gitignore Näytä tiedosto

@@ -0,0 +1 @@
1
+*.sqlite*

+ 30
- 0
database/factories/StoreFactory.php Näytä tiedosto

@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+namespace Database\Factories;
4
+
5
+use App\Enums\StoreCategory;
6
+use App\Models\Store;
7
+use App\Models\User;
8
+use Illuminate\Database\Eloquent\Factories\Factory;
9
+
10
+/**
11
+ * @extends Factory<Store>
12
+ */
13
+class StoreFactory extends Factory
14
+{
15
+    /**
16
+     * Define the model's default state.
17
+     *
18
+     * @return array<string, mixed>
19
+     */
20
+    public function definition(): array
21
+    {
22
+        return [
23
+            'user_id' => User::factory(),
24
+            'name' => fake()->unique()->company(),
25
+            'category' => fake()->randomElement(StoreCategory::cases()),
26
+            'description' => fake()->paragraph(),
27
+            'language' => 'en',
28
+        ];
29
+    }
30
+}

+ 60
- 0
database/factories/UserFactory.php Näytä tiedosto

@@ -0,0 +1,60 @@
1
+<?php
2
+
3
+namespace Database\Factories;
4
+
5
+use App\Models\User;
6
+use Illuminate\Database\Eloquent\Factories\Factory;
7
+use Illuminate\Support\Facades\Hash;
8
+use Illuminate\Support\Str;
9
+
10
+/**
11
+ * @extends Factory<User>
12
+ */
13
+class UserFactory extends Factory
14
+{
15
+    /**
16
+     * The current password being used by the factory.
17
+     */
18
+    protected static ?string $password;
19
+
20
+    /**
21
+     * Define the model's default state.
22
+     *
23
+     * @return array<string, mixed>
24
+     */
25
+    public function definition(): array
26
+    {
27
+        return [
28
+            'name' => fake()->name(),
29
+            'email' => fake()->unique()->safeEmail(),
30
+            'email_verified_at' => now(),
31
+            'password' => static::$password ??= Hash::make('password'),
32
+            'remember_token' => Str::random(10),
33
+            'two_factor_secret' => null,
34
+            'two_factor_recovery_codes' => null,
35
+            'two_factor_confirmed_at' => null,
36
+        ];
37
+    }
38
+
39
+    /**
40
+     * Indicate that the model's email address should be unverified.
41
+     */
42
+    public function unverified(): static
43
+    {
44
+        return $this->state(fn (array $attributes) => [
45
+            'email_verified_at' => null,
46
+        ]);
47
+    }
48
+
49
+    /**
50
+     * Indicate that the model has two-factor authentication configured.
51
+     */
52
+    public function withTwoFactor(): static
53
+    {
54
+        return $this->state(fn (array $attributes) => [
55
+            'two_factor_secret' => encrypt('secret'),
56
+            'two_factor_recovery_codes' => encrypt(json_encode(['recovery-code-1'])),
57
+            'two_factor_confirmed_at' => now(),
58
+        ]);
59
+    }
60
+}

+ 49
- 0
database/migrations/0001_01_01_000000_create_users_table.php Näytä tiedosto

@@ -0,0 +1,49 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     */
12
+    public function up(): void
13
+    {
14
+        Schema::create('users', function (Blueprint $table) {
15
+            $table->id();
16
+            $table->string('name');
17
+            $table->string('email')->unique();
18
+            $table->timestamp('email_verified_at')->nullable();
19
+            $table->string('password');
20
+            $table->rememberToken();
21
+            $table->timestamps();
22
+        });
23
+
24
+        Schema::create('password_reset_tokens', function (Blueprint $table) {
25
+            $table->string('email')->primary();
26
+            $table->string('token');
27
+            $table->timestamp('created_at')->nullable();
28
+        });
29
+
30
+        Schema::create('sessions', function (Blueprint $table) {
31
+            $table->string('id')->primary();
32
+            $table->foreignId('user_id')->nullable()->index();
33
+            $table->string('ip_address', 45)->nullable();
34
+            $table->text('user_agent')->nullable();
35
+            $table->longText('payload');
36
+            $table->integer('last_activity')->index();
37
+        });
38
+    }
39
+
40
+    /**
41
+     * Reverse the migrations.
42
+     */
43
+    public function down(): void
44
+    {
45
+        Schema::dropIfExists('users');
46
+        Schema::dropIfExists('password_reset_tokens');
47
+        Schema::dropIfExists('sessions');
48
+    }
49
+};

+ 35
- 0
database/migrations/0001_01_01_000001_create_cache_table.php Näytä tiedosto

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     */
12
+    public function up(): void
13
+    {
14
+        Schema::create('cache', function (Blueprint $table) {
15
+            $table->string('key')->primary();
16
+            $table->mediumText('value');
17
+            $table->bigInteger('expiration')->index();
18
+        });
19
+
20
+        Schema::create('cache_locks', function (Blueprint $table) {
21
+            $table->string('key')->primary();
22
+            $table->string('owner');
23
+            $table->bigInteger('expiration')->index();
24
+        });
25
+    }
26
+
27
+    /**
28
+     * Reverse the migrations.
29
+     */
30
+    public function down(): void
31
+    {
32
+        Schema::dropIfExists('cache');
33
+        Schema::dropIfExists('cache_locks');
34
+    }
35
+};

+ 59
- 0
database/migrations/0001_01_01_000002_create_jobs_table.php Näytä tiedosto

@@ -0,0 +1,59 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     */
12
+    public function up(): void
13
+    {
14
+        Schema::create('jobs', function (Blueprint $table) {
15
+            $table->id();
16
+            $table->string('queue')->index();
17
+            $table->longText('payload');
18
+            $table->unsignedSmallInteger('attempts');
19
+            $table->unsignedInteger('reserved_at')->nullable();
20
+            $table->unsignedInteger('available_at');
21
+            $table->unsignedInteger('created_at');
22
+        });
23
+
24
+        Schema::create('job_batches', function (Blueprint $table) {
25
+            $table->string('id')->primary();
26
+            $table->string('name');
27
+            $table->integer('total_jobs');
28
+            $table->integer('pending_jobs');
29
+            $table->integer('failed_jobs');
30
+            $table->longText('failed_job_ids');
31
+            $table->mediumText('options')->nullable();
32
+            $table->integer('cancelled_at')->nullable();
33
+            $table->integer('created_at');
34
+            $table->integer('finished_at')->nullable();
35
+        });
36
+
37
+        Schema::create('failed_jobs', function (Blueprint $table) {
38
+            $table->id();
39
+            $table->string('uuid')->unique();
40
+            $table->string('connection');
41
+            $table->string('queue');
42
+            $table->longText('payload');
43
+            $table->longText('exception');
44
+            $table->timestamp('failed_at')->useCurrent();
45
+
46
+            $table->index(['connection', 'queue', 'failed_at']);
47
+        });
48
+    }
49
+
50
+    /**
51
+     * Reverse the migrations.
52
+     */
53
+    public function down(): void
54
+    {
55
+        Schema::dropIfExists('jobs');
56
+        Schema::dropIfExists('job_batches');
57
+        Schema::dropIfExists('failed_jobs');
58
+    }
59
+};

+ 34
- 0
database/migrations/2025_08_14_170933_add_two_factor_columns_to_users_table.php Näytä tiedosto

@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     */
12
+    public function up(): void
13
+    {
14
+        Schema::table('users', function (Blueprint $table) {
15
+            $table->text('two_factor_secret')->after('password')->nullable();
16
+            $table->text('two_factor_recovery_codes')->after('two_factor_secret')->nullable();
17
+            $table->timestamp('two_factor_confirmed_at')->after('two_factor_recovery_codes')->nullable();
18
+        });
19
+    }
20
+
21
+    /**
22
+     * Reverse the migrations.
23
+     */
24
+    public function down(): void
25
+    {
26
+        Schema::table('users', function (Blueprint $table) {
27
+            $table->dropColumn([
28
+                'two_factor_secret',
29
+                'two_factor_recovery_codes',
30
+                'two_factor_confirmed_at',
31
+            ]);
32
+        });
33
+    }
34
+};

+ 34
- 0
database/migrations/2026_11_14_000000_create_stores_table.php Näytä tiedosto

@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     */
12
+    public function up(): void
13
+    {
14
+        Schema::create('stores', function (Blueprint $table) {
15
+            $table->id();
16
+            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
17
+            $table->string('name');
18
+            $table->string('slug')->unique();
19
+            $table->string('category');
20
+            $table->text('description');
21
+            $table->string('language', 5)->default('en');
22
+            $table->string('status')->default('draft');
23
+            $table->timestamps();
24
+        });
25
+    }
26
+
27
+    /**
28
+     * Reverse the migrations.
29
+     */
30
+    public function down(): void
31
+    {
32
+        Schema::dropIfExists('stores');
33
+    }
34
+};

+ 28
- 0
database/migrations/2026_11_14_000001_add_plan_to_stores_table.php Näytä tiedosto

@@ -0,0 +1,28 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     */
12
+    public function up(): void
13
+    {
14
+        Schema::table('stores', function (Blueprint $table) {
15
+            $table->json('plan')->nullable()->after('status');
16
+        });
17
+    }
18
+
19
+    /**
20
+     * Reverse the migrations.
21
+     */
22
+    public function down(): void
23
+    {
24
+        Schema::table('stores', function (Blueprint $table) {
25
+            $table->dropColumn('plan');
26
+        });
27
+    }
28
+};

+ 25
- 0
database/seeders/DatabaseSeeder.php Näytä tiedosto

@@ -0,0 +1,25 @@
1
+<?php
2
+
3
+namespace Database\Seeders;
4
+
5
+use App\Models\User;
6
+use Illuminate\Database\Console\Seeds\WithoutModelEvents;
7
+use Illuminate\Database\Seeder;
8
+
9
+class DatabaseSeeder extends Seeder
10
+{
11
+    use WithoutModelEvents;
12
+
13
+    /**
14
+     * Seed the application's database.
15
+     */
16
+    public function run(): void
17
+    {
18
+        // User::factory(10)->create();
19
+
20
+        User::factory()->create([
21
+            'name' => 'Test User',
22
+            'email' => 'test@example.com',
23
+        ]);
24
+    }
25
+}

+ 6283
- 0
package-lock.json
File diff suppressed because it is too large
Näytä tiedosto


+ 67
- 0
package.json Näytä tiedosto

@@ -0,0 +1,67 @@
1
+{
2
+    "$schema": "https://www.schemastore.org/package.json",
3
+    "private": true,
4
+    "type": "module",
5
+    "scripts": {
6
+        "build": "vp build",
7
+        "build:ssr": "vp build && vp build --ssr",
8
+        "dev": "vp dev",
9
+        "check": "vp check",
10
+        "check:fix": "vp check --fix",
11
+        "types:check": "tsc --noEmit"
12
+    },
13
+    "dependencies": {
14
+        "@inertiajs/react": "^3.0.0",
15
+        "@inertiajs/vite": "^3.0.0",
16
+        "@radix-ui/react-avatar": "^1.1.3",
17
+        "@radix-ui/react-checkbox": "^1.1.4",
18
+        "@radix-ui/react-collapsible": "^1.1.3",
19
+        "@radix-ui/react-dialog": "^1.1.6",
20
+        "@radix-ui/react-dropdown-menu": "^2.1.6",
21
+        "@radix-ui/react-label": "^2.1.2",
22
+        "@radix-ui/react-navigation-menu": "^1.2.5",
23
+        "@radix-ui/react-select": "^2.1.6",
24
+        "@radix-ui/react-separator": "^1.1.2",
25
+        "@radix-ui/react-slot": "^1.2.3",
26
+        "@radix-ui/react-toggle": "^1.1.2",
27
+        "@radix-ui/react-toggle-group": "^1.1.2",
28
+        "@radix-ui/react-tooltip": "^1.1.8",
29
+        "@tailwindcss/vite": "^4.1.11",
30
+        "@types/react": "^19.2.0",
31
+        "@types/react-dom": "^19.2.0",
32
+        "@vitejs/plugin-react": "^6.1.1",
33
+        "class-variance-authority": "^0.7.1",
34
+        "clsx": "^2.1.1",
35
+        "concurrently": "^10.0.3",
36
+        "input-otp": "^1.4.2",
37
+        "laravel-vite-plugin": "^3.0.0",
38
+        "lucide-react": "^0.475.0",
39
+        "react": "^19.2.0",
40
+        "react-dom": "^19.2.0",
41
+        "sonner": "^2.0.0",
42
+        "tailwind-merge": "^3.0.1",
43
+        "tailwindcss": "^4.0.0",
44
+        "tw-animate-css": "^1.4.0",
45
+        "typescript": "^5.7.2",
46
+        "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0"
47
+    },
48
+    "devDependencies": {
49
+        "@laravel/vite-plugin-wayfinder": "^0.1.3",
50
+        "@rolldown/plugin-babel": "^0.2.3",
51
+        "@types/node": "^22.13.5",
52
+        "babel-plugin-react-compiler": "^1.0.0",
53
+        "vite-plus": "1.4.0"
54
+    },
55
+    "optionalDependencies": {
56
+        "@laravel/multiplex": "^0.4.1",
57
+        "@rollup/rollup-linux-x64-gnu": "4.9.5",
58
+        "@rollup/rollup-win32-x64-msvc": "4.9.5",
59
+        "@tailwindcss/oxide-linux-x64-gnu": "^4.0.1",
60
+        "@tailwindcss/oxide-win32-x64-msvc": "^4.0.1",
61
+        "lightningcss-linux-x64-gnu": "^1.29.1",
62
+        "lightningcss-win32-x64-msvc": "^1.29.1"
63
+    },
64
+    "overrides": {
65
+        "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0"
66
+    }
67
+}

+ 13
- 0
phpstan.neon Näytä tiedosto

@@ -0,0 +1,13 @@
1
+includes:
2
+    - vendor/larastan/larastan/extension.neon
3
+    - vendor/nesbot/carbon/extension.neon
4
+
5
+parameters:
6
+    paths:
7
+        - app/
8
+        - bootstrap/app.php
9
+        - config/
10
+        - database/
11
+        - routes/
12
+
13
+    level: 7

+ 36
- 0
phpunit.xml Näytä tiedosto

@@ -0,0 +1,36 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+         xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4
+         bootstrap="vendor/autoload.php"
5
+         colors="true"
6
+>
7
+    <testsuites>
8
+        <testsuite name="Unit">
9
+            <directory>tests/Unit</directory>
10
+        </testsuite>
11
+        <testsuite name="Feature">
12
+            <directory>tests/Feature</directory>
13
+        </testsuite>
14
+    </testsuites>
15
+    <source>
16
+        <include>
17
+            <directory>app</directory>
18
+        </include>
19
+    </source>
20
+    <php>
21
+        <env name="APP_ENV" value="testing"/>
22
+        <env name="APP_MAINTENANCE_DRIVER" value="file"/>
23
+        <env name="BCRYPT_ROUNDS" value="4"/>
24
+        <env name="BROADCAST_CONNECTION" value="null"/>
25
+        <env name="CACHE_STORE" value="array"/>
26
+        <env name="DB_CONNECTION" value="sqlite"/>
27
+        <env name="DB_DATABASE" value=":memory:"/>
28
+        <env name="DB_URL" value=""/>
29
+        <env name="MAIL_MAILER" value="array"/>
30
+        <env name="QUEUE_CONNECTION" value="sync"/>
31
+        <env name="SESSION_DRIVER" value="array"/>
32
+        <env name="PULSE_ENABLED" value="false"/>
33
+        <env name="TELESCOPE_ENABLED" value="false"/>
34
+        <env name="NIGHTWATCH_ENABLED" value="false"/>
35
+    </php>
36
+</phpunit>

+ 3
- 0
pint.json Näytä tiedosto

@@ -0,0 +1,3 @@
1
+{
2
+    "preset": "laravel"
3
+}

+ 5
- 0
pnpm-workspace.yaml Näytä tiedosto

@@ -0,0 +1,5 @@
1
+packages:
2
+    - '.'
3
+
4
+publicHoistPattern:
5
+    - '@inertiajs/core'

+ 25
- 0
public/.htaccess Näytä tiedosto

@@ -0,0 +1,25 @@
1
+<IfModule mod_rewrite.c>
2
+    <IfModule mod_negotiation.c>
3
+        Options -MultiViews -Indexes
4
+    </IfModule>
5
+
6
+    RewriteEngine On
7
+
8
+    # Handle Authorization Header
9
+    RewriteCond %{HTTP:Authorization} .
10
+    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
11
+
12
+    # Handle X-XSRF-Token Header
13
+    RewriteCond %{HTTP:x-xsrf-token} .
14
+    RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
15
+
16
+    # Redirect Trailing Slashes If Not A Folder...
17
+    RewriteCond %{REQUEST_FILENAME} !-d
18
+    RewriteCond %{REQUEST_URI} (.+)/$
19
+    RewriteRule ^ %1 [L,R=308]
20
+
21
+    # Send Requests To Front Controller...
22
+    RewriteCond %{REQUEST_FILENAME} !-d
23
+    RewriteCond %{REQUEST_FILENAME} !-f
24
+    RewriteRule ^ index.php [L]
25
+</IfModule>

BIN
public/apple-touch-icon.png Näytä tiedosto


BIN
public/favicon.ico Näytä tiedosto


+ 3
- 0
public/favicon.svg Näytä tiedosto

@@ -0,0 +1,3 @@
1
+<svg width="166" height="166" viewBox="0 0 166 166" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+<path fill-rule="evenodd" clip-rule="evenodd" d="M162.041 38.7592C162.099 38.9767 162.129 39.201 162.13 39.4264V74.4524C162.13 74.9019 162.011 75.3435 161.786 75.7325C161.561 76.1216 161.237 76.4442 160.847 76.6678L131.462 93.5935V127.141C131.462 128.054 130.977 128.897 130.186 129.357L68.8474 164.683C68.707 164.763 68.5538 164.814 68.4007 164.868C68.3432 164.887 68.289 164.922 68.2284 164.938C67.7996 165.051 67.3489 165.051 66.9201 164.938C66.8499 164.919 66.7861 164.881 66.7191 164.855C66.5787 164.804 66.4319 164.76 66.2979 164.683L4.97219 129.357C4.58261 129.133 4.2589 128.81 4.0337 128.421C3.8085 128.032 3.68976 127.591 3.68945 127.141L3.68945 22.0634C3.68945 21.8336 3.72136 21.6101 3.7788 21.393C3.79794 21.3196 3.84262 21.2526 3.86814 21.1791C3.91601 21.0451 3.96068 20.9078 4.03088 20.7833C4.07874 20.7003 4.14894 20.6333 4.20638 20.5566C4.27977 20.4545 4.34678 20.3491 4.43293 20.2598C4.50632 20.1863 4.60205 20.1321 4.68501 20.0682C4.77755 19.9916 4.86051 19.9086 4.96581 19.848L35.6334 2.18492C36.0217 1.96139 36.4618 1.84375 36.9098 1.84375C37.3578 1.84375 37.7979 1.96139 38.1862 2.18492L68.8506 19.848H68.857C68.9591 19.9118 69.0452 19.9916 69.1378 20.065C69.2207 20.1289 69.3133 20.1863 69.3867 20.2566C69.476 20.3491 69.5398 20.4545 69.6164 20.5566C69.6707 20.6333 69.7441 20.7003 69.7887 20.7833C69.8621 20.911 69.9036 21.0451 69.9546 21.1791C69.9802 21.2526 70.0248 21.3196 70.044 21.3962C70.1027 21.6138 70.1328 21.8381 70.1333 22.0634V87.6941L95.686 72.9743V39.4232C95.686 39.1997 95.7179 38.9731 95.7753 38.7592C95.7977 38.6826 95.8391 38.6155 95.8647 38.5421C95.9157 38.408 95.9604 38.2708 96.0306 38.1463C96.0785 38.0633 96.1487 37.9962 96.2029 37.9196C96.2795 37.8175 96.3433 37.7121 96.4326 37.6227C96.506 37.5493 96.5986 37.495 96.6815 37.4312C96.7773 37.3546 96.8602 37.2716 96.9623 37.2109L127.633 19.5479C128.021 19.324 128.461 19.2062 128.91 19.2062C129.358 19.2062 129.798 19.324 130.186 19.5479L160.85 37.2109C160.959 37.2748 161.042 37.3546 161.137 37.428C161.217 37.4918 161.31 37.5493 161.383 37.6195C161.473 37.7121 161.536 37.8175 161.613 37.9196C161.67 37.9962 161.741 38.0633 161.785 38.1463C161.859 38.2708 161.9 38.408 161.951 38.5421C161.98 38.6155 162.021 38.6826 162.041 38.7592ZM157.018 72.9743V43.8477L146.287 50.028L131.462 58.5675V87.6941L157.021 72.9743H157.018ZM126.354 125.663V96.5176L111.771 104.85L70.1301 128.626V158.046L126.354 125.663ZM8.80126 26.4848V125.663L65.0183 158.043V128.629L35.6494 112L35.6398 111.994L35.6271 111.988C35.5281 111.93 35.4452 111.847 35.3526 111.777C35.2729 111.713 35.1803 111.662 35.1101 111.592L35.1038 111.582C35.0208 111.502 34.9634 111.403 34.8932 111.314C34.8293 111.228 34.7528 111.154 34.7017 111.065L34.6985 111.055C34.6411 110.96 34.606 110.845 34.5645 110.736C34.523 110.64 34.4688 110.551 34.4432 110.449C34.4113 110.328 34.4049 110.197 34.3922 110.072C34.3794 109.976 34.3539 109.881 34.3539 109.785V109.778V41.2045L19.5322 32.6619L8.80126 26.4848ZM36.913 7.35007L11.3635 22.0634L36.9066 36.7768L62.4529 22.0602L36.9066 7.35007H36.913ZM50.1999 99.1736L65.0215 90.6374V26.4848L54.2906 32.6651L39.4657 41.2045V105.357L50.1999 99.1736ZM128.91 24.713L103.363 39.4264L128.91 54.1397L154.453 39.4232L128.91 24.713ZM126.354 58.5675L111.529 50.028L100.798 43.8477V72.9743L115.619 81.5106L126.354 87.6941V58.5675ZM67.5711 124.205L105.042 102.803L123.772 92.109L98.2451 77.4053L68.8538 94.3341L42.0663 109.762L67.5711 124.205Z" fill="#FF2D20"/>
3
+</svg>

+ 20
- 0
public/index.php Näytä tiedosto

@@ -0,0 +1,20 @@
1
+<?php
2
+
3
+use Illuminate\Foundation\Application;
4
+use Illuminate\Http\Request;
5
+
6
+define('LARAVEL_START', microtime(true));
7
+
8
+// Determine if the application is in maintenance mode...
9
+if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
10
+    require $maintenance;
11
+}
12
+
13
+// Register the Composer autoloader...
14
+require __DIR__.'/../vendor/autoload.php';
15
+
16
+// Bootstrap Laravel and handle the request...
17
+/** @var Application $app */
18
+$app = require_once __DIR__.'/../bootstrap/app.php';
19
+
20
+$app->handleRequest(Request::capture());

+ 2
- 0
public/robots.txt Näytä tiedosto

@@ -0,0 +1,2 @@
1
+User-agent: *
2
+Disallow:

+ 160
- 0
resources/css/app.css Näytä tiedosto

@@ -0,0 +1,160 @@
1
+@import 'tailwindcss';
2
+
3
+@import 'tw-animate-css';
4
+
5
+@source '../views';
6
+@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
7
+
8
+@custom-variant dark (&:is(.dark *));
9
+
10
+@theme {
11
+    --font-sans:
12
+        'Instrument Sans', ui-sans-serif, system-ui, sans-serif,
13
+        'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
14
+        'Noto Color Emoji';
15
+
16
+    --radius-lg: var(--radius);
17
+    --radius-md: calc(var(--radius) - 2px);
18
+    --radius-sm: calc(var(--radius) - 4px);
19
+
20
+    --color-background: var(--background);
21
+    --color-foreground: var(--foreground);
22
+
23
+    --color-card: var(--card);
24
+    --color-card-foreground: var(--card-foreground);
25
+
26
+    --color-popover: var(--popover);
27
+    --color-popover-foreground: var(--popover-foreground);
28
+
29
+    --color-primary: var(--primary);
30
+    --color-primary-foreground: var(--primary-foreground);
31
+
32
+    --color-secondary: var(--secondary);
33
+    --color-secondary-foreground: var(--secondary-foreground);
34
+
35
+    --color-muted: var(--muted);
36
+    --color-muted-foreground: var(--muted-foreground);
37
+
38
+    --color-accent: var(--accent);
39
+    --color-accent-foreground: var(--accent-foreground);
40
+
41
+    --color-destructive: var(--destructive);
42
+    --color-destructive-foreground: var(--destructive-foreground);
43
+
44
+    --color-border: var(--border);
45
+    --color-input: var(--input);
46
+    --color-ring: var(--ring);
47
+
48
+    --color-chart-1: var(--chart-1);
49
+    --color-chart-2: var(--chart-2);
50
+    --color-chart-3: var(--chart-3);
51
+    --color-chart-4: var(--chart-4);
52
+    --color-chart-5: var(--chart-5);
53
+
54
+    --color-sidebar: var(--sidebar);
55
+    --color-sidebar-foreground: var(--sidebar-foreground);
56
+    --color-sidebar-primary: var(--sidebar-primary);
57
+    --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
58
+    --color-sidebar-accent: var(--sidebar-accent);
59
+    --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
60
+    --color-sidebar-border: var(--sidebar-border);
61
+    --color-sidebar-ring: var(--sidebar-ring);
62
+}
63
+
64
+:root {
65
+    --background: oklch(1 0 0);
66
+    --foreground: oklch(0.145 0 0);
67
+    --card: oklch(1 0 0);
68
+    --card-foreground: oklch(0.145 0 0);
69
+    --popover: oklch(1 0 0);
70
+    --popover-foreground: oklch(0.145 0 0);
71
+    --primary: oklch(0.205 0 0);
72
+    --primary-foreground: oklch(0.985 0 0);
73
+    --secondary: oklch(0.97 0 0);
74
+    --secondary-foreground: oklch(0.205 0 0);
75
+    --muted: oklch(0.97 0 0);
76
+    --muted-foreground: oklch(0.556 0 0);
77
+    --accent: oklch(0.97 0 0);
78
+    --accent-foreground: oklch(0.205 0 0);
79
+    --destructive: oklch(0.577 0.245 27.325);
80
+    --destructive-foreground: oklch(0.577 0.245 27.325);
81
+    --border: oklch(0.922 0 0);
82
+    --input: oklch(0.922 0 0);
83
+    --ring: oklch(0.87 0 0);
84
+    --chart-1: oklch(0.646 0.222 41.116);
85
+    --chart-2: oklch(0.6 0.118 184.704);
86
+    --chart-3: oklch(0.398 0.07 227.392);
87
+    --chart-4: oklch(0.828 0.189 84.429);
88
+    --chart-5: oklch(0.769 0.188 70.08);
89
+    --radius: 0.625rem;
90
+    --sidebar: oklch(0.985 0 0);
91
+    --sidebar-foreground: oklch(0.145 0 0);
92
+    --sidebar-primary: oklch(0.205 0 0);
93
+    --sidebar-primary-foreground: oklch(0.985 0 0);
94
+    --sidebar-accent: oklch(0.97 0 0);
95
+    --sidebar-accent-foreground: oklch(0.205 0 0);
96
+    --sidebar-border: oklch(0.922 0 0);
97
+    --sidebar-ring: oklch(0.87 0 0);
98
+}
99
+
100
+.dark {
101
+    --background: oklch(0.145 0 0);
102
+    --foreground: oklch(0.985 0 0);
103
+    --card: oklch(0.145 0 0);
104
+    --card-foreground: oklch(0.985 0 0);
105
+    --popover: oklch(0.145 0 0);
106
+    --popover-foreground: oklch(0.985 0 0);
107
+    --primary: oklch(0.985 0 0);
108
+    --primary-foreground: oklch(0.205 0 0);
109
+    --secondary: oklch(0.269 0 0);
110
+    --secondary-foreground: oklch(0.985 0 0);
111
+    --muted: oklch(0.269 0 0);
112
+    --muted-foreground: oklch(0.708 0 0);
113
+    --accent: oklch(0.269 0 0);
114
+    --accent-foreground: oklch(0.985 0 0);
115
+    --destructive: oklch(0.396 0.141 25.723);
116
+    --destructive-foreground: oklch(0.637 0.237 25.331);
117
+    --border: oklch(0.269 0 0);
118
+    --input: oklch(0.269 0 0);
119
+    --ring: oklch(0.439 0 0);
120
+    --chart-1: oklch(0.488 0.243 264.376);
121
+    --chart-2: oklch(0.696 0.17 162.48);
122
+    --chart-3: oklch(0.769 0.188 70.08);
123
+    --chart-4: oklch(0.627 0.265 303.9);
124
+    --chart-5: oklch(0.645 0.246 16.439);
125
+    --sidebar: oklch(0.205 0 0);
126
+    --sidebar-foreground: oklch(0.985 0 0);
127
+    --sidebar-primary: oklch(0.985 0 0);
128
+    --sidebar-primary-foreground: oklch(0.985 0 0);
129
+    --sidebar-accent: oklch(0.269 0 0);
130
+    --sidebar-accent-foreground: oklch(0.985 0 0);
131
+    --sidebar-border: oklch(0.269 0 0);
132
+    --sidebar-ring: oklch(0.439 0 0);
133
+}
134
+
135
+@layer base {
136
+    * {
137
+        @apply border-border outline-ring/50;
138
+    }
139
+
140
+    body {
141
+        @apply bg-background text-foreground;
142
+    }
143
+}
144
+
145
+/*
146
+ * Storefront. Colours, fonts and corner radius come from the store plan as
147
+ * --sf-* variables (see resources/js/storefront/theme.ts), so a storefront
148
+ * never picks up the dashboard's light or dark theme.
149
+ */
150
+.sf-root {
151
+    background-color: var(--sf-bg);
152
+    color: var(--sf-fg);
153
+    font-family: var(--sf-font-body);
154
+    scroll-behavior: smooth;
155
+}
156
+
157
+.sf-heading {
158
+    font-family: var(--sf-font-heading);
159
+    letter-spacing: -0.015em;
160
+}

+ 42
- 0
resources/js/app.tsx Näytä tiedosto

@@ -0,0 +1,42 @@
1
+import { createInertiaApp } from '@inertiajs/react';
2
+import { Toaster } from '@/components/ui/sonner';
3
+import { TooltipProvider } from '@/components/ui/tooltip';
4
+import { initializeTheme } from '@/hooks/use-appearance';
5
+import AppLayout from '@/layouts/app-layout';
6
+import AuthLayout from '@/layouts/auth-layout';
7
+import SettingsLayout from '@/layouts/settings/layout';
8
+
9
+const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
10
+
11
+void createInertiaApp({
12
+    title: (title) => (title ? `${title} - ${appName}` : appName),
13
+    layout: (name) => {
14
+        switch (true) {
15
+            case name === 'welcome':
16
+            case name === 'stores/preview':
17
+                // Full pages with no dashboard around them.
18
+                return null;
19
+            case name.startsWith('auth/'):
20
+                return AuthLayout;
21
+            case name.startsWith('settings/'):
22
+                return [AppLayout, SettingsLayout];
23
+            default:
24
+                return AppLayout;
25
+        }
26
+    },
27
+    strictMode: true,
28
+    withApp(app) {
29
+        return (
30
+            <TooltipProvider delayDuration={0}>
31
+                {app}
32
+                <Toaster />
33
+            </TooltipProvider>
34
+        );
35
+    },
36
+    progress: {
37
+        color: '#4B5563',
38
+    },
39
+});
40
+
41
+// This will set light / dark mode on load...
42
+initializeTheme();

+ 24
- 0
resources/js/components/alert-error.tsx Näytä tiedosto

@@ -0,0 +1,24 @@
1
+import { AlertCircleIcon } from 'lucide-react';
2
+import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
3
+
4
+export default function AlertError({
5
+    errors,
6
+    title,
7
+}: {
8
+    errors: string[];
9
+    title?: string;
10
+}) {
11
+    return (
12
+        <Alert variant="destructive">
13
+            <AlertCircleIcon />
14
+            <AlertTitle>{title || 'Something went wrong.'}</AlertTitle>
15
+            <AlertDescription>
16
+                <ul className="list-inside list-disc text-sm">
17
+                    {Array.from(new Set(errors)).map((error, index) => (
18
+                        <li key={index}>{error}</li>
19
+                    ))}
20
+                </ul>
21
+            </AlertDescription>
22
+        </Alert>
23
+    );
24
+}

+ 22
- 0
resources/js/components/app-content.tsx Näytä tiedosto

@@ -0,0 +1,22 @@
1
+import * as React from 'react';
2
+import { SidebarInset } from '@/components/ui/sidebar';
3
+import type { AppVariant } from '@/types';
4
+
5
+type Props = React.ComponentProps<'main'> & {
6
+    variant?: AppVariant;
7
+};
8
+
9
+export function AppContent({ variant = 'sidebar', children, ...props }: Props) {
10
+    if (variant === 'sidebar') {
11
+        return <SidebarInset {...props}>{children}</SidebarInset>;
12
+    }
13
+
14
+    return (
15
+        <main
16
+            className="mx-auto flex h-full w-full max-w-7xl flex-1 flex-col gap-4 rounded-xl"
17
+            {...props}
18
+        >
19
+            {children}
20
+        </main>
21
+    );
22
+}

+ 248
- 0
resources/js/components/app-header.tsx Näytä tiedosto

@@ -0,0 +1,248 @@
1
+import { Link, usePage } from '@inertiajs/react';
2
+import { BookOpen, Folder, LayoutGrid, Menu, Search } from 'lucide-react';
3
+import AppLogo from '@/components/app-logo';
4
+import AppLogoIcon from '@/components/app-logo-icon';
5
+import { Breadcrumbs } from '@/components/breadcrumbs';
6
+import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
7
+import { Button } from '@/components/ui/button';
8
+import {
9
+    DropdownMenu,
10
+    DropdownMenuContent,
11
+    DropdownMenuTrigger,
12
+} from '@/components/ui/dropdown-menu';
13
+import {
14
+    NavigationMenu,
15
+    NavigationMenuItem,
16
+    NavigationMenuList,
17
+    navigationMenuTriggerStyle,
18
+} from '@/components/ui/navigation-menu';
19
+import {
20
+    Sheet,
21
+    SheetContent,
22
+    SheetHeader,
23
+    SheetTitle,
24
+    SheetTrigger,
25
+} from '@/components/ui/sheet';
26
+import {
27
+    Tooltip,
28
+    TooltipContent,
29
+    TooltipTrigger,
30
+} from '@/components/ui/tooltip';
31
+import { UserMenuContent } from '@/components/user-menu-content';
32
+import { useCurrentUrl } from '@/hooks/use-current-url';
33
+import { useInitials } from '@/hooks/use-initials';
34
+import { cn, toUrl } from '@/lib/utils';
35
+import { dashboard } from '@/routes';
36
+import type { BreadcrumbItem, NavItem } from '@/types';
37
+
38
+type Props = {
39
+    breadcrumbs?: BreadcrumbItem[];
40
+};
41
+
42
+const mainNavItems: NavItem[] = [
43
+    {
44
+        title: 'Dashboard',
45
+        href: dashboard(),
46
+        icon: LayoutGrid,
47
+    },
48
+];
49
+
50
+const rightNavItems: NavItem[] = [
51
+    {
52
+        title: 'Repository',
53
+        href: 'https://github.com/laravel/react-starter-kit',
54
+        icon: Folder,
55
+    },
56
+    {
57
+        title: 'Documentation',
58
+        href: 'https://laravel.com/docs/starter-kits#react',
59
+        icon: BookOpen,
60
+    },
61
+];
62
+
63
+const activeItemStyles =
64
+    'text-neutral-900 dark:bg-neutral-800 dark:text-neutral-100';
65
+
66
+export function AppHeader({ breadcrumbs = [] }: Props) {
67
+    const page = usePage();
68
+    const { auth } = page.props;
69
+    const getInitials = useInitials();
70
+    const { isCurrentUrl, whenCurrentUrl } = useCurrentUrl();
71
+
72
+    return (
73
+        <>
74
+            <div className="border-b border-sidebar-border/80">
75
+                <div className="mx-auto flex h-16 items-center px-4 md:max-w-7xl">
76
+                    {/* Mobile Menu */}
77
+                    <div className="lg:hidden">
78
+                        <Sheet>
79
+                            <SheetTrigger asChild>
80
+                                <Button
81
+                                    variant="ghost"
82
+                                    size="icon"
83
+                                    className="mr-2 h-[34px] w-[34px]"
84
+                                >
85
+                                    <Menu className="h-5 w-5" />
86
+                                </Button>
87
+                            </SheetTrigger>
88
+                            <SheetContent
89
+                                side="left"
90
+                                className="flex h-full w-64 flex-col items-stretch justify-between bg-sidebar"
91
+                            >
92
+                                <SheetTitle className="sr-only">
93
+                                    Navigation menu
94
+                                </SheetTitle>
95
+                                <SheetHeader className="flex justify-start text-left">
96
+                                    <AppLogoIcon className="h-6 w-6 fill-current text-black dark:text-white" />
97
+                                </SheetHeader>
98
+                                <div className="flex h-full flex-1 flex-col space-y-4 p-4">
99
+                                    <div className="flex h-full flex-col justify-between text-sm">
100
+                                        <div className="flex flex-col space-y-4">
101
+                                            {mainNavItems.map((item) => (
102
+                                                <Link
103
+                                                    key={item.title}
104
+                                                    href={item.href}
105
+                                                    className="flex items-center space-x-2 font-medium"
106
+                                                >
107
+                                                    {item.icon && (
108
+                                                        <item.icon className="h-5 w-5" />
109
+                                                    )}
110
+                                                    <span>{item.title}</span>
111
+                                                </Link>
112
+                                            ))}
113
+                                        </div>
114
+
115
+                                        <div className="flex flex-col space-y-4">
116
+                                            {rightNavItems.map((item) => (
117
+                                                <a
118
+                                                    key={item.title}
119
+                                                    href={toUrl(item.href)}
120
+                                                    target="_blank"
121
+                                                    rel="noopener noreferrer"
122
+                                                    className="flex items-center space-x-2 font-medium"
123
+                                                >
124
+                                                    {item.icon && (
125
+                                                        <item.icon className="h-5 w-5" />
126
+                                                    )}
127
+                                                    <span>{item.title}</span>
128
+                                                </a>
129
+                                            ))}
130
+                                        </div>
131
+                                    </div>
132
+                                </div>
133
+                            </SheetContent>
134
+                        </Sheet>
135
+                    </div>
136
+
137
+                    <Link
138
+                        href={dashboard()}
139
+                        prefetch
140
+                        className="flex items-center space-x-2"
141
+                    >
142
+                        <AppLogo />
143
+                    </Link>
144
+
145
+                    {/* Desktop Navigation */}
146
+                    <div className="ml-6 hidden h-full items-center space-x-6 lg:flex">
147
+                        <NavigationMenu className="flex h-full items-stretch">
148
+                            <NavigationMenuList className="flex h-full items-stretch space-x-2">
149
+                                {mainNavItems.map((item, index) => (
150
+                                    <NavigationMenuItem
151
+                                        key={index}
152
+                                        className="relative flex h-full items-center"
153
+                                    >
154
+                                        <Link
155
+                                            href={item.href}
156
+                                            className={cn(
157
+                                                navigationMenuTriggerStyle(),
158
+                                                whenCurrentUrl(
159
+                                                    item.href,
160
+                                                    activeItemStyles,
161
+                                                ),
162
+                                                'h-9 cursor-pointer px-3',
163
+                                            )}
164
+                                        >
165
+                                            {item.icon && (
166
+                                                <item.icon className="mr-2 h-4 w-4" />
167
+                                            )}
168
+                                            {item.title}
169
+                                        </Link>
170
+                                        {isCurrentUrl(item.href) && (
171
+                                            <div className="absolute bottom-0 left-0 h-0.5 w-full translate-y-px bg-black dark:bg-white"></div>
172
+                                        )}
173
+                                    </NavigationMenuItem>
174
+                                ))}
175
+                            </NavigationMenuList>
176
+                        </NavigationMenu>
177
+                    </div>
178
+
179
+                    <div className="ml-auto flex items-center space-x-2">
180
+                        <div className="relative flex items-center space-x-1">
181
+                            <Button
182
+                                variant="ghost"
183
+                                size="icon"
184
+                                className="group h-9 w-9 cursor-pointer"
185
+                            >
186
+                                <Search className="!size-5 opacity-80 group-hover:opacity-100" />
187
+                            </Button>
188
+                            <div className="ml-1 hidden gap-1 lg:flex">
189
+                                {rightNavItems.map((item) => (
190
+                                    <Tooltip key={item.title}>
191
+                                        <TooltipTrigger>
192
+                                            <a
193
+                                                href={toUrl(item.href)}
194
+                                                target="_blank"
195
+                                                rel="noopener noreferrer"
196
+                                                className="group inline-flex h-9 w-9 items-center justify-center rounded-md bg-transparent p-0 text-sm font-medium text-accent-foreground ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50"
197
+                                            >
198
+                                                <span className="sr-only">
199
+                                                    {item.title}
200
+                                                </span>
201
+                                                {item.icon && (
202
+                                                    <item.icon className="size-5 opacity-80 group-hover:opacity-100" />
203
+                                                )}
204
+                                            </a>
205
+                                        </TooltipTrigger>
206
+                                        <TooltipContent>
207
+                                            <p>{item.title}</p>
208
+                                        </TooltipContent>
209
+                                    </Tooltip>
210
+                                ))}
211
+                            </div>
212
+                        </div>
213
+                        <DropdownMenu>
214
+                            <DropdownMenuTrigger asChild>
215
+                                <Button
216
+                                    variant="ghost"
217
+                                    className="size-10 rounded-full p-1"
218
+                                >
219
+                                    <Avatar className="size-8 overflow-hidden rounded-full">
220
+                                        <AvatarImage
221
+                                            src={auth.user?.avatar}
222
+                                            alt={auth.user?.name}
223
+                                        />
224
+                                        <AvatarFallback className="rounded-lg bg-neutral-200 text-black dark:bg-neutral-700 dark:text-white">
225
+                                            {getInitials(auth.user?.name ?? '')}
226
+                                        </AvatarFallback>
227
+                                    </Avatar>
228
+                                </Button>
229
+                            </DropdownMenuTrigger>
230
+                            <DropdownMenuContent className="w-56" align="end">
231
+                                {auth.user && (
232
+                                    <UserMenuContent user={auth.user} />
233
+                                )}
234
+                            </DropdownMenuContent>
235
+                        </DropdownMenu>
236
+                    </div>
237
+                </div>
238
+            </div>
239
+            {breadcrumbs.length > 1 && (
240
+                <div className="flex w-full border-b border-sidebar-border/70">
241
+                    <div className="mx-auto flex h-12 w-full items-center justify-start px-4 text-neutral-500 md:max-w-7xl">
242
+                        <Breadcrumbs breadcrumbs={breadcrumbs} />
243
+                    </div>
244
+                </div>
245
+            )}
246
+        </>
247
+    );
248
+}

+ 13
- 0
resources/js/components/app-logo-icon.tsx Näytä tiedosto

@@ -0,0 +1,13 @@
1
+import type { SVGAttributes } from 'react';
2
+
3
+export default function AppLogoIcon(props: SVGAttributes<SVGElement>) {
4
+    return (
5
+        <svg {...props} viewBox="0 0 40 42" xmlns="http://www.w3.org/2000/svg">
6
+            <path
7
+                fillRule="evenodd"
8
+                clipRule="evenodd"
9
+                d="M17.2 5.63325L8.6 0.855469L0 5.63325V32.1434L16.2 41.1434L32.4 32.1434V23.699L40 19.4767V9.85547L31.4 5.07769L22.8 9.85547V18.2999L17.2 21.411V5.63325ZM38 18.2999L32.4 21.411V15.2545L38 12.1434V18.2999ZM36.9409 10.4439L31.4 13.5221L25.8591 10.4439L31.4 7.36561L36.9409 10.4439ZM24.8 18.2999V12.1434L30.4 15.2545V21.411L24.8 18.2999ZM23.8 20.0323L29.3409 23.1105L16.2 30.411L10.6591 27.3328L23.8 20.0323ZM7.6 27.9212L15.2 32.1434V38.2999L2 30.9666V7.92116L7.6 11.0323V27.9212ZM8.6 9.29991L3.05913 6.22165L8.6 3.14339L14.1409 6.22165L8.6 9.29991ZM30.4 24.8101L17.2 32.1434V38.2999L30.4 30.9666V24.8101ZM9.6 11.0323L15.2 7.92117V22.5221L9.6 25.6333V11.0323Z"
10
+            />
11
+        </svg>
12
+    );
13
+}

+ 20
- 0
resources/js/components/app-logo.tsx Näytä tiedosto

@@ -0,0 +1,20 @@
1
+import { usePage } from '@inertiajs/react';
2
+
3
+import AppLogoIcon from '@/components/app-logo-icon';
4
+
5
+export default function AppLogo() {
6
+    const { name } = usePage().props;
7
+
8
+    return (
9
+        <>
10
+            <div className="flex aspect-square size-8 items-center justify-center rounded-md bg-sidebar-primary text-sidebar-primary-foreground">
11
+                <AppLogoIcon className="size-5 fill-current text-white dark:text-black" />
12
+            </div>
13
+            <div className="ml-1 grid flex-1 text-left text-sm">
14
+                <span className="mb-0.5 truncate leading-tight font-semibold">
15
+                    {name}
16
+                </span>
17
+            </div>
18
+        </>
19
+    );
20
+}

+ 21
- 0
resources/js/components/app-shell.tsx Näytä tiedosto

@@ -0,0 +1,21 @@
1
+import { usePage } from '@inertiajs/react';
2
+import type { ReactNode } from 'react';
3
+import { SidebarProvider } from '@/components/ui/sidebar';
4
+import type { AppVariant } from '@/types';
5
+
6
+type Props = {
7
+    children: ReactNode;
8
+    variant?: AppVariant;
9
+};
10
+
11
+export function AppShell({ children, variant = 'sidebar' }: Props) {
12
+    const isOpen = usePage().props.sidebarOpen;
13
+
14
+    if (variant === 'header') {
15
+        return (
16
+            <div className="flex min-h-screen w-full flex-col">{children}</div>
17
+        );
18
+    }
19
+
20
+    return <SidebarProvider defaultOpen={isOpen}>{children}</SidebarProvider>;
21
+}

+ 18
- 0
resources/js/components/app-sidebar-header.tsx Näytä tiedosto

@@ -0,0 +1,18 @@
1
+import { Breadcrumbs } from '@/components/breadcrumbs';
2
+import { SidebarTrigger } from '@/components/ui/sidebar';
3
+import type { BreadcrumbItem as BreadcrumbItemType } from '@/types';
4
+
5
+export function AppSidebarHeader({
6
+    breadcrumbs = [],
7
+}: {
8
+    breadcrumbs?: BreadcrumbItemType[];
9
+}) {
10
+    return (
11
+        <header className="flex h-16 shrink-0 items-center gap-2 border-b border-sidebar-border/50 px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 md:px-4">
12
+            <div className="flex items-center gap-2">
13
+                <SidebarTrigger className="-ml-1" />
14
+                <Breadcrumbs breadcrumbs={breadcrumbs} />
15
+            </div>
16
+        </header>
17
+    );
18
+}

+ 65
- 0
resources/js/components/app-sidebar.tsx Näytä tiedosto

@@ -0,0 +1,65 @@
1
+import { Link } from '@inertiajs/react';
2
+import { BookOpen, FolderGit2, LayoutGrid } from 'lucide-react';
3
+import AppLogo from '@/components/app-logo';
4
+import { NavFooter } from '@/components/nav-footer';
5
+import { NavMain } from '@/components/nav-main';
6
+import { NavUser } from '@/components/nav-user';
7
+import {
8
+    Sidebar,
9
+    SidebarContent,
10
+    SidebarFooter,
11
+    SidebarHeader,
12
+    SidebarMenu,
13
+    SidebarMenuButton,
14
+    SidebarMenuItem,
15
+} from '@/components/ui/sidebar';
16
+import { dashboard } from '@/routes';
17
+import type { NavItem } from '@/types';
18
+
19
+const mainNavItems: NavItem[] = [
20
+    {
21
+        title: 'Dashboard',
22
+        href: dashboard(),
23
+        icon: LayoutGrid,
24
+    },
25
+];
26
+
27
+const footerNavItems: NavItem[] = [
28
+    {
29
+        title: 'Repository',
30
+        href: 'https://github.com/laravel/react-starter-kit',
31
+        icon: FolderGit2,
32
+    },
33
+    {
34
+        title: 'Documentation',
35
+        href: 'https://laravel.com/docs/starter-kits#react',
36
+        icon: BookOpen,
37
+    },
38
+];
39
+
40
+export function AppSidebar() {
41
+    return (
42
+        <Sidebar collapsible="icon" variant="inset">
43
+            <SidebarHeader>
44
+                <SidebarMenu>
45
+                    <SidebarMenuItem>
46
+                        <SidebarMenuButton size="lg" asChild>
47
+                            <Link href={dashboard()} prefetch>
48
+                                <AppLogo />
49
+                            </Link>
50
+                        </SidebarMenuButton>
51
+                    </SidebarMenuItem>
52
+                </SidebarMenu>
53
+            </SidebarHeader>
54
+
55
+            <SidebarContent>
56
+                <NavMain items={mainNavItems} />
57
+            </SidebarContent>
58
+
59
+            <SidebarFooter>
60
+                <NavFooter items={footerNavItems} className="mt-auto" />
61
+                <NavUser />
62
+            </SidebarFooter>
63
+        </Sidebar>
64
+    );
65
+}

+ 45
- 0
resources/js/components/appearance-tabs.tsx Näytä tiedosto

@@ -0,0 +1,45 @@
1
+import type { LucideIcon } from 'lucide-react';
2
+import { Monitor, Moon, Sun } from 'lucide-react';
3
+import type { HTMLAttributes } from 'react';
4
+import type { Appearance } from '@/hooks/use-appearance';
5
+import { useAppearance } from '@/hooks/use-appearance';
6
+import { cn } from '@/lib/utils';
7
+
8
+export default function AppearanceToggleTab({
9
+    className = '',
10
+    ...props
11
+}: HTMLAttributes<HTMLDivElement>) {
12
+    const { appearance, updateAppearance } = useAppearance();
13
+
14
+    const tabs: { value: Appearance; icon: LucideIcon; label: string }[] = [
15
+        { value: 'light', icon: Sun, label: 'Light' },
16
+        { value: 'dark', icon: Moon, label: 'Dark' },
17
+        { value: 'system', icon: Monitor, label: 'System' },
18
+    ];
19
+
20
+    return (
21
+        <div
22
+            className={cn(
23
+                'inline-flex gap-1 rounded-lg bg-neutral-100 p-1 dark:bg-neutral-800',
24
+                className,
25
+            )}
26
+            {...props}
27
+        >
28
+            {tabs.map(({ value, icon: Icon, label }) => (
29
+                <button
30
+                    key={value}
31
+                    onClick={() => updateAppearance(value)}
32
+                    className={cn(
33
+                        'flex items-center rounded-md px-3.5 py-1.5 transition-colors',
34
+                        appearance === value
35
+                            ? 'bg-white shadow-xs dark:bg-neutral-700 dark:text-neutral-100'
36
+                            : 'text-neutral-500 hover:bg-neutral-200/60 hover:text-black dark:text-neutral-400 dark:hover:bg-neutral-700/60',
37
+                    )}
38
+                >
39
+                    <Icon className="-ml-1 h-4 w-4" />
40
+                    <span className="ml-1.5 text-sm">{label}</span>
41
+                </button>
42
+            ))}
43
+        </div>
44
+    );
45
+}

+ 50
- 0
resources/js/components/breadcrumbs.tsx Näytä tiedosto

@@ -0,0 +1,50 @@
1
+import { Link } from '@inertiajs/react';
2
+import { Fragment } from 'react';
3
+import {
4
+    Breadcrumb,
5
+    BreadcrumbItem,
6
+    BreadcrumbLink,
7
+    BreadcrumbList,
8
+    BreadcrumbPage,
9
+    BreadcrumbSeparator,
10
+} from '@/components/ui/breadcrumb';
11
+import type { BreadcrumbItem as BreadcrumbItemType } from '@/types';
12
+
13
+export function Breadcrumbs({
14
+    breadcrumbs,
15
+}: {
16
+    breadcrumbs: BreadcrumbItemType[];
17
+}) {
18
+    return (
19
+        <>
20
+            {breadcrumbs.length > 0 && (
21
+                <Breadcrumb>
22
+                    <BreadcrumbList>
23
+                        {breadcrumbs.map((item, index) => {
24
+                            const isLast = index === breadcrumbs.length - 1;
25
+
26
+                            return (
27
+                                <Fragment key={index}>
28
+                                    <BreadcrumbItem>
29
+                                        {isLast ? (
30
+                                            <BreadcrumbPage>
31
+                                                {item.title}
32
+                                            </BreadcrumbPage>
33
+                                        ) : (
34
+                                            <BreadcrumbLink asChild>
35
+                                                <Link href={item.href}>
36
+                                                    {item.title}
37
+                                                </Link>
38
+                                            </BreadcrumbLink>
39
+                                        )}
40
+                                    </BreadcrumbItem>
41
+                                    {!isLast && <BreadcrumbSeparator />}
42
+                                </Fragment>
43
+                            );
44
+                        })}
45
+                    </BreadcrumbList>
46
+                </Breadcrumb>
47
+            )}
48
+        </>
49
+    );
50
+}

+ 120
- 0
resources/js/components/delete-user.tsx Näytä tiedosto

@@ -0,0 +1,120 @@
1
+import { Form } from '@inertiajs/react';
2
+import { useRef } from 'react';
3
+import ProfileController from '@/actions/App/Http/Controllers/Settings/ProfileController';
4
+import Heading from '@/components/heading';
5
+import InputError from '@/components/input-error';
6
+import PasswordInput from '@/components/password-input';
7
+import { Button } from '@/components/ui/button';
8
+import {
9
+    Dialog,
10
+    DialogClose,
11
+    DialogContent,
12
+    DialogDescription,
13
+    DialogFooter,
14
+    DialogTitle,
15
+    DialogTrigger,
16
+} from '@/components/ui/dialog';
17
+import { Label } from '@/components/ui/label';
18
+
19
+export default function DeleteUser() {
20
+    const passwordInput = useRef<HTMLInputElement>(null);
21
+
22
+    return (
23
+        <div className="space-y-6">
24
+            <Heading
25
+                variant="small"
26
+                title="Delete account"
27
+                description="Delete your account and all of its resources"
28
+            />
29
+            <div className="space-y-4 rounded-lg border border-red-100 bg-red-50 p-4 dark:border-red-200/10 dark:bg-red-700/10">
30
+                <div className="relative space-y-0.5 text-red-600 dark:text-red-100">
31
+                    <p className="font-medium">Warning</p>
32
+                    <p className="text-sm">
33
+                        Please proceed with caution, this cannot be undone.
34
+                    </p>
35
+                </div>
36
+
37
+                <Dialog>
38
+                    <DialogTrigger asChild>
39
+                        <Button
40
+                            variant="destructive"
41
+                            data-test="delete-user-button"
42
+                        >
43
+                            Delete account
44
+                        </Button>
45
+                    </DialogTrigger>
46
+                    <DialogContent>
47
+                        <DialogTitle>
48
+                            Are you sure you want to delete your account?
49
+                        </DialogTitle>
50
+                        <DialogDescription>
51
+                            Once your account is deleted, all of its resources
52
+                            and data will also be permanently deleted. Please
53
+                            enter your password to confirm you would like to
54
+                            permanently delete your account.
55
+                        </DialogDescription>
56
+
57
+                        <Form
58
+                            {...ProfileController.destroy.form()}
59
+                            options={{
60
+                                preserveScroll: true,
61
+                            }}
62
+                            onError={() => passwordInput.current?.focus()}
63
+                            resetOnSuccess
64
+                            className="space-y-6"
65
+                        >
66
+                            {({ resetAndClearErrors, processing, errors }) => (
67
+                                <>
68
+                                    <div className="grid gap-2">
69
+                                        <Label
70
+                                            htmlFor="password"
71
+                                            className="sr-only"
72
+                                        >
73
+                                            Password
74
+                                        </Label>
75
+
76
+                                        <PasswordInput
77
+                                            id="password"
78
+                                            name="password"
79
+                                            ref={passwordInput}
80
+                                            placeholder="Password"
81
+                                            autoComplete="current-password"
82
+                                        />
83
+
84
+                                        <InputError message={errors.password} />
85
+                                    </div>
86
+
87
+                                    <DialogFooter className="gap-2">
88
+                                        <DialogClose asChild>
89
+                                            <Button
90
+                                                variant="secondary"
91
+                                                onClick={() =>
92
+                                                    resetAndClearErrors()
93
+                                                }
94
+                                            >
95
+                                                Cancel
96
+                                            </Button>
97
+                                        </DialogClose>
98
+
99
+                                        <Button
100
+                                            variant="destructive"
101
+                                            disabled={processing}
102
+                                            asChild
103
+                                        >
104
+                                            <button
105
+                                                type="submit"
106
+                                                data-test="confirm-delete-user-button"
107
+                                            >
108
+                                                Delete account
109
+                                            </button>
110
+                                        </Button>
111
+                                    </DialogFooter>
112
+                                </>
113
+                            )}
114
+                        </Form>
115
+                    </DialogContent>
116
+                </Dialog>
117
+            </div>
118
+        </div>
119
+    );
120
+}

+ 26
- 0
resources/js/components/heading.tsx Näytä tiedosto

@@ -0,0 +1,26 @@
1
+export default function Heading({
2
+    title,
3
+    description,
4
+    variant = 'default',
5
+}: {
6
+    title: string;
7
+    description?: string;
8
+    variant?: 'default' | 'small';
9
+}) {
10
+    return (
11
+        <header className={variant === 'small' ? '' : 'mb-8 space-y-0.5'}>
12
+            <h2
13
+                className={
14
+                    variant === 'small'
15
+                        ? 'mb-0.5 text-base font-medium'
16
+                        : 'text-xl font-semibold tracking-tight'
17
+                }
18
+            >
19
+                {title}
20
+            </h2>
21
+            {description && (
22
+                <p className="text-sm text-muted-foreground">{description}</p>
23
+            )}
24
+        </header>
25
+    );
26
+}

+ 17
- 0
resources/js/components/input-error.tsx Näytä tiedosto

@@ -0,0 +1,17 @@
1
+import type { HTMLAttributes } from 'react';
2
+import { cn } from '@/lib/utils';
3
+
4
+export default function InputError({
5
+    message,
6
+    className = '',
7
+    ...props
8
+}: HTMLAttributes<HTMLParagraphElement> & { message?: string }) {
9
+    return message ? (
10
+        <p
11
+            {...props}
12
+            className={cn('text-sm text-red-600 dark:text-red-400', className)}
13
+        >
14
+            {message}
15
+        </p>
16
+    ) : null;
17
+}

+ 126
- 0
resources/js/components/manage-two-factor.tsx Näytä tiedosto

@@ -0,0 +1,126 @@
1
+import { Form } from '@inertiajs/react';
2
+import { ShieldCheck } from 'lucide-react';
3
+import { useEffect, useRef, useState } from 'react';
4
+import Heading from '@/components/heading';
5
+import TwoFactorRecoveryCodes from '@/components/two-factor-recovery-codes';
6
+import TwoFactorSetupModal from '@/components/two-factor-setup-modal';
7
+import { Button } from '@/components/ui/button';
8
+import { useTwoFactorAuth } from '@/hooks/use-two-factor-auth';
9
+import { disable, enable } from '@/routes/two-factor';
10
+
11
+export type Props = {
12
+    canManageTwoFactor?: boolean;
13
+    requiresConfirmation?: boolean;
14
+    twoFactorEnabled?: boolean;
15
+};
16
+
17
+export default function ManageTwoFactor(props: Props) {
18
+    const requiresConfirmation = props.requiresConfirmation ?? false;
19
+    const twoFactorEnabled = props.twoFactorEnabled ?? false;
20
+
21
+    const {
22
+        qrCodeSvg,
23
+        hasSetupData,
24
+        manualSetupKey,
25
+        clearSetupData,
26
+        clearTwoFactorAuthData,
27
+        fetchSetupData,
28
+        recoveryCodesList,
29
+        fetchRecoveryCodes,
30
+        errors,
31
+    } = useTwoFactorAuth();
32
+    const [showSetupModal, setShowSetupModal] = useState<boolean>(false);
33
+    const prevTwoFactorEnabled = useRef(twoFactorEnabled);
34
+
35
+    useEffect(() => {
36
+        if (prevTwoFactorEnabled.current && !twoFactorEnabled) {
37
+            clearTwoFactorAuthData();
38
+        }
39
+
40
+        prevTwoFactorEnabled.current = twoFactorEnabled;
41
+    }, [twoFactorEnabled, clearTwoFactorAuthData]);
42
+
43
+    if (!(props.canManageTwoFactor ?? false)) {
44
+        return null;
45
+    }
46
+
47
+    return (
48
+        <div className="space-y-6">
49
+            <Heading
50
+                variant="small"
51
+                title="Two-factor authentication"
52
+                description="Manage your two-factor authentication settings"
53
+            />
54
+            {twoFactorEnabled ? (
55
+                <div className="flex flex-col items-start justify-start space-y-4">
56
+                    <p className="text-sm text-muted-foreground">
57
+                        You will be prompted for a secure, random pin during
58
+                        login, which you can retrieve from the TOTP-supported
59
+                        application on your phone.
60
+                    </p>
61
+
62
+                    <div className="relative inline">
63
+                        <Form {...disable.form()}>
64
+                            {({ processing }) => (
65
+                                <Button
66
+                                    variant="destructive"
67
+                                    type="submit"
68
+                                    disabled={processing}
69
+                                >
70
+                                    Disable 2FA
71
+                                </Button>
72
+                            )}
73
+                        </Form>
74
+                    </div>
75
+
76
+                    <TwoFactorRecoveryCodes
77
+                        recoveryCodesList={recoveryCodesList}
78
+                        fetchRecoveryCodes={fetchRecoveryCodes}
79
+                        errors={errors}
80
+                    />
81
+                </div>
82
+            ) : (
83
+                <div className="flex flex-col items-start justify-start space-y-4">
84
+                    <p className="text-sm text-muted-foreground">
85
+                        When you enable two-factor authentication, you will be
86
+                        prompted for a secure pin during login. This pin can be
87
+                        retrieved from a TOTP-supported application on your
88
+                        phone.
89
+                    </p>
90
+
91
+                    <div>
92
+                        {hasSetupData ? (
93
+                            <Button onClick={() => setShowSetupModal(true)}>
94
+                                <ShieldCheck />
95
+                                Continue setup
96
+                            </Button>
97
+                        ) : (
98
+                            <Form
99
+                                {...enable.form()}
100
+                                onSuccess={() => setShowSetupModal(true)}
101
+                            >
102
+                                {({ processing }) => (
103
+                                    <Button type="submit" disabled={processing}>
104
+                                        Enable 2FA
105
+                                    </Button>
106
+                                )}
107
+                            </Form>
108
+                        )}
109
+                    </div>
110
+                </div>
111
+            )}
112
+
113
+            <TwoFactorSetupModal
114
+                isOpen={showSetupModal}
115
+                onClose={() => setShowSetupModal(false)}
116
+                requiresConfirmation={requiresConfirmation}
117
+                twoFactorEnabled={twoFactorEnabled}
118
+                qrCodeSvg={qrCodeSvg}
119
+                manualSetupKey={manualSetupKey}
120
+                clearSetupData={clearSetupData}
121
+                fetchSetupData={fetchSetupData}
122
+                errors={errors}
123
+            />
124
+        </div>
125
+    );
126
+}

+ 49
- 0
resources/js/components/nav-footer.tsx Näytä tiedosto

@@ -0,0 +1,49 @@
1
+import type { ComponentPropsWithoutRef } from 'react';
2
+import {
3
+    SidebarGroup,
4
+    SidebarGroupContent,
5
+    SidebarMenu,
6
+    SidebarMenuButton,
7
+    SidebarMenuItem,
8
+} from '@/components/ui/sidebar';
9
+import { toUrl } from '@/lib/utils';
10
+import type { NavItem } from '@/types';
11
+
12
+export function NavFooter({
13
+    items,
14
+    className,
15
+    ...props
16
+}: ComponentPropsWithoutRef<typeof SidebarGroup> & {
17
+    items: NavItem[];
18
+}) {
19
+    return (
20
+        <SidebarGroup
21
+            {...props}
22
+            className={`group-data-[collapsible=icon]:p-0 ${className || ''}`}
23
+        >
24
+            <SidebarGroupContent>
25
+                <SidebarMenu>
26
+                    {items.map((item) => (
27
+                        <SidebarMenuItem key={item.title}>
28
+                            <SidebarMenuButton
29
+                                asChild
30
+                                className="text-neutral-600 hover:text-neutral-800 dark:text-neutral-300 dark:hover:text-neutral-100"
31
+                            >
32
+                                <a
33
+                                    href={toUrl(item.href)}
34
+                                    target="_blank"
35
+                                    rel="noopener noreferrer"
36
+                                >
37
+                                    {item.icon && (
38
+                                        <item.icon className="h-5 w-5" />
39
+                                    )}
40
+                                    <span>{item.title}</span>
41
+                                </a>
42
+                            </SidebarMenuButton>
43
+                        </SidebarMenuItem>
44
+                    ))}
45
+                </SidebarMenu>
46
+            </SidebarGroupContent>
47
+        </SidebarGroup>
48
+    );
49
+}

+ 36
- 0
resources/js/components/nav-main.tsx Näytä tiedosto

@@ -0,0 +1,36 @@
1
+import { Link } from '@inertiajs/react';
2
+import {
3
+    SidebarGroup,
4
+    SidebarGroupLabel,
5
+    SidebarMenu,
6
+    SidebarMenuButton,
7
+    SidebarMenuItem,
8
+} from '@/components/ui/sidebar';
9
+import { useCurrentUrl } from '@/hooks/use-current-url';
10
+import type { NavItem } from '@/types';
11
+
12
+export function NavMain({ items }: { items: NavItem[] }) {
13
+    const { isCurrentUrl } = useCurrentUrl();
14
+
15
+    return (
16
+        <SidebarGroup className="px-2 py-0">
17
+            <SidebarGroupLabel>Platform</SidebarGroupLabel>
18
+            <SidebarMenu>
19
+                {items.map((item) => (
20
+                    <SidebarMenuItem key={item.title}>
21
+                        <SidebarMenuButton
22
+                            asChild
23
+                            isActive={isCurrentUrl(item.href)}
24
+                            tooltip={{ children: item.title }}
25
+                        >
26
+                            <Link href={item.href} prefetch>
27
+                                {item.icon && <item.icon />}
28
+                                <span>{item.title}</span>
29
+                            </Link>
30
+                        </SidebarMenuButton>
31
+                    </SidebarMenuItem>
32
+                ))}
33
+            </SidebarMenu>
34
+        </SidebarGroup>
35
+    );
36
+}

+ 58
- 0
resources/js/components/nav-user.tsx Näytä tiedosto

@@ -0,0 +1,58 @@
1
+import { usePage } from '@inertiajs/react';
2
+import { ChevronsUpDown } from 'lucide-react';
3
+import {
4
+    DropdownMenu,
5
+    DropdownMenuContent,
6
+    DropdownMenuTrigger,
7
+} from '@/components/ui/dropdown-menu';
8
+import {
9
+    SidebarMenu,
10
+    SidebarMenuButton,
11
+    SidebarMenuItem,
12
+    useSidebar,
13
+} from '@/components/ui/sidebar';
14
+import { UserInfo } from '@/components/user-info';
15
+import { UserMenuContent } from '@/components/user-menu-content';
16
+import { useIsMobile } from '@/hooks/use-mobile';
17
+
18
+export function NavUser() {
19
+    const { auth } = usePage().props;
20
+    const { state } = useSidebar();
21
+    const isMobile = useIsMobile();
22
+
23
+    if (!auth.user) {
24
+        return null;
25
+    }
26
+
27
+    return (
28
+        <SidebarMenu>
29
+            <SidebarMenuItem>
30
+                <DropdownMenu>
31
+                    <DropdownMenuTrigger asChild>
32
+                        <SidebarMenuButton
33
+                            size="lg"
34
+                            className="group text-sidebar-accent-foreground data-[state=open]:bg-sidebar-accent"
35
+                            data-test="sidebar-menu-button"
36
+                        >
37
+                            <UserInfo user={auth.user} />
38
+                            <ChevronsUpDown className="ml-auto size-4" />
39
+                        </SidebarMenuButton>
40
+                    </DropdownMenuTrigger>
41
+                    <DropdownMenuContent
42
+                        className="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg"
43
+                        align="end"
44
+                        side={
45
+                            isMobile
46
+                                ? 'bottom'
47
+                                : state === 'collapsed'
48
+                                  ? 'left'
49
+                                  : 'bottom'
50
+                        }
51
+                    >
52
+                        <UserMenuContent user={auth.user} />
53
+                    </DropdownMenuContent>
54
+                </DropdownMenu>
55
+            </SidebarMenuItem>
56
+        </SidebarMenu>
57
+    );
58
+}

+ 37
- 0
resources/js/components/password-input.tsx Näytä tiedosto

@@ -0,0 +1,37 @@
1
+import { Eye, EyeOff } from 'lucide-react';
2
+import type { ComponentProps, Ref } from 'react';
3
+import { useState } from 'react';
4
+import { Input } from '@/components/ui/input';
5
+import { cn } from '@/lib/utils';
6
+
7
+export default function PasswordInput({
8
+    className,
9
+    ref,
10
+    ...props
11
+}: Omit<ComponentProps<'input'>, 'type'> & { ref?: Ref<HTMLInputElement> }) {
12
+    const [showPassword, setShowPassword] = useState(false);
13
+
14
+    return (
15
+        <div className="relative">
16
+            <Input
17
+                type={showPassword ? 'text' : 'password'}
18
+                className={cn('pr-10', className)}
19
+                ref={ref}
20
+                {...props}
21
+            />
22
+            <button
23
+                type="button"
24
+                onClick={() => setShowPassword((prev) => !prev)}
25
+                className="absolute inset-y-0 right-0 flex items-center rounded-r-md px-3 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring focus-visible:outline-none"
26
+                aria-label={showPassword ? 'Hide password' : 'Show password'}
27
+                tabIndex={-1}
28
+            >
29
+                {showPassword ? (
30
+                    <EyeOff className="size-4" />
31
+                ) : (
32
+                    <Eye className="size-4" />
33
+                )}
34
+            </button>
35
+        </div>
36
+    );
37
+}

+ 23
- 0
resources/js/components/text-link.tsx Näytä tiedosto

@@ -0,0 +1,23 @@
1
+import { Link } from '@inertiajs/react';
2
+import type { ComponentProps } from 'react';
3
+import { cn } from '@/lib/utils';
4
+
5
+type Props = ComponentProps<typeof Link>;
6
+
7
+export default function TextLink({
8
+    className = '',
9
+    children,
10
+    ...props
11
+}: Props) {
12
+    return (
13
+        <Link
14
+            className={cn(
15
+                'text-foreground underline decoration-neutral-300 underline-offset-4 transition-colors duration-300 ease-out hover:decoration-current! dark:decoration-neutral-500',
16
+                className,
17
+            )}
18
+            {...props}
19
+        >
20
+            {children}
21
+        </Link>
22
+    );
23
+}

+ 164
- 0
resources/js/components/two-factor-recovery-codes.tsx Näytä tiedosto

@@ -0,0 +1,164 @@
1
+import { Form } from '@inertiajs/react';
2
+import { Eye, EyeOff, LockKeyhole, RefreshCw } from 'lucide-react';
3
+import { useCallback, useEffect, useRef, useState } from 'react';
4
+import AlertError from '@/components/alert-error';
5
+import { Button } from '@/components/ui/button';
6
+import {
7
+    Card,
8
+    CardContent,
9
+    CardDescription,
10
+    CardHeader,
11
+    CardTitle,
12
+} from '@/components/ui/card';
13
+import { regenerateRecoveryCodes } from '@/routes/two-factor';
14
+
15
+type Props = {
16
+    recoveryCodesList: string[];
17
+    fetchRecoveryCodes: () => Promise<void>;
18
+    errors: string[];
19
+};
20
+
21
+export default function TwoFactorRecoveryCodes({
22
+    recoveryCodesList,
23
+    fetchRecoveryCodes,
24
+    errors,
25
+}: Props) {
26
+    const [codesAreVisible, setCodesAreVisible] = useState<boolean>(false);
27
+    const codesSectionRef = useRef<HTMLDivElement | null>(null);
28
+    const canRegenerateCodes = recoveryCodesList.length > 0 && codesAreVisible;
29
+
30
+    const toggleCodesVisibility = useCallback(async () => {
31
+        if (!codesAreVisible && !recoveryCodesList.length) {
32
+            await fetchRecoveryCodes();
33
+        }
34
+
35
+        setCodesAreVisible(!codesAreVisible);
36
+
37
+        if (!codesAreVisible) {
38
+            setTimeout(() => {
39
+                codesSectionRef.current?.scrollIntoView({
40
+                    behavior: 'smooth',
41
+                    block: 'nearest',
42
+                });
43
+            });
44
+        }
45
+    }, [codesAreVisible, recoveryCodesList.length, fetchRecoveryCodes]);
46
+
47
+    useEffect(() => {
48
+        if (!recoveryCodesList.length) {
49
+            void fetchRecoveryCodes();
50
+        }
51
+    }, [recoveryCodesList.length, fetchRecoveryCodes]);
52
+
53
+    const RecoveryCodeIconComponent = codesAreVisible ? EyeOff : Eye;
54
+
55
+    return (
56
+        <Card>
57
+            <CardHeader>
58
+                <CardTitle className="flex gap-3">
59
+                    <LockKeyhole className="size-4" aria-hidden="true" />
60
+                    2FA recovery codes
61
+                </CardTitle>
62
+                <CardDescription>
63
+                    Recovery codes let you regain access if you lose your 2FA
64
+                    device. Store them in a secure password manager.
65
+                </CardDescription>
66
+            </CardHeader>
67
+            <CardContent>
68
+                <div className="flex flex-col gap-3 select-none sm:flex-row sm:items-center sm:justify-between">
69
+                    <Button
70
+                        onClick={toggleCodesVisibility}
71
+                        className="w-fit"
72
+                        aria-expanded={codesAreVisible}
73
+                        aria-controls="recovery-codes-section"
74
+                    >
75
+                        <RecoveryCodeIconComponent
76
+                            className="size-4"
77
+                            aria-hidden="true"
78
+                        />
79
+                        {codesAreVisible ? 'Hide' : 'View'} recovery codes
80
+                    </Button>
81
+
82
+                    {canRegenerateCodes && (
83
+                        <Form
84
+                            {...regenerateRecoveryCodes.form()}
85
+                            options={{ preserveScroll: true }}
86
+                            onSuccess={fetchRecoveryCodes}
87
+                        >
88
+                            {({ processing }) => (
89
+                                <Button
90
+                                    variant="secondary"
91
+                                    type="submit"
92
+                                    disabled={processing}
93
+                                    aria-describedby="regenerate-warning"
94
+                                >
95
+                                    <RefreshCw /> Regenerate codes
96
+                                </Button>
97
+                            )}
98
+                        </Form>
99
+                    )}
100
+                </div>
101
+                <div
102
+                    id="recovery-codes-section"
103
+                    className={`relative overflow-hidden transition-all duration-300 ${codesAreVisible ? 'h-auto opacity-100' : 'h-0 opacity-0'}`}
104
+                    aria-hidden={!codesAreVisible}
105
+                >
106
+                    <div className="mt-3 space-y-3">
107
+                        {errors?.length ? (
108
+                            <AlertError errors={errors} />
109
+                        ) : (
110
+                            <>
111
+                                <div
112
+                                    ref={codesSectionRef}
113
+                                    className="grid gap-1 rounded-lg bg-muted p-4 font-mono text-sm"
114
+                                    role="list"
115
+                                    aria-label="Recovery codes"
116
+                                >
117
+                                    {recoveryCodesList.length ? (
118
+                                        recoveryCodesList.map((code, index) => (
119
+                                            <div
120
+                                                key={index}
121
+                                                role="listitem"
122
+                                                className="select-text"
123
+                                            >
124
+                                                {code}
125
+                                            </div>
126
+                                        ))
127
+                                    ) : (
128
+                                        <div
129
+                                            className="space-y-2"
130
+                                            aria-label="Loading recovery codes"
131
+                                        >
132
+                                            {Array.from(
133
+                                                { length: 8 },
134
+                                                (_, index) => (
135
+                                                    <div
136
+                                                        key={index}
137
+                                                        className="h-4 animate-pulse rounded bg-muted-foreground/20"
138
+                                                        aria-hidden="true"
139
+                                                    />
140
+                                                ),
141
+                                            )}
142
+                                        </div>
143
+                                    )}
144
+                                </div>
145
+
146
+                                <div className="text-xs text-muted-foreground select-none">
147
+                                    <p id="regenerate-warning">
148
+                                        Each recovery code can be used once to
149
+                                        access your account and will be removed
150
+                                        after use. If you need more, click{' '}
151
+                                        <span className="font-bold">
152
+                                            Regenerate codes
153
+                                        </span>{' '}
154
+                                        above.
155
+                                    </p>
156
+                                </div>
157
+                            </>
158
+                        )}
159
+                    </div>
160
+                </div>
161
+            </CardContent>
162
+        </Card>
163
+    );
164
+}

+ 355
- 0
resources/js/components/two-factor-setup-modal.tsx Näytä tiedosto

@@ -0,0 +1,355 @@
1
+import { Form } from '@inertiajs/react';
2
+import { REGEXP_ONLY_DIGITS } from 'input-otp';
3
+import { Check, Copy, ScanLine } from 'lucide-react';
4
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
+import AlertError from '@/components/alert-error';
6
+import InputError from '@/components/input-error';
7
+import { Button } from '@/components/ui/button';
8
+import {
9
+    Dialog,
10
+    DialogContent,
11
+    DialogDescription,
12
+    DialogHeader,
13
+    DialogTitle,
14
+} from '@/components/ui/dialog';
15
+import {
16
+    InputOTP,
17
+    InputOTPGroup,
18
+    InputOTPSlot,
19
+} from '@/components/ui/input-otp';
20
+import { Spinner } from '@/components/ui/spinner';
21
+import { useAppearance } from '@/hooks/use-appearance';
22
+import { useClipboard } from '@/hooks/use-clipboard';
23
+import { OTP_MAX_LENGTH } from '@/hooks/use-two-factor-auth';
24
+import { confirm } from '@/routes/two-factor';
25
+
26
+function GridScanIcon() {
27
+    return (
28
+        <div className="mb-3 rounded-full border border-border bg-card p-0.5 shadow-sm">
29
+            <div className="relative overflow-hidden rounded-full border border-border bg-muted p-2.5">
30
+                <div className="absolute inset-0 grid grid-cols-5 opacity-50">
31
+                    {Array.from({ length: 5 }, (_, i) => (
32
+                        <div
33
+                            key={`col-${i + 1}`}
34
+                            className="border-r border-border last:border-r-0"
35
+                        />
36
+                    ))}
37
+                </div>
38
+                <div className="absolute inset-0 grid grid-rows-5 opacity-50">
39
+                    {Array.from({ length: 5 }, (_, i) => (
40
+                        <div
41
+                            key={`row-${i + 1}`}
42
+                            className="border-b border-border last:border-b-0"
43
+                        />
44
+                    ))}
45
+                </div>
46
+                <ScanLine className="relative z-20 size-6 text-foreground" />
47
+            </div>
48
+        </div>
49
+    );
50
+}
51
+
52
+function TwoFactorSetupStep({
53
+    qrCodeSvg,
54
+    manualSetupKey,
55
+    buttonText,
56
+    onNextStep,
57
+    errors,
58
+}: {
59
+    qrCodeSvg: string | null;
60
+    manualSetupKey: string | null;
61
+    buttonText: string;
62
+    onNextStep: () => void;
63
+    errors: string[];
64
+}) {
65
+    const { resolvedAppearance } = useAppearance();
66
+    const [copiedText, copy] = useClipboard();
67
+    const IconComponent = copiedText === manualSetupKey ? Check : Copy;
68
+
69
+    return (
70
+        <>
71
+            {errors?.length ? (
72
+                <AlertError errors={errors} />
73
+            ) : (
74
+                <>
75
+                    <div className="mx-auto flex max-w-md overflow-hidden">
76
+                        <div className="mx-auto aspect-square w-64 rounded-lg border border-border">
77
+                            <div className="z-10 flex h-full w-full items-center justify-center p-5">
78
+                                {qrCodeSvg ? (
79
+                                    <div
80
+                                        className="aspect-square w-full rounded-lg bg-white p-2 [&_svg]:size-full"
81
+                                        dangerouslySetInnerHTML={{
82
+                                            __html: qrCodeSvg,
83
+                                        }}
84
+                                        style={{
85
+                                            filter:
86
+                                                resolvedAppearance === 'dark'
87
+                                                    ? 'invert(1) brightness(1.5)'
88
+                                                    : undefined,
89
+                                        }}
90
+                                    />
91
+                                ) : (
92
+                                    <Spinner />
93
+                                )}
94
+                            </div>
95
+                        </div>
96
+                    </div>
97
+
98
+                    <div className="flex w-full space-x-5">
99
+                        <Button className="w-full" onClick={onNextStep}>
100
+                            {buttonText}
101
+                        </Button>
102
+                    </div>
103
+
104
+                    <div className="relative flex w-full items-center justify-center">
105
+                        <div className="absolute inset-0 top-1/2 h-px w-full bg-border" />
106
+                        <span className="relative bg-card px-2 py-1">
107
+                            or, enter the code manually
108
+                        </span>
109
+                    </div>
110
+
111
+                    <div className="flex w-full space-x-2">
112
+                        <div className="flex w-full items-stretch overflow-hidden rounded-xl border border-border">
113
+                            {!manualSetupKey ? (
114
+                                <div className="flex h-full w-full items-center justify-center bg-muted p-3">
115
+                                    <Spinner />
116
+                                </div>
117
+                            ) : (
118
+                                <>
119
+                                    <input
120
+                                        type="text"
121
+                                        readOnly
122
+                                        value={manualSetupKey}
123
+                                        className="h-full w-full bg-background p-3 text-foreground outline-none"
124
+                                    />
125
+                                    <button
126
+                                        onClick={() => copy(manualSetupKey)}
127
+                                        className="border-l border-border px-3 hover:bg-muted"
128
+                                    >
129
+                                        <IconComponent className="w-4" />
130
+                                    </button>
131
+                                </>
132
+                            )}
133
+                        </div>
134
+                    </div>
135
+                </>
136
+            )}
137
+        </>
138
+    );
139
+}
140
+
141
+function TwoFactorVerificationStep({
142
+    onClose,
143
+    onBack,
144
+}: {
145
+    onClose: () => void;
146
+    onBack: () => void;
147
+}) {
148
+    const [code, setCode] = useState<string>('');
149
+    const pinInputContainerRef = useRef<HTMLDivElement>(null);
150
+
151
+    useEffect(() => {
152
+        setTimeout(() => {
153
+            pinInputContainerRef.current?.querySelector('input')?.focus();
154
+        }, 0);
155
+    }, []);
156
+
157
+    return (
158
+        <Form
159
+            {...confirm.form()}
160
+            onSuccess={() => onClose()}
161
+            resetOnError
162
+            resetOnSuccess
163
+        >
164
+            {({
165
+                processing,
166
+                errors,
167
+            }: {
168
+                processing: boolean;
169
+                errors?: { confirmTwoFactorAuthentication?: { code?: string } };
170
+            }) => (
171
+                <>
172
+                    <div
173
+                        ref={pinInputContainerRef}
174
+                        className="relative w-full space-y-3"
175
+                    >
176
+                        <div className="flex w-full flex-col items-center space-y-3 py-2">
177
+                            <InputOTP
178
+                                id="otp"
179
+                                name="code"
180
+                                maxLength={OTP_MAX_LENGTH}
181
+                                onChange={setCode}
182
+                                disabled={processing}
183
+                                pattern={REGEXP_ONLY_DIGITS}
184
+                                autoFocus
185
+                            >
186
+                                <InputOTPGroup>
187
+                                    {Array.from(
188
+                                        { length: OTP_MAX_LENGTH },
189
+                                        (_, index) => (
190
+                                            <InputOTPSlot
191
+                                                key={index}
192
+                                                index={index}
193
+                                            />
194
+                                        ),
195
+                                    )}
196
+                                </InputOTPGroup>
197
+                            </InputOTP>
198
+                            <InputError
199
+                                message={
200
+                                    errors?.confirmTwoFactorAuthentication?.code
201
+                                }
202
+                            />
203
+                        </div>
204
+
205
+                        <div className="flex w-full space-x-5">
206
+                            <Button
207
+                                type="button"
208
+                                variant="outline"
209
+                                className="flex-1"
210
+                                onClick={onBack}
211
+                                disabled={processing}
212
+                            >
213
+                                Back
214
+                            </Button>
215
+                            <Button
216
+                                type="submit"
217
+                                className="flex-1"
218
+                                disabled={
219
+                                    processing || code.length < OTP_MAX_LENGTH
220
+                                }
221
+                            >
222
+                                Confirm
223
+                            </Button>
224
+                        </div>
225
+                    </div>
226
+                </>
227
+            )}
228
+        </Form>
229
+    );
230
+}
231
+
232
+type Props = {
233
+    isOpen: boolean;
234
+    onClose: () => void;
235
+    requiresConfirmation: boolean;
236
+    twoFactorEnabled: boolean;
237
+    qrCodeSvg: string | null;
238
+    manualSetupKey: string | null;
239
+    clearSetupData: () => void;
240
+    fetchSetupData: () => Promise<void>;
241
+    errors: string[];
242
+};
243
+
244
+export default function TwoFactorSetupModal({
245
+    isOpen,
246
+    onClose,
247
+    requiresConfirmation,
248
+    twoFactorEnabled,
249
+    qrCodeSvg,
250
+    manualSetupKey,
251
+    clearSetupData,
252
+    fetchSetupData,
253
+    errors,
254
+}: Props) {
255
+    const [showVerificationStep, setShowVerificationStep] =
256
+        useState<boolean>(false);
257
+
258
+    const modalConfig = useMemo<{
259
+        title: string;
260
+        description: string;
261
+        buttonText: string;
262
+    }>(() => {
263
+        if (twoFactorEnabled) {
264
+            return {
265
+                title: 'Two-factor authentication enabled',
266
+                description:
267
+                    'Two-factor authentication is now enabled. Scan the QR code or enter the setup key in your authenticator app.',
268
+                buttonText: 'Close',
269
+            };
270
+        }
271
+
272
+        if (showVerificationStep) {
273
+            return {
274
+                title: 'Verify authentication code',
275
+                description:
276
+                    'Enter the 6-digit code from your authenticator app',
277
+                buttonText: 'Continue',
278
+            };
279
+        }
280
+
281
+        return {
282
+            title: 'Enable two-factor authentication',
283
+            description:
284
+                'To finish enabling two-factor authentication, scan the QR code or enter the setup key in your authenticator app',
285
+            buttonText: 'Continue',
286
+        };
287
+    }, [twoFactorEnabled, showVerificationStep]);
288
+
289
+    const resetModalState = useCallback(() => {
290
+        if (twoFactorEnabled) {
291
+            clearSetupData();
292
+        }
293
+
294
+        setShowVerificationStep(false);
295
+    }, [clearSetupData, twoFactorEnabled]);
296
+
297
+    const handleClose = useCallback(() => {
298
+        resetModalState();
299
+        onClose();
300
+    }, [onClose, resetModalState]);
301
+
302
+    const handleModalNextStep = useCallback(() => {
303
+        if (requiresConfirmation) {
304
+            setShowVerificationStep(true);
305
+
306
+            return;
307
+        }
308
+
309
+        clearSetupData();
310
+        handleClose();
311
+    }, [requiresConfirmation, clearSetupData, handleClose]);
312
+
313
+    const fetchSetupDataRef = useRef(fetchSetupData);
314
+
315
+    useEffect(() => {
316
+        fetchSetupDataRef.current = fetchSetupData;
317
+    }, [fetchSetupData]);
318
+
319
+    useEffect(() => {
320
+        if (isOpen && !qrCodeSvg) {
321
+            void fetchSetupDataRef.current();
322
+        }
323
+    }, [isOpen, qrCodeSvg]);
324
+
325
+    return (
326
+        <Dialog open={isOpen} onOpenChange={(open) => !open && handleClose()}>
327
+            <DialogContent className="sm:max-w-md">
328
+                <DialogHeader className="flex items-center justify-center">
329
+                    <GridScanIcon />
330
+                    <DialogTitle>{modalConfig.title}</DialogTitle>
331
+                    <DialogDescription className="text-center">
332
+                        {modalConfig.description}
333
+                    </DialogDescription>
334
+                </DialogHeader>
335
+
336
+                <div className="flex flex-col items-center space-y-5">
337
+                    {showVerificationStep ? (
338
+                        <TwoFactorVerificationStep
339
+                            onClose={handleClose}
340
+                            onBack={() => setShowVerificationStep(false)}
341
+                        />
342
+                    ) : (
343
+                        <TwoFactorSetupStep
344
+                            qrCodeSvg={qrCodeSvg}
345
+                            manualSetupKey={manualSetupKey}
346
+                            buttonText={modalConfig.buttonText}
347
+                            onNextStep={handleModalNextStep}
348
+                            errors={errors}
349
+                        />
350
+                    )}
351
+                </div>
352
+            </DialogContent>
353
+        </Dialog>
354
+    );
355
+}

+ 0
- 0
resources/js/components/ui/alert.tsx Näytä tiedosto


Some files were not shown because too many files changed in this diff

Loading…
Peruuta
Tallenna