Laravel Aiku ERP Development
Expert AI assistant for building and maintaining the Aiku white-label ERP application using Laravel 12, Inertia.js v2, Vue 3, and the complete Laravel ecosystem.
Technology Stack
**Backend**: PHP 8.4.15, Laravel 12, Laravel Horizon, Octane, Sanctum, Scout, Telescope**Frontend**: Vue 3, Inertia.js v2, Tailwind CSS 3, Laravel Echo**Testing**: Pest v4, PHPUnit 12**Code Quality**: Laravel Pint (formatter)**Development**: Laravel Sail, Breeze, EnvoyCore Development Principles
Code Quality Standards
1. **No Comments Policy**: Write clear, self-explanatory code instead of adding comments
2. **Explicit Typing**: Always use explicit return type declarations and parameter type hints
3. **Constructor Promotion**: Use PHP 8 constructor property promotion syntax
4. **Control Structures**: Always use curly braces, even for single-line statements
5. **PHPDoc**: Prefer PHPDoc blocks with array shape definitions over inline comments
6. **Enum Conventions**: Use TitleCase for enum keys (e.g., `FavoritePerson`, `Monthly`)
Laravel Best Practices
**File Creation**:
Always use `php artisan make:*` commands (controllers, models, migrations, etc.)Pass `--no-interaction` to all Artisan commandsUse `php artisan make:class` for generic PHP classesCheck available commands with `list-artisan-commands` tool**Database & Eloquent**:
Prefer Eloquent models and relationships over raw queriesUse `Model::query()` instead of `DB::`Always use eager loading to prevent N+1 query problemsUse proper relationship methods with return type hintsWhen modifying columns in migrations, include ALL previously defined attributes**Validation**:
Create Form Request classes for validation (never inline in controllers)Include both validation rules and custom error messagesCheck sibling Form Requests for array vs string-based rule conventions**Configuration**:
Never use `env()` outside of config filesAlways use `config('app.name')` instead of `env('APP_NAME')`**URL Generation**:
Prefer named routes with `route()` function**Authentication & Authorization**:
Use built-in features: gates, policies, Sanctum**Queues**:
Use queued jobs with `ShouldQueue` interface for time-consuming operationsLaravel 10 Structure (Important)
This application uses Laravel 10 structure (not migrated to Laravel 12 streamlined structure):
Middleware: `app/Http/Middleware/`Service providers: `app/Providers/`Middleware registration: `app/Http/Kernel.php`Exception handling: `app/Exceptions/Handler.php`Console commands: `app/Console/Kernel.php`No `bootstrap/app.php` application configurationInertia.js v2 Development
**Core Concepts**:
Place components in `resources/js/Pages` directoryUse `Inertia::render()` for server-side routing instead of Blade viewsSearch documentation before implementation: `search-docs` tool with queries like `['inertia routing', 'inertia props']`**v2 Features to Leverage**:
PollingPrefetchingDeferred props (add animated skeleton loaders for empty states)Infinite scrolling with merging props and `WhenVisible`Lazy loading data on scroll**Forms**:
Use `<Form>` component (recommended approach)Alternative: `useForm` helper for programmatic controlUse `resetOnError`, `resetOnSuccess`, `setDefaultsOnSuccess` optionsSearch docs: `['form component', 'useForm helper', 'form component resetting']`Example:
```php
// routes/web.php
Route::get('/users', function () {
return Inertia::render('Users/Index', [
'users' => User::all()
]);
});
```
Testing with Pest
**Test Creation**:
Use `php artisan make:test --pest {name}` for feature testsAdd `--unit` flag for unit testsMost tests should be feature testsNever remove tests without approval**Test Coverage**:
Test happy paths, failure paths, and edge casesEvery code change must include a test (new or updated)Use model factories instead of manual model creationCheck factories for custom states before manual setup**Running Tests**:
Minimal targeted runs: `php artisan test --filter=testName`Single file: `php artisan test tests/Feature/ExampleTest.php`All tests: `php artisan test`**Pest Syntax**:
```php
it('returns all users successfully', function () {
$response = $this->postJson('/api/users', []);
$response->assertSuccessful(); // Use specific assertions
});
```
**Assertions**:
Use specific methods: `assertSuccessful()`, `assertForbidden()`, `assertNotFound()`Avoid generic `assertStatus(403)` when specific methods exist**Mocking**:
Import: `use function Pest\Laravel\mock;`Alternative: `$this->mock()` if project conventions prefer it**Faker**:
Use `$this->faker->word()` or `fake()->randomDigit()`Follow existing project conventionsAPI Development
Default to Eloquent API Resources for APIsUse API versioning unless existing routes don'tFollow existing application conventions when presentCode Formatting
**Critical**: Run `vendor/bin/pint --dirty` before finalizing changes (DO NOT run with `--dirty` flag as per project rules - run `vendor/bin/pint` to fix formatting)
Feature Flags with Pennant
This application uses Laravel Pennant for feature flag management across organizations and user types. Use `search-docs` tool for guidance.
Frontend Bundling
If changes don't appear in UI, user may need to run:
`npm run build``npm run dev``composer run dev`Vite manifest errors can be resolved by running `npm run build` or asking user to run dev server.
Architecture Guidelines
**Follow existing conventions**: Check sibling files for structure, naming, and approach**Reuse components**: Check for existing components before creating new ones**Descriptive naming**: Use clear names like `isRegisteredForDiscounts`, not `discount()`**No new base folders**: Stick to existing directory structure without approval**No dependency changes**: Don't modify package.json or composer.json without approval**Concise explanations**: Focus on important details, not obvious informationDocumentation
Only create documentation files when explicitly requestedDo not create verification scripts when tests provide coverageUnit and feature tests are more important than tinker scriptsTool Usage
When available, use specialized tools:
`list-artisan-commands` - Check available Artisan parameters`get-absolute-url` - Generate correct project URLs`tinker` - Execute PHP for debugging or Eloquent queries`database-query` - Read from database directly`browser-logs` - Read browser errors and exceptions (recent only)**`search-docs`** - Search Laravel ecosystem documentation (critically important)Documentation Search Strategy
**Always search documentation before making changes**:
Use multiple broad, simple, topic-based queries: `['rate limiting', 'routing rate limiting', 'routing']`Don't include package names in queries (version info is auto-sent)Use `test resource table`, NOT `filament 4 test resource table`Perfect for: Laravel, Inertia, Livewire, Filament, Tailwind, Pest, Nova, etc.**Search Syntax**:
1. Simple words with auto-stemming: `authentication`
2. Multiple words (AND): `rate limit`
3. Exact phrases: `"infinite scroll"`
4. Mixed: `middleware "rate limit"`
5. Multiple queries: `["authentication", "middleware"]`
Workflow
1. **Check documentation** using `search-docs` tool
2. **Review existing code** in sibling files for conventions
3. **Write or update tests** for all changes
4. **Implement changes** following Laravel best practices
5. **Run targeted tests** with `--filter`
6. **Format code** with `vendor/bin/pint`
7. **Ask user** if they want full test suite run
Example Code Snippets
**Controller with Form Request**:
```php
public function store(StoreUserRequest $request): RedirectResponse
{
$user = User::create($request->validated());
return redirect()->route('users.show', $user);
}
```
**Eloquent Relationship**:
```php
public function posts(): HasMany
{
return $this->hasMany(Post::class);
}
```
**Constructor Promotion**:
```php
public function __construct(
public GitHub $github,
public string $apiKey
) {}
```
This skill ensures high-quality Laravel development following Aiku ERP's specific conventions and the Laravel ecosystem's best practices.