Laravel make model with migration

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Efficiently Creating Models and Migrations in Laravel 5.x - A Comprehensive Guide Introduction: Laravel is a versatile PHP framework that provides developers with numerous tools to make their application development process more efficient. One of its key features is the ability to manage your database using models and migrations. This blog post will delve into the details of creating Laravel 5 models and the associated migrations, ensuring that you get all the necessary files in one go. The Scenario: You've issued the command `php artisan make:model Settings` to create a new model for your application called "Settings". However, the migration file is not being generated as expected. This blog post aims to guide you through different ways to solve this issue and ensure that both the model and its associated migrations are created simultaneously, saving you time and effort during development. Step-by-Step Guide: 1. Firstly, check your Laravel version and composer.json file: Make sure you're using Laravel 5 or above and examine your composer.json file for any irregularities that might affect the migration generation process. The following code snippet shows a basic structure of a composer.json file:
...
    "require": {
            "php": ">=5.5.9",
            "laravel/framework": "5.1.*"
        },
...
2. Verify your command usage and output: Ensure you're using the correct `make:model` command with the model name (Settings in this case). Check if the output shows that the corresponding migration file is being created alongside the model. Here's an example of such output:
[Illuminate\Foundation\Console\ModelCommand] Creating Model: App\Settings
[Illuminate\Foundation\Console\ModelCommand] Created Model: App\Settings
[Illuminate\Foundation\Console\ModelCommand] Creating Migration: 2018_01_01_00_00_create_settings_table
[PDOStatement] SQL: create table `settings` (id bigint unsigned not null auto_increment, name varchar(255) default NULL, value text, created_at timestamp null, updated_at timestamp null) default character set utf8 collate `utf8_unicode_ci`, engine = InnoDB
If the output indicates that the migration file is being generated but not seen in your project directory, try running `php artisan migrate:refresh` to clear the existing migrations and re-create all tables. If the problem persists, proceed to the next step. 3. Check the Laravel make command cache: The Laravel make commands may occasionally encounter caching issues that prevent them from generating appropriate files. To fix this issue, run the following command: `php artisan clear-compiled`. This will remove all compiled files created by Laravel and allow you to generate a clean project without any caching issues. 4. Update your Laravel version (if necessary): If none of the above steps resolve the problem, you may want to consider updating your Laravel version to the latest stable release. Updating the framework can sometimes be the solution for various unexpected behavior and bugs that could affect the auto-generation of migration files with model creation. 5. Check your database connection configuration: Ensure that your .env file contains the correct database credentials, including the username, password, and host. An incorrect or missing database information might cause problems while creating migrations during model generation. Here's an example of a typical .env file for MySQL:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=password
Conclusion: This comprehensive guide has provided you with the necessary information to troubleshoot and resolve issues when creating models and their associated migration files in Laravel 5. By following these steps, you'll be able to avoid common pitfalls with model generation and ensure a smooth development process for your application. If you encounter any further difficulties, don't hesitate to refer back to this blog post or reach out to us at https://laravelcompany.com/for-developers, where our team of experts can help you overcome these challenges.