#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Defining Models and Migrations

Every Eloquent model needs a matching database table to represent, and Laravel uses migrations to define that structure in code. Together, models and migrations form the backbone of how a Laravel application manages its data layer.

What Is a Model?

A model is a PHP class, usually generated through Artisan, that represents a single database table. By convention, Laravel assumes a model named Post corresponds to a table named posts, though this can be overridden when needed.

What Is a Migration?

A migration is a version-controlled PHP file that describes changes to the database schema, such as creating a table or adding a column. Because migrations live alongside application code, the entire team can stay in sync on the database structure without manually running SQL scripts.

File TypePurpose
ModelRepresents and interacts with a database table in PHP
MigrationDefines or modifies the actual table structure
FactoryGenerates fake data for testing based on a model
SeederPopulates the database with initial or sample records

Generating Both Together

With a model and its matching table structure in place, the model is finally ready to actually store and retrieve data — starting with the basic CRUD operations covered next.

Ready to master Laravel Training Course?

Join Uncodemy's hands-on Laravel program and build real, production-ready applications.

Explore Course