PHPackages                             noouh/migration-to-model - 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. noouh/migration-to-model

ActiveLibrary

noouh/migration-to-model
========================

A Laravel package to convert migrations into models

1(1y ago)09PHPPHP &gt;=7.3

Since Jul 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mohamedhekal/convert-migration-to-models-laravel)[ Packagist](https://packagist.org/packages/noouh/migration-to-model)[ RSS](/packages/noouh-migration-to-model/feed)WikiDiscussions main Synced 1mo ago

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

Migration to Model
==================

[](#migration-to-model)

Migration to Model is a Laravel package that converts your database migrations into Eloquent models. It generates fillable properties, table names, and relationships based on your migration files.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require noouh/migration-to-model
```

Usage
-----

[](#usage)

To convert a specific migration file into a model, you can use the following artisan command:

```
php artisan migrations:convert {migration}
```

Replace `{migration}` with the name of your migration file (without the timestamp). For example, if your migration file is `2024_07_23_000000_create_users_table.php`, you would use:

```
php artisan migrations:convert create_users_table
```

To convert all migration files into models, simply run:

```
php artisan migrations:convert
```

This command will generate model files in the `app/Models` directory with the appropriate fillable properties, table names, and relationship methods based on detected foreign keys.

Example
-------

[](#example)

Suppose you have the following migration file:

```
