Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Lift Laravel Package

wendelladriel/laravel-lift

Experimental Laravel package that supercharges Eloquent models with typed public properties matching your schema, powered by PHP 8 attributes. Add validation rules and other metadata directly on models and access them via handy methods, using Eloquent events for easy drop-in use.

View on GitHub
Deep Wiki
Context7

lift:migration

⚠️ This is an experimental feature, keep that in mind when using it

The lift:migration command allows you to generate a migration file based on your models. By default, it uses the App\Models namespace, but you can change it using the --namespace option.

All the created migration files will be placed inside the database/migrations folder.

Examples

The command below will generate a migration file for the App\Models\User model.

php artisan lift:migration User

The command below will generate a migration file for the App\Models\Auth\User model.

php artisan lift:migration Auth\User

The command below will generate a migration file for the App\Custom\Models\User model.

php artisan lift:migration User --namespace=App\Custom\Models

Create Table Migration

When the table for your model is not yet created in the database, the lift:migration command will generate a migration file to create the table.

// User.php

final class User extends Model
{
    use Lift, SoftDeletes;

    public int $id;

    public string $name;

    public string $email;

    public string $password;

    public CarbonImmutable $created_at;

    public DateTime $updated_at;

    public ?bool $active;

    public $test;
}

// Migration file generated

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email');
            $table->string('password');
            $table->boolean('active')->nullable();
            $table->string('test');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('users');
    }
};

Update Table Migration

When the table for your model is already created in the database, the lift:migration command will generate a migration file to update the table based on the differences between the model and the database table.

// User.php

final class User extends Model
{
    use Lift, SoftDeletes;

    public int $id;

    public string $name;

    public string $username;

    public string $email;

    public string $password;

    public ?bool $active;
}

// Migration file generated

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('username')->after('name');
            $table->dropColumn('created_at');
            $table->dropColumn('updated_at');
            $table->dropColumn('test');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Nothing to do here
    }
};
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope