Skip to content

Tasks Module Deep Dive

This page walks through the built-in Tasks module as a concrete reference for extending SaasForgeKit.

1) Database layer

Tasks are tenant-scoped and support both tenancy modes.

Relevant migrations:

  • Single DB mode:
    • database/migrations/2026_02_22_094519_create_tasks_table.php
  • Multi DB mode:
    • database/migrations/tenant/2026_02_22_094519_create_tasks_table.php

Pattern to follow for new tenant modules:

  • keep a central migration guarded for single-db mode
  • create a tenant migration for multi-db mode

2) Model layer

Task model:

  • app/Models/Task.php

Key points:

  • uses tenant relationship behavior
  • defines fillable fields for mass assignment
  • casts is_completed to boolean

3) Validation layer

Form requests:

  • app/Http/Requests/StoreTaskRequest.php
  • app/Http/Requests/UpdateTaskRequest.php

Pattern to reuse:

  • separate create/update validation
  • keep controller actions lean
  • centralize request rules in Form Requests

4) Controller layer

Controller:

  • app/Http/Controllers/TaskController.php

What it demonstrates:

  • Inertia page rendering (tasks/index)
  • create/update/delete flows
  • route-aware redirects for default and workspace-prefixed contexts
  • safe task resolution from route values

5) Route layer

Routes live in:

  • routes/tenant.php

Key patterns:

  • tasks module is behind auth + tenant initialization
  • access is gated via subscription middleware
  • same CRUD endpoints are exposed for:
    • default tenant context
    • workspace slug context (named workspace.tasks.*)

6) Frontend layer

Inertia page:

  • resources/js/pages/tasks/index.tsx

What it demonstrates:

  • form-based create flow
  • inline edit flow
  • completion toggle
  • delete confirmation flow
  • workspace-aware URL construction

7) Testing layer

Feature tests:

  • tests/Feature/TaskTest.php
  • tests/Feature/MultiDb/TaskTest.php

Coverage includes:

  • auth/subscription access control
  • CRUD behavior
  • tenant isolation boundaries
  • multi-db schema and behavior checks

8) Reuse this blueprint

When creating your own module, clone this sequence:

  1. Schema (single-db + multi-db paths)
  2. Model + factory
  3. Form requests
  4. Controller actions
  5. Tenant routes
  6. Inertia page
  7. Feature tests for both tenancy modes when applicable