# Generate CRUD

to generate a new CRUD from any table on  your tomato-php generated CRUDs just need to run this command

```
php artisan tomato-flutter:crud
```

now you will get a new module inside your app dir `/flutter/APP_NAME/lib/app/modules/TABLE_NAME` to allow your module inside `/flutter/APP_NAME/lib/app/modules/Modules.dart` add this line

```dart
export 'Auth/AuthModule.dart';
export "Dashboard/DashboardModule.dart";
export "Settings/SettingsModule.dart";
export "Splash/SplashModule.dart";
export "Profile/ProfileModule.dart";
export "Forms/FormsModule.dart";
export "TABLE_NAME/TABLE_NAMEModule.dart";
```

and after that allow the modules to route inside the file `/flutter/APP_NAME/lib/routes/Router.dart` add this line

```dart
import 'package:get/get.dart';

import '/app/modules/Modules.dart';

List<GetPage> routes = [
  /// Basic Routes
  ...splashRoutes,

  /// Auth Routes
  ...authRoutes,

  /// Dashboard Routes
  ...dashboardRoutes,

  /// Setting Routes
  ...settingsRoutes,

  /// Profile Routes
  ...profileRoutes,

  ...formsRoutes,

  ...tableNameRoutes,
];
```

### Add Endpoints to Backend

please note that the generated files will match only APIs generated by TomatoPHP and you need to add APIs routes to the api.php&#x20;

```php
Route::middleware(['auth:sanctum'])->name('api.')->group(function () {
    Route::get('customers', [\Modules\Customers\Http\Controllers\CustomerController::class, 'index'])->name('customers.index');
    Route::post('customers', [\Modules\Customers\Http\Controllers\CustomerController::class, 'store'])->name('customers.store');
    Route::get('customers/{model}', [\Modules\Customers\Http\Controllers\CustomerController::class, 'show'])->name('customers.show');
    Route::post('customers/{model}', [\Modules\Customers\Http\Controllers\CustomerController::class, 'update'])->name('customers.update');
    Route::delete('customers/{model}', [\Modules\Customers\Http\Controllers\CustomerController::class, 'destroy'])->name('customers.destroy');
});Change Endpoint
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tomatophp.com/plugins/tomato-flutter/generate-crud.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
