Skip to content

Laravel AutoCrud

The AutoCrud trait is a powerful Laravel package that automatically generates CRUD operations, forms, tables, and API endpoints for your Eloquent models. This documentation provides a complete implementation guide.

The AutoCrud trait simplifies model management by:

  • Automatic CRUD Operations: Generate create, read, update, delete operations
  • Dynamic Forms: Auto-generate forms based on field definitions
  • Table Generation: Create data tables with sorting and filtering
  • API Endpoints: Expose RESTful endpoints automatically
  • Relationship Handling: Support for complex relationships including polymorphic
  • Validation: Built-in validation with custom rules support
  • Event Hooks: Lifecycle event handling
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Ismaelcmajada\LaravelAutoCrud\Models\Traits\AutoCrud;
class Product extends Model
{
use AutoCrud;
protected static function getFields(): array
{
return [
[
'name' => 'Name',
'field' => 'name',
'type' => 'string',
'table' => true,
'form' => true,
'rules' => ['required' => true],
],
// More fields...
];
}
}