Inertia Integration

Introduction

If you're building an Inertia.js app, use TranquilInertiaController, which mixes in InertiaResponses to render Inertia pages for each resource response.

Usage

1use Tranquil\Controllers\TranquilInertiaController;
2 
3class CarController extends TranquilInertiaController {
4 protected string $modelClass = Car::class;
5}

Component Paths

  • Defaults are derived from your model class name using plural CamelCase. For a Car model, defaults are:
    • Index: Cars/Index
    • Create: Cars/CreateEdit
    • Show: Cars/Show
    • Edit: Cars/CreateEdit

Override paths via public properties on the controller:

1public string $componentPathPrefix = 'Admin/Cars';
2public string $indexPath = 'Admin/Cars/Index';
3public string $createPath = 'Admin/Cars/CreateEdit';
4public string $showPath = 'Admin/Cars/Show';
5public string $editPath = 'Admin/Cars/CreateEdit';

Response Parameters

  • The base controller builds parameter arrays for each response type. You can customize them by overriding methods like getIndexResponseParameters(), getCreateResponseParameters(), etc.

Policies

  • All Tranquil controllers enforce policies. Ensure your policy methods (viewAny, view, create, update, delete) are implemented for your model.