base-api-scramble-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -0
- package/docs/AI-GUIDE-COMPLETE.md +372 -0
- package/docs/EXCEL-EXPORT-SERVICE.md +349 -0
- package/docs/EXPORT-DATA-PROVIDERS.md +340 -0
- package/docs/EXPORT-TEMPLATES.md +459 -0
- package/docs/LARAVEL-API-TEST.md +355 -0
- package/docs/MAKE-EXPORT-EXCEL-COMMAND.md +215 -0
- package/docs/README.md +678 -0
- package/docs/STRUCTURE.md +540 -0
- package/docs/starting_point.md +423 -0
- package/index.js +968 -0
- package/package.json +17 -0
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
# Project Structure - Base API Scramble
|
|
2
|
+
|
|
3
|
+
## 📁 Root Directory
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
base-api-scramble/
|
|
7
|
+
├── 📄 .editorconfig
|
|
8
|
+
├── 📄 .env.example
|
|
9
|
+
├── 📄 .gitattributes
|
|
10
|
+
├── 📄 .gitignore
|
|
11
|
+
├── 📄 README.md
|
|
12
|
+
├── 📄 DESCRIPTION.md
|
|
13
|
+
├── 📄 STRUCTURE.md # This file
|
|
14
|
+
├── 📄 artisan
|
|
15
|
+
├── 📄 composer.json
|
|
16
|
+
├── 📄 composer.lock
|
|
17
|
+
├── 📄 package.json
|
|
18
|
+
├── 📄 phpunit.xml
|
|
19
|
+
├── 📄 vite.config.js
|
|
20
|
+
└── 📁 [directories...]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 🎯 Application Directory (`app/`)
|
|
26
|
+
|
|
27
|
+
### Console
|
|
28
|
+
```
|
|
29
|
+
app/Console/
|
|
30
|
+
├── Commands/
|
|
31
|
+
│ ├── GC.php # Generator Command utama
|
|
32
|
+
│ ├── GCFromMigration.php # Generate dari migration
|
|
33
|
+
│ ├── GCHelp.php # Helper command
|
|
34
|
+
│ ├── GCWizard.php # Wizard mode
|
|
35
|
+
│ └── gc/ # Template stubs
|
|
36
|
+
│ ├── controller.stub
|
|
37
|
+
│ ├── controller_with_file.stub
|
|
38
|
+
│ ├── migration.stub
|
|
39
|
+
│ ├── model.stub
|
|
40
|
+
│ ├── query.stub # ⭐ NEW: Query class stub
|
|
41
|
+
│ ├── route_api_v1_segment.stub
|
|
42
|
+
│ ├── storerequest.stub
|
|
43
|
+
│ └── updaterequest.stub
|
|
44
|
+
└── Kernel.php
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Exceptions
|
|
48
|
+
```
|
|
49
|
+
app/Exceptions/
|
|
50
|
+
└── Handler.php # Global exception handler
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Helpers
|
|
54
|
+
```
|
|
55
|
+
app/Helpers/
|
|
56
|
+
├── ApiResponse.php # Standardized API responses
|
|
57
|
+
└── QueryHelper.php # Query building helper
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### HTTP Layer
|
|
61
|
+
```
|
|
62
|
+
app/Http/
|
|
63
|
+
├── Controllers/
|
|
64
|
+
│ ├── Controller.php # Base controller
|
|
65
|
+
│ └── Api/V1/ # API Version 1
|
|
66
|
+
│ ├── AuthController.php # Authentication
|
|
67
|
+
│ ├── LabelController.php # Labels CRUD
|
|
68
|
+
│ ├── LogActivityController.php # Activity logs
|
|
69
|
+
│ ├── PermissionController.php # Permissions management
|
|
70
|
+
│ ├── PostController.php # Posts CRUD
|
|
71
|
+
│ ├── ProfileController.php # User profile
|
|
72
|
+
│ ├── RoleController.php # Roles management
|
|
73
|
+
│ ├── RolePermissionController.php # Role-Permission pivot
|
|
74
|
+
│ ├── UserController.php # Users management
|
|
75
|
+
│ └── UserRoleController.php # User-Role pivot
|
|
76
|
+
│
|
|
77
|
+
├── Middleware/
|
|
78
|
+
│ ├── Authenticate.php
|
|
79
|
+
│ ├── EncryptCookies.php
|
|
80
|
+
│ ├── PreventRequestsDuringMaintenance.php
|
|
81
|
+
│ ├── RedirectIfAuthenticated.php
|
|
82
|
+
│ ├── TrimStrings.php
|
|
83
|
+
│ ├── TrustHosts.php
|
|
84
|
+
│ ├── TrustProxies.php
|
|
85
|
+
│ ├── ValidateSignature.php
|
|
86
|
+
│ └── VerifyCsrfToken.php
|
|
87
|
+
│
|
|
88
|
+
├── Requests/Api/V1/
|
|
89
|
+
│ ├── ChangePasswordRequest.php
|
|
90
|
+
│ ├── IndexRequest.php # ⭐ NEW: Generic index request
|
|
91
|
+
│ ├── LoginRequest.php # ⭐ NEW: Login validation
|
|
92
|
+
│ ├── LabelStoreRequest.php
|
|
93
|
+
│ ├── LabelUpdateRequest.php
|
|
94
|
+
│ ├── PermissionStoreRequest.php # ⭐ NEW
|
|
95
|
+
│ ├── PermissionUpdateRequest.php # ⭐ NEW
|
|
96
|
+
│ ├── PostStoreRequest.php
|
|
97
|
+
│ ├── PostUpdateRequest.php
|
|
98
|
+
│ ├── ProfileRequest.php
|
|
99
|
+
│ ├── RolePermissionAttachRequest.php # ⭐ NEW
|
|
100
|
+
│ ├── RolePermissionDetachRequest.php # ⭐ NEW
|
|
101
|
+
│ ├── RolePermissionSyncPermissionsRequest.php # ⭐ NEW
|
|
102
|
+
│ ├── RolePermissionSyncRolesRequest.php # ⭐ NEW
|
|
103
|
+
│ ├── RoleStoreRequest.php # ⭐ NEW
|
|
104
|
+
│ ├── RoleUpdateRequest.php # ⭐ NEW
|
|
105
|
+
│ ├── UserRoleAttachRequest.php # ⭐ NEW
|
|
106
|
+
│ ├── UserRoleDetachRequest.php # ⭐ NEW
|
|
107
|
+
│ ├── UserRoleSyncRolesRequest.php # ⭐ NEW
|
|
108
|
+
│ ├── UserRoleSyncUsersRequest.php # ⭐ NEW
|
|
109
|
+
│ ├── UserStoreRequest.php # ⭐ NEW
|
|
110
|
+
│ └── UserUpdateRequest.php # ⭐ NEW
|
|
111
|
+
│
|
|
112
|
+
├── Resources/V1/
|
|
113
|
+
│ └── ActivityLogResource.php # API resource transformer
|
|
114
|
+
│
|
|
115
|
+
└── Kernel.php
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Models
|
|
119
|
+
```
|
|
120
|
+
app/Models/
|
|
121
|
+
├── ActivityLog.php # Activity logging
|
|
122
|
+
├── Label.php # Labels
|
|
123
|
+
├── Permission.php # Permissions (Spatie)
|
|
124
|
+
├── Post.php # Posts
|
|
125
|
+
├── Role.php # Roles (Spatie)
|
|
126
|
+
└── User.php # Users
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Observers
|
|
130
|
+
```
|
|
131
|
+
app/Observers/
|
|
132
|
+
├── LogPermissionObserver.php # Log permission changes
|
|
133
|
+
├── LogRoleObserver.php # Log role changes
|
|
134
|
+
└── LogUserObserver.php # Log user changes
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Providers
|
|
138
|
+
```
|
|
139
|
+
app/Providers/
|
|
140
|
+
├── AppServiceProvider.php
|
|
141
|
+
├── AuthServiceProvider.php
|
|
142
|
+
├── BroadcastServiceProvider.php
|
|
143
|
+
├── EventServiceProvider.php
|
|
144
|
+
├── RouteServiceProvider.php
|
|
145
|
+
└── ScrambleServiceProvider.php # ⭐ NEW: Scramble configuration
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Queries (⭐ NEW Directory)
|
|
149
|
+
```
|
|
150
|
+
app/Queries/
|
|
151
|
+
├── ActivityLogQuery.php # Activity log query builder
|
|
152
|
+
├── LabelQuery.php # Label query builder
|
|
153
|
+
├── PermissionQuery.php # Permission query builder
|
|
154
|
+
├── PostQuery.php # Post query builder
|
|
155
|
+
├── RoleQuery.php # Role query builder
|
|
156
|
+
└── UserQuery.php # User query builder
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Services
|
|
160
|
+
```
|
|
161
|
+
app/Services/
|
|
162
|
+
└── FileService.php # File handling service
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Traits
|
|
166
|
+
```
|
|
167
|
+
app/Traits/
|
|
168
|
+
└── Queryable.php # Query filtering trait
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 🗄️ Database (`database/`)
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
database/
|
|
177
|
+
├── factories/
|
|
178
|
+
│ └── UserFactory.php
|
|
179
|
+
│
|
|
180
|
+
├── migrations/
|
|
181
|
+
│ ├── 2014_10_12_000000_create_users_table.php
|
|
182
|
+
│ ├── 2014_10_12_100000_create_password_reset_tokens_table.php
|
|
183
|
+
│ ├── 2019_08_19_000000_create_failed_jobs_table.php
|
|
184
|
+
│ ├── 2019_12_14_000001_create_personal_access_tokens_table.php
|
|
185
|
+
│ ├── 2025_02_07_062711_create_sessions_table.php
|
|
186
|
+
│ ├── 2025_02_07_062718_create_jobs_table.php
|
|
187
|
+
│ ├── 2025_02_07_062727_create_cache_table.php
|
|
188
|
+
│ ├── 2025_02_07_063308_create_permission_tables.php
|
|
189
|
+
│ ├── 2025_02_07_064118_create_activity_log_table.php
|
|
190
|
+
│ ├── 2025_06_20_105040_create_labels_table.php
|
|
191
|
+
│ └── 2025_06_20_113036_create_posts_table.php
|
|
192
|
+
│
|
|
193
|
+
└── seeders/
|
|
194
|
+
├── DatabaseSeeder.php
|
|
195
|
+
└── PermissionSeeder.php
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## ⚙️ Configuration (`config/`)
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
config/
|
|
204
|
+
├── app.php # Application config
|
|
205
|
+
├── auth.php # Authentication
|
|
206
|
+
├── broadcasting.php # Broadcasting
|
|
207
|
+
├── cache.php # Cache
|
|
208
|
+
├── cors.php # CORS
|
|
209
|
+
├── database.php # Database
|
|
210
|
+
├── filesystems.php # File storage
|
|
211
|
+
├── hashing.php # Hashing
|
|
212
|
+
├── logging.php # Logging
|
|
213
|
+
├── mail.php # Mail
|
|
214
|
+
├── permission.php # Spatie Permission
|
|
215
|
+
├── query-builder.php # Query builder
|
|
216
|
+
├── queue.php # Queue
|
|
217
|
+
├── sanctum.php # Laravel Sanctum
|
|
218
|
+
├── scramble.php # ⭐ NEW: Scramble API docs config
|
|
219
|
+
├── services.php # External services
|
|
220
|
+
├── session.php # Session
|
|
221
|
+
└── view.php # Views
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## 🌐 Routes (`routes/`)
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
routes/
|
|
230
|
+
├── api.php # Main API routes
|
|
231
|
+
├── api_v1.php # API Version 1 routes
|
|
232
|
+
├── channels.php # Broadcasting channels
|
|
233
|
+
├── console.php # Console commands
|
|
234
|
+
└── web.php # Web routes
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## 📦 Public Assets (`public/`)
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
public/
|
|
243
|
+
├── .htaccess
|
|
244
|
+
├── favicon.ico
|
|
245
|
+
├── index.php # Application entry point
|
|
246
|
+
└── robots.txt
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## 🎨 Resources (`resources/`)
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
resources/
|
|
255
|
+
├── css/
|
|
256
|
+
│ └── app.css
|
|
257
|
+
├── js/
|
|
258
|
+
│ ├── app.js
|
|
259
|
+
│ └── bootstrap.js
|
|
260
|
+
└── views/
|
|
261
|
+
└── welcome.blade.php
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## 💾 Storage (`storage/`)
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
storage/
|
|
270
|
+
├── app/
|
|
271
|
+
│ └── public/ # Public storage (symlinked)
|
|
272
|
+
│
|
|
273
|
+
├── framework/
|
|
274
|
+
│ ├── cache/
|
|
275
|
+
│ │ └── data/
|
|
276
|
+
│ ├── sessions/
|
|
277
|
+
│ ├── testing/
|
|
278
|
+
│ └── views/
|
|
279
|
+
│
|
|
280
|
+
└── logs/ # Application logs
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## 🧪 Tests (`tests/`)
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
tests/
|
|
289
|
+
├── CreatesApplication.php
|
|
290
|
+
├── TestCase.php
|
|
291
|
+
├── Feature/
|
|
292
|
+
│ └── ExampleTest.php
|
|
293
|
+
└── Unit/
|
|
294
|
+
└── ExampleTest.php
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## 📚 Documentation (`docs/`)
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
docs/
|
|
303
|
+
└── AI-GUIDE-COMPLETE.md # Complete AI implementation guide
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## 🛠️ Bootstrap (`bootstrap/`)
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
bootstrap/
|
|
312
|
+
├── app.php # Application bootstrap
|
|
313
|
+
└── cache/ # Framework cache
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## 🎯 Architecture Highlights
|
|
319
|
+
|
|
320
|
+
### 📋 Query Builder Pattern (NEW!)
|
|
321
|
+
Project ini menggunakan **dedicated Query classes** untuk memisahkan logic filtering/searching dari Controller:
|
|
322
|
+
|
|
323
|
+
```php
|
|
324
|
+
app/Queries/
|
|
325
|
+
├── ActivityLogQuery.php
|
|
326
|
+
├── LabelQuery.php
|
|
327
|
+
├── PermissionQuery.php
|
|
328
|
+
├── PostQuery.php
|
|
329
|
+
├── RoleQuery.php
|
|
330
|
+
└── UserQuery.php
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
**Benefits:**
|
|
334
|
+
- ✅ Separation of Concerns
|
|
335
|
+
- ✅ Reusable query logic
|
|
336
|
+
- ✅ Easier testing
|
|
337
|
+
- ✅ Cleaner controllers
|
|
338
|
+
- ✅ Better maintainability
|
|
339
|
+
|
|
340
|
+
### 🔐 Authentication & Authorization
|
|
341
|
+
- **Laravel Sanctum** for API authentication
|
|
342
|
+
- **Spatie Permission** for role-based access control (RBAC)
|
|
343
|
+
- **Activity logging** for audit trails with observers
|
|
344
|
+
|
|
345
|
+
### 📝 Enhanced Request Validation
|
|
346
|
+
Validasi yang lebih lengkap dan granular:
|
|
347
|
+
- **IndexRequest** - Generic pagination & filtering
|
|
348
|
+
- **LoginRequest** - Authentication validation
|
|
349
|
+
- **Attach/Detach/Sync Requests** - Many-to-many relationship operations
|
|
350
|
+
- **Store/Update Requests** - Per-resource validation
|
|
351
|
+
|
|
352
|
+
### 🎯 API Documentation
|
|
353
|
+
- **Scramble** for automatic OpenAPI/Swagger documentation
|
|
354
|
+
- **ScrambleServiceProvider** untuk custom configuration
|
|
355
|
+
- **Versioned API** (V1) dengan struktur yang scalable
|
|
356
|
+
|
|
357
|
+
### 🔨 Custom Commands
|
|
358
|
+
- `php artisan gc` - Generator Command
|
|
359
|
+
- `php artisan gc:wizard` - Interactive wizard
|
|
360
|
+
- `php artisan gc:migration` - Generate from migration
|
|
361
|
+
- `php artisan gc:help` - Help documentation
|
|
362
|
+
|
|
363
|
+
Generator sekarang include:
|
|
364
|
+
- Controller (dengan/tanpa file upload)
|
|
365
|
+
- Model dengan relationships
|
|
366
|
+
- **Query class** untuk filtering
|
|
367
|
+
- Request validation (Store/Update)
|
|
368
|
+
- Migration
|
|
369
|
+
- Auto-register routes
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## 📝 Key Features
|
|
374
|
+
|
|
375
|
+
### ✨ Complete CRUD Architecture
|
|
376
|
+
```
|
|
377
|
+
Request → Controller → Query → Model → Response
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**Flow:**
|
|
381
|
+
1. **Request Validation** (FormRequest)
|
|
382
|
+
2. **Controller** delegates to Query class
|
|
383
|
+
3. **Query Class** handles filtering, searching, sorting
|
|
384
|
+
4. **Model** interacts with database
|
|
385
|
+
5. **Resource** transforms response (optional)
|
|
386
|
+
6. **ApiResponse** standardizes output
|
|
387
|
+
|
|
388
|
+
### 🎨 API Response Format
|
|
389
|
+
Menggunakan `ApiResponse` helper untuk response konsisten:
|
|
390
|
+
```php
|
|
391
|
+
ApiResponse::success($data, 'Message', 200);
|
|
392
|
+
ApiResponse::error('Error message', 400);
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### 📊 Development Tools
|
|
396
|
+
- Query builder pattern
|
|
397
|
+
- File upload service
|
|
398
|
+
- Activity log observers
|
|
399
|
+
- API resource transformers
|
|
400
|
+
|
|
401
|
+
### ✅ Code Quality
|
|
402
|
+
- Form request validation (22 request classes)
|
|
403
|
+
- Query classes for business logic separation
|
|
404
|
+
- Model observers for event handling
|
|
405
|
+
- Service layer for reusable logic
|
|
406
|
+
- Traits for shared functionality
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## 🚀 Tech Stack
|
|
411
|
+
|
|
412
|
+
- **Framework:** Laravel 10.x (^10.10)
|
|
413
|
+
- **PHP:** 8.1+
|
|
414
|
+
- **Authentication:** Laravel Sanctum (^3.3)
|
|
415
|
+
- **Permissions:** Spatie Laravel Permission (^6.13)
|
|
416
|
+
- **API Docs:** Dedoc Scramble (^0.12.35) + Scramble Pro (^0.7.18)
|
|
417
|
+
- **Query Builder:** Spatie Laravel Query Builder (^6.3)
|
|
418
|
+
- **Activity Log:** Spatie Laravel Activity Log (^4.9)
|
|
419
|
+
- **Frontend Build:** Vite
|
|
420
|
+
- **Architecture:** MVC + Query Pattern
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
## 📊 Comparison: Old vs New Structure
|
|
425
|
+
|
|
426
|
+
### Added Features:
|
|
427
|
+
| Feature | Old Branch | Current Branch |
|
|
428
|
+
|---------|-----------|----------------|
|
|
429
|
+
| Query Classes | ❌ | ✅ (6 classes) |
|
|
430
|
+
| Scramble Config | ❌ | ✅ |
|
|
431
|
+
| Request Classes | 6 | 22 (+267%) |
|
|
432
|
+
| ScrambleServiceProvider | ❌ | ✅ |
|
|
433
|
+
| Telescope | ✅ | ❌ (removed) |
|
|
434
|
+
| Query Stub | ❌ | ✅ |
|
|
435
|
+
|
|
436
|
+
### Benefits of Current Architecture:
|
|
437
|
+
✅ Better separation of concerns dengan Query classes
|
|
438
|
+
✅ More granular validation dengan 22+ request classes
|
|
439
|
+
✅ Cleaner controllers (logic di Query classes)
|
|
440
|
+
✅ Easier to test (isolated query logic)
|
|
441
|
+
✅ Scalable untuk fitur complex filtering
|
|
442
|
+
✅ Professional API documentation dengan Scramble
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## 📌 Notes
|
|
447
|
+
|
|
448
|
+
### Architecture Pattern
|
|
449
|
+
Project ini menggunakan **Query Builder Pattern** sebagai enhancement dari standard MVC:
|
|
450
|
+
|
|
451
|
+
```
|
|
452
|
+
┌─────────────┐
|
|
453
|
+
│ Request │ (Validation)
|
|
454
|
+
└──────┬──────┘
|
|
455
|
+
│
|
|
456
|
+
┌──────▼──────┐
|
|
457
|
+
│ Controller │ (Routing logic)
|
|
458
|
+
└──────┬──────┘
|
|
459
|
+
│
|
|
460
|
+
┌──────▼──────┐
|
|
461
|
+
│ Query │ (Business logic, filtering, sorting)
|
|
462
|
+
└──────┬──────┘
|
|
463
|
+
│
|
|
464
|
+
┌──────▼──────┐
|
|
465
|
+
│ Model │ (Data access)
|
|
466
|
+
└──────┬──────┘
|
|
467
|
+
│
|
|
468
|
+
┌──────▼──────┐
|
|
469
|
+
│ Response │ (Transform & format)
|
|
470
|
+
└─────────────┘
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### Generator Command
|
|
474
|
+
Custom artisan commands untuk generate complete CRUD:
|
|
475
|
+
- Model + Migration
|
|
476
|
+
- Controller (dengan Query integration)
|
|
477
|
+
- **Query class** untuk filtering logic
|
|
478
|
+
- Request validation (Store/Update)
|
|
479
|
+
- Auto-register API routes
|
|
480
|
+
- Support file upload
|
|
481
|
+
|
|
482
|
+
### API Documentation
|
|
483
|
+
Scramble automatically generates OpenAPI documentation dari:
|
|
484
|
+
- Controller methods
|
|
485
|
+
- FormRequest validation rules
|
|
486
|
+
- Route definitions
|
|
487
|
+
- Model properties
|
|
488
|
+
|
|
489
|
+
Access di: `/docs/api` (when configured)
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
## 🎓 Best Practices Implemented
|
|
494
|
+
|
|
495
|
+
1. **Request Validation**: All inputs validated via FormRequest
|
|
496
|
+
2. **Query Separation**: Business logic di Query classes
|
|
497
|
+
3. **Resource Transformation**: Consistent API responses
|
|
498
|
+
4. **Activity Logging**: Automatic via Observers
|
|
499
|
+
5. **Type Hinting**: Strong typing throughout
|
|
500
|
+
6. **API Versioning**: Prepared for V2, V3, etc.
|
|
501
|
+
7. **Documentation**: Auto-generated with Scramble
|
|
502
|
+
|
|
503
|
+
---
|
|
504
|
+
|
|
505
|
+
## 📦 Dependencies
|
|
506
|
+
|
|
507
|
+
### Production
|
|
508
|
+
```json
|
|
509
|
+
{
|
|
510
|
+
"php": "^8.1",
|
|
511
|
+
"laravel/framework": "^10.10",
|
|
512
|
+
"laravel/sanctum": "^3.3",
|
|
513
|
+
"dedoc/scramble": "^0.12.35",
|
|
514
|
+
"dedoc/scramble-pro": "^0.7.18",
|
|
515
|
+
"spatie/laravel-permission": "^6.13",
|
|
516
|
+
"spatie/laravel-query-builder": "^6.3",
|
|
517
|
+
"spatie/laravel-activitylog": "^4.9",
|
|
518
|
+
"guzzlehttp/guzzle": "^7.2",
|
|
519
|
+
"laravel/tinker": "^2.8"
|
|
520
|
+
}
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
### Development
|
|
524
|
+
```json
|
|
525
|
+
{
|
|
526
|
+
"laravel/pint": "^1.0",
|
|
527
|
+
"laravel/sail": "^1.18",
|
|
528
|
+
"phpunit/phpunit": "^10.1",
|
|
529
|
+
"spatie/laravel-ignition": "^2.0",
|
|
530
|
+
"fakerphp/faker": "^1.9.1",
|
|
531
|
+
"mockery/mockery": "^1.4.4",
|
|
532
|
+
"nunomaduro/collision": "^7.0"
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
**Last Updated:** October 2025
|
|
539
|
+
**Laravel Version:** 10.x (^10.10)
|
|
540
|
+
**PHP Version:** 8.1+
|