0Pricing
PHP Academy · Lesson

Eloquent Models and Migrations

Generate models and database migrations with Artisan commands.

What is Eloquent?

Eloquent is Laravel' ActiveRecord ORM. Each database table has a corresponding Model class that represents a row and provides query methods.

Generating a Model

Use Artisan to create a model. Add -m to also generate a migration file.

$ php artisan make:model Post -m
# Creates:
# app/Models/Post.php
# database/migrations/xxxx_create_posts_table.php

All lessons in this course

  1. Eloquent Models and Migrations
  2. CRUD with Eloquent
  3. Eloquent Relationships
  4. Eager Loading and Query Scopes
← Back to PHP Academy