PHPackages                             elgohr/laravel-trans-builder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. elgohr/laravel-trans-builder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

elgohr/laravel-trans-builder
============================

A professional UI-based migration builder for Laravel Translatable package

v1(3mo ago)34MITPHPPHP ^8.1

Since Mar 22Pushed 3mo agoCompare

[ Source](https://github.com/AmirElgohr126/laravel-prince-trans)[ Packagist](https://packagist.org/packages/elgohr/laravel-trans-builder)[ RSS](/packages/elgohr-laravel-trans-builder/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Translatable Migration Builder
==============================

[](#translatable-migration-builder)

A professional UI-based migration builder for Laravel that simplifies creating database tables with full translatable field support using the Astrotomic Laravel Translatable package.

🎯 Features
----------

[](#-features)

### Core Features

[](#core-features)

- **Visual UI Builder** - Intuitive interface to design database tables using a phpMyAdmin-like builder
- **Translatable Fields** - Seamlessly separate translatable and non-translatable columns
- **Automatic Translation Tables** - Auto-generates translation tables with proper constraints
- **Full Customization** - Configure every aspect of your table structure
- **Live Preview** - Preview generated migration and model code before export
- **One-Click Download** - Export migration and model files directly
- **Generate In Project** - Write migration, models, repository files, and seeder directly into your Laravel project
- **Artisan Command** - Quick access via `php artisan translatable:builder`

### Advanced Features

[](#advanced-features)

- Multiple primary key types (Auto-increment, Big ID, UUID)
- Foreign key management with cascade actions
- Database engine and charset configuration
- Soft deletes support
- Timestamps management
- Custom naming for translation tables and foreign keys
- Column reordering
- Edit/remove columns before generation
- Model generation with Translatable integration
- Repository generation with admin CRUD pattern
- Seeder generation for main and translation tables

📦 Installation
--------------

[](#-installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require elgohr/laravel-trans-builder
```

### 2. Publish Configuration (Optional)

[](#2-publish-configuration-optional)

```
php artisan vendor:publish --tag=translatable-builder-config
```

### 3. Requirements

[](#3-requirements)

- PHP 8.1+
- Laravel 10.0+
- Livewire 3.0+

Astrotomic Translatable is optional for installation. If installed, generated models include the trait usage automatically.

🚀 Quick Start
-------------

[](#-quick-start)

### Access the Builder

[](#access-the-builder)

**Option 1: Web Route**

```
http://your-app.test/translatable-builder

```

**Option 2: Artisan Command**

```
php artisan translatable:builder

# With auto-serve
php artisan translatable:builder --serve
```

### Basic Workflow

[](#basic-workflow)

1. **Step 1: Basic Configuration**

    - Enter table name
    - Configure primary key, engine, charset
    - Set timestamps, soft deletes options
    - Customize translation table names (optional)
2. **Step 2: Add Columns**

    - Click "Add Column"
    - Configure each column:
        - Name, type, length/precision
        - Nullable, default values
        - Indexes (unique, index)
        - Foreign keys
        - **Mark as "Translatable"** ✨
3. **Step 3: Preview**

    - Review generated migration
    - Review generated model
    - Copy code, download files, or generate directly in project
4. **Step 4: Use Generated Files**

    - Place migration in `database/migrations/`
    - Place model in `app/Models/`
    - Run `php artisan migrate`
5. **Optional: Generate In Project (Recommended)**

    - Click `Generate In Project` in Preview
    - The package generates automatically:
        - Migration in `database/migrations`
        - Model folder in `app/Models/{Model}`
        - `{Model}.php`
        - `{Model}Translation.php`
        - `{Model}Repository.php`
        - `{Model}EloquentRepository/Eloquent{Model}Repository.php`
        - `{Model}Seeder.php` in `database/seeders`

🖼️ Interface Screenshots
------------------------

[](#️-interface-screenshots)

### Table Configuration (Step 1)

[](#table-configuration-step-1)

[![Table Configuration](./table_builder.png)](./table_builder.png)

### Columns Builder (Step 2)

[](#columns-builder-step-2)

[![Columns Builder](./column_builder.png)](./column_builder.png)

### Generated Migration Output

[](#generated-migration-output)

[![Generated Migration](./example_builder.png)](./example_builder.png)

🎨 Usage Examples
----------------

[](#-usage-examples)

### Building a Blog System

[](#building-a-blog-system)

**Table Configuration:**

- Table Name: `posts`
- Timestamps: ✓
- Soft Deletes: ✓

**Columns:**

1. `user_id` (foreignId) → `users.id`
2. `title` (string, 200) → **Translatable** ✓
3. `slug` (string, 200) → **Translatable** ✓
4. `content` (text) → **Translatable** ✓
5. `excerpt` (text, nullable) → **Translatable** ✓
6. `is_published` (boolean, default: false)
7. `published_at` (dateTime, nullable)
8. `view_count` (integer, default: 0)

**Generated Files:**

Migration:

```
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
    $table->boolean('is_published')->default(false);
    $table->dateTime('published_at')->nullable();
    $table->integer('view_count')->default(0);
    $table->softDeletes();
    $table->timestamps();
});

Schema::create('posts_translations', function (Blueprint $table) {
    $table->id();
    $table->string('title');
    $table->string('slug');
    $table->text('content');
    $table->text('excerpt')->nullable();
    $table->string('locale')->index();
    $table->unique(['posts_id', 'locale']);
    $table->foreign('posts_id')->references('id')->on('posts')->cascadeOnDelete();
});
```

Model:

```
class Post extends Model
{
    use Translatable;

    public $translatedAttributes = ['title', 'slug', 'content', 'excerpt'];

    protected $casts = [
        'is_published' => 'boolean',
        'published_at' => 'datetime',
        'view_count' => 'integer',
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}
```

### Building a Product Catalog

[](#building-a-product-catalog)

**Table Configuration:**

- Table Name: `products`
- Timestamps: ✓
- Engine: InnoDB
- Charset: utf8mb4

**Columns:**

1. `sku` (string, 100, unique)
2. `price` (decimal, 10, 2, default: 0)
3. `stock` (integer, default: 0, nullable)
4. `is_active` (boolean, default: true)
5. `category_id` (foreignId) → `categories.id`
6. `name` (string, 200) → **Translatable** ✓
7. `description` (text) → **Translatable** ✓
8. `slug` (string) → **Translatable** ✓

⚙️ Configuration
----------------

[](#️-configuration)

### Config File: `config/translatable-builder.php`

[](#config-file-configtranslatable-builderphp)

```
return [
    // Enable/disable builder
    'enabled' => env('TRANSLATABLE_BUILDER_ENABLED', true),

    // Route configuration
    'route_prefix' => 'translatable-builder',
    'middleware' => ['web'],

    // File paths
    'migration_path' => 'database/migrations',
    'model_path' => 'app/Models',
    'seeder_path' => 'database/seeders',
    'model_namespace' => 'App\\Models',

    // Available column types
    'column_types' => [
        'string', 'text', 'integer', 'bigInteger', 'decimal',
        'float', 'boolean', 'date', 'dateTime', 'time', 'json',
        'jsonb', 'uuid', 'enum', 'foreignId', 'morphs',
    ],

    // Available index types
    'index_types' => [
        'index' => 'Index',
        'unique' => 'Unique',
        'primary' => 'Primary Key',
    ],
];
```

🔑 Key Concepts
--------------

[](#-key-concepts)

### Translatable Columns

[](#translatable-columns)

When you mark a column as "Translatable":

- It's **removed** from the main table
- It's **added** to the translations table
- The builder automatically handles:
    - Translation table creation
    - Locale column (indexed)
    - Foreign key to main table
    - Unique constraint on `[foreign_key, locale]`

### Example Structure

[](#example-structure)

**Before (without Translations):**

```
$table->string('name');
$table->text('description');
```

**After (with Translations):**

```
Main Table (products):
- id
- sku
- price
- stock
- created_at
- updated_at

Translations Table (products_translations):
- id
- products_id (foreign key)
- locale (indexed)
- name
- description
- unique(products_id, locale)

```

📁 Package Structure
-------------------

[](#-package-structure)

```
translatable-migration-builder/
├── config/
│   └── translatable-builder.php          # Configuration
├── resources/
│   ├── views/
│   │   ├── index.blade.php               # Main view
│   │   └── livewire/
│   │       └── builder.blade.php         # Livewire component
│   ├── css/
│   │   └── builder.css                   # Styling (optional)
│   ├── js/
│   │   └── builder.js                    # JavaScript (optional)
│   └── examples/
│       ├── 2024_03_22_120000_create_products_table.php
│       └── Product.php
├── routes/
│   └── web.php                           # Routes
├── src/
│   ├── Builders/
│   │   ├── Column.php                    # Column model
│   │   └── Table.php                     # Table model
│   ├── Commands/
│   │   └── LaunchBuilderCommand.php      # Artisan command
│   ├── Generators/
│   │   ├── MigrationGenerator.php        # Migration code generator
│   │   └── ModelGenerator.php            # Model code generator
│   ├── Http/
│   │   └── Controllers/
│   │       └── BuilderController.php     # Route controller
│   ├── Livewire/
│   │   └── BuilderComponent.php          # Livewire component
│   ├── Support/                          # Helper utilities (optional)
│   ├── Contracts/                        # Interfaces (optional)
│   └── TranslatableMigrationBuilderServiceProvider.php
├── composer.json
└── README.md

```

🛠️ Architecture
---------------

[](#️-architecture)

### Builder Classes

[](#builder-classes)

**Column.php** - Represents a single database column

```
$column = new Column('title', 'string');
$column->setLength(200)
       ->setNullable(false)
       ->setTranslatable(true);
```

**Table.php** - Represents a complete table structure

```
$table = new Table('products');
$table->setPrimaryKey('id')
      ->setTimestamps(true)
      ->addColumn($column);
```

### Generators

[](#generators)

**MigrationGenerator.php** - Generates Laravel migration PHP code

```
$generator = new MigrationGenerator();
$code = $generator->generate($table);
$filename = $generator->getFilename($table);
```

**ModelGenerator.php** - Generates Laravel model with Translatable trait

```
$generator = new ModelGenerator();
$code = $generator->generate($table);
```

### Livewire Component

[](#livewire-component)

**BuilderComponent.php** - Manages UI state and interactions

- `addColumn()` - Add new column
- `removeColumn()` - Remove column
- `updateColumn()` - Update column properties
- `goToStep()` - Navigate between steps
- `generatePreview()` - Generate preview code
- `downloadMigration()` - Export migration file
- `downloadModel()` - Export model file
- `generateInProject()` - Generate migration, models, repository files, and seeder directly in Laravel project

🎯 Best Practices
----------------

[](#-best-practices)

### Table Naming

[](#table-naming)

```
// Use plural form for tables
products, users, posts, categories

// Translation tables auto-generated as
products_translations, users_translations, etc.
```

### Column Naming

[](#column-naming)

```
// Use snake_case
user_id, category_id, product_name

// Foreign keys follow convention
{singular_table}_id (user_id, category_id)
```

### Translatable Fields

[](#translatable-fields)

```
// Good - Textual content
title, description, content, slug, meta_title, meta_description

// Bad - Config/status fields (should NOT be translatable)
is_active, status, price, stock
```

🔒 Security
----------

[](#-security)

### Access Control

[](#access-control)

By default, the builder is accessible to all authenticated users. Restrict access by modifying middleware:

```
// config/translatable-builder.php
'middleware' => ['web', 'auth', 'admin'], // Add custom middleware
```

### Environment Control

[](#environment-control)

```
// .env
TRANSLATABLE_BUILDER_ENABLED=true  # Set to false in production
```

🐛 Troubleshooting
-----------------

[](#-troubleshooting)

### Builder not loading?

[](#builder-not-loading)

1. Ensure Livewire is properly installed
2. Check if route is accessible: `php artisan route:list | grep translatable`
3. Verify `TRANSLATABLE_BUILDER_ENABLED` is `true` in .env

### Generated migration fails?

[](#generated-migration-fails)

1. Check table name doesn't conflict with existing tables
2. Verify foreign key references exist
3. Ensure column names are valid MySQL identifiers

### Model not working with Translatable?

[](#model-not-working-with-translatable)

1. Verify `$translatedAttributes` are set correctly
2. Check foreign key names match migration
3. Ensure Astrotomic package is installed

📚 Additional Resources
----------------------

[](#-additional-resources)

- [Astrotomic Translatable Docs](https://github.com/Astrotomic/laravel-translatable)
- [Laravel Migrations](https://laravel.com/docs/migrations)
- [Livewire Documentation](https://livewire.laravel.com/)

📝 License
---------

[](#-license)

MIT License - See LICENSE file

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please submit issues and pull requests.

📧 Support
---------

[](#-support)

For issues, questions, or feature requests, please open an issue on GitHub.

---

**Built with ❤️ for Laravel developers who value clean, translatable databases**

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance82

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

97d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/150277873?v=4)[Amir Nagy Elgohr](/maintainers/AmirElgohr126)[@AmirElgohr126](https://github.com/AmirElgohr126)

---

Top Contributors

[![AmirElgohr126](https://avatars.githubusercontent.com/u/150277873?v=4)](https://github.com/AmirElgohr126 "AmirElgohr126 (8 commits)")

### Embed Badge

![Health badge](/badges/elgohr-laravel-trans-builder/health.svg)

```
[![Health](https://phpackages.com/badges/elgohr-laravel-trans-builder/health.svg)](https://phpackages.com/packages/elgohr-laravel-trans-builder)
```

###  Alternatives

[nasirkhan/laravel-starter

A CMS like modular Laravel starter project.

1.4k2.7k](/packages/nasirkhan-laravel-starter)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21255.6k](/packages/ramonrietdijk-livewire-tables)[lakm/laravel-comments

Integrate seamless commenting functionality into your Laravel project.

40614.3k1](/packages/lakm-laravel-comments)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1319.7k3](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.2k](/packages/tomshaw-electricgrid)[marcorieser/statamic-livewire

A Laravel Livewire integration for Statamic.

23100.9k12](/packages/marcorieser-statamic-livewire)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
