jdion84/lucid

Declare database schemas inside Laravel models.

Maintainers

Details

github.com/jdion84/lucid

Source

Issues

Installs: 6

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/jdion84/lucid

1.0.0 2024-02-16 02:04 UTC

This package is auto-updated.

Last update: 2025-10-16 06:26:50 UTC


README

Declare database schemas inside Laravel models.

Installation

Require this package via composer:

composer require jdion84/lucid

Usage

Create a new model class with a schema method:

php artisan make:schema Post

Or, add a schema method to an existing model:

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Jdion84\Lucid\Table;

class Post extends Model
{
    use HasFactory;

    public function schema(Table $table)
    {
        $table->id();
        $table->string('title')->index();
        $table->text('body');
        $table->timestamp('created_at');
        $table->timestamp('updated_at');
    }
}

Migrate & sync model schema methods with the database:

php artisan migrate:schemas

Commands

Create a new model class with a schema method:

php artisan make:schema {name} {--p|pivot} {--force}

Migrate & sync model schema methods with the database:

migrate:schemas {--f|fresh} {--s|seed} {--force}