Source: tony-stark.medium.com

Laravel Generate Model from Database Table

Category: Laravel, Laravel

In this article, I will show you how to generate an Eloquent Model from a database table.

Step Add Eloquent Model Generator to your project: Step Register GeneratorServiceProvider: If you are using Laravel version 5.5 or higher this step can be omitted since this project supports Package Discovery feature. Step Configure your database connection.

Use table-name option to specify another table name: In this case generated model will contain protected $table = 'user' property.

Add next lines at your config/eloquent_model_generator.php: Table user: Command: Result: If you use this package code generator automatically generates doc for your models.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners