Aiku ERP Development Assistant
Expert assistant for the Inikoo Aiku open-source white-label ERP web application. Follows strict Laravel best practices, project conventions, and testing requirements.
Core Technology Stack
**Backend**: Laravel 12, PHP 8.4, Laravel Sanctum, Horizon, Octane, Scout, Telescope**Frontend**: Inertia.js v2, Vue 3, Tailwind CSS 3, Ziggy v2**Testing**: Pest v4, PHPUnit v12**Tooling**: Laravel Pint (formatter), Laravel Sail (Docker), PrettierDevelopment Principles
Code Quality Standards
1. **No Code Comments**: Write clear, self-explanatory code instead of adding comments
2. **Explicit Types**: Always use explicit return type declarations and parameter type hints
3. **Constructor Promotion**: Use PHP 8 constructor property promotion
4. **Curly Braces**: Always use curly braces for control structures, even single-line
5. **Follow Conventions**: Check sibling files for structure, approach, and naming before creating new files
The Laravel Way
Use `php artisan make:*` commands to create files (migrations, controllers, models, etc.)Pass `--no-interaction` and appropriate `--options` to Artisan commandsUse Eloquent relationships with return type hints over raw queriesPrefer `Model::query()` over `DB::`Use eager loading to prevent N+1 query problemsStore configuration in config files; never use `env()` outside config filesUse named routes and `route()` function for URL generationDatabase & Models
Always use proper Eloquent relationship methods with return type hintsWhen modifying columns in migrations, include ALL previously defined attributes (or they'll be dropped)Create factories and seeders when creating new modelsUse `casts()` method on models rather than `$casts` property (follow existing conventions)For complex operations, use Laravel's query builderControllers & Validation
Create Form Request classes for validation (never inline validation in controllers)Include both validation rules and custom error messages in Form RequestsCheck sibling Form Requests to determine if the app uses array or string-based rulesUse queued jobs (with `ShouldQueue`) for time-consuming operationsUse Eloquent API Resources and API versioning for APIs (unless existing routes differ)Frontend (Inertia + Vue)
Components live in `resources/js/Pages` directoryUse `Inertia::render()` for server-side routing instead of Blade viewsBuild forms with `<Form>` component or `useForm` helper (follow existing conventions)Use deferred props with nice skeleton loading statesLeverage Inertia v2 features: polling, prefetching, infinite scrolling, lazy loading**Example Inertia Route:**
```php
Route::get('/users', function () {
return Inertia::render('Users/Index', [
'users' => User::all()
]);
});
```
Testing Requirements (Critical)
**Every change must be programmatically tested.**
1. Write a new test or update existing test for your changes
2. Run affected tests to ensure they pass
3. Use minimum necessary tests for speed: `php artisan test --filter=testName`
4. Never remove tests without approval
**Pest Test Structure:**
```php
it('returns all users', function () {
$response = $this->postJson('/api/users', []);
$response->assertSuccessful();
});
```
**Test Commands:**
All tests: `php artisan test`Single file: `php artisan test tests/Feature/ExampleTest.php`Filtered: `php artisan test --filter=testName`**Test Guidelines:**
Use Pest (not PHPUnit syntax)Create tests with `php artisan make:test --pest {name}`Test happy paths, failure paths, and edge casesUse model factories (check for custom states first)Use specific assertions: `assertForbidden()` not `assertStatus(403)`Import mocking: `use function Pest\Laravel\mock;`Use `$this->faker->word()` or `fake()->randomDigit()` (follow conventions)Project Structure
This project uses **Laravel 10 structure** (not migrated to Laravel 12's streamlined structure):
Middleware: `app/Http/Middleware/`Service Providers: `app/Providers/`Middleware registration: `app/Http/Kernel.php`Exception handling: `app/Exceptions/Handler.php`Console/schedule: `app/Console/Kernel.php`Code Formatting
**Before finalizing changes:**
```bash
vendor/bin/pint --dirty
```
Do NOT run with `--test` flag; run without flags to auto-fix formatting.
Common Tasks
Creating a New Model
```bash
php artisan make:model --no-interaction ModelName -mfs
Creates model, migration, factory, seeder
```
Creating a Controller with Form Request
```bash
php artisan make:controller --no-interaction UserController
php artisan make:request --no-interaction StoreUserRequest
```
Running Tests After Changes
```bash
php artisan test --filter=user_creation
```
Frontend Build Issues
If changes aren't reflected or you see Vite manifest errors:
Ask user to run `npm run dev` or `composer run dev`Or run `npm run build` yourselfAuthentication & Authorization
Use Laravel's built-in features: gates, policies, SanctumFeature flags managed via **Laravel Pennant**Important Constraints
**Do not** create documentation files unless explicitly requested**Do not** change dependencies without approval**Do not** create new base folders without approval**Do not** create verification scripts when tests cover the functionality**Do not** use `DB::` when `Model::query()` is appropriate**Be concise** in explanations; focus on what's importantWorkflow
1. **Read existing code**: Check sibling files for conventions
2. **Search documentation**: Use available documentation tools for Laravel ecosystem packages
3. **Write code**: Follow all conventions above
4. **Format code**: Run `vendor/bin/pint --dirty`
5. **Write/update tests**: Ensure programmatic verification
6. **Run tests**: Use filtered test runs for speed
7. **Verify**: Ask user to run full test suite if needed
Example: Adding a New Feature
1. Create model with factory/seeder: `php artisan make:model --no-interaction Product -mfs`
2. Create controller: `php artisan make:controller --no-interaction ProductController`
3. Create form request: `php artisan make:request --no-interaction StoreProductRequest`
4. Implement feature with explicit types and relationships
5. Create Inertia page component in `resources/js/Pages/Products/`
6. Write Pest tests: `php artisan make:test --pest ProductTest`
7. Run tests: `php artisan test --filter=product`
8. Format: `vendor/bin/pint --dirty`
Key Reminders
✅ Write self-explanatory code without comments✅ Use explicit return types and type hints✅ Test every change programmatically✅ Format with Pint before finalizing✅ Use Eloquent relationships and eager loading✅ Follow existing conventions in sibling files✅ Use `php artisan make:*` commands❌ Never skip testing❌ Never use `env()` outside config files❌ Never bypass ORM with raw queries unless necessary