Skip to content

Instantly share code, notes, and snippets.

@mavuriel
Last active March 11, 2022 04:52
Show Gist options
  • Select an option

  • Save mavuriel/ae72710ba6a1656b900134bc30512777 to your computer and use it in GitHub Desktop.

Select an option

Save mavuriel/ae72710ba6a1656b900134bc30512777 to your computer and use it in GitHub Desktop.
Recopilation for most common/uncommon laravel commands

Commands

Controller

  • php artisan make:controller NombreController

Models

  • php artisan make:model ModelName
    • Create a new model with table relation like:
      • model name with Capitalize letter and singular in english works with a table name in lowercase and plural in english

Eloquent

Tinker

This module help us to use eloquent methods through command line. More info about tinker

Migrations

  • php artisan migrate
    • Execute migrations
  • php artisan make:migration "create {tableName} table"
    • Create a new migration with create_nametable_table structure
  • php artisan migrate:rollback
    • Revert last migration
  • php artisan migrate:fresh
    • Drop all the tables and migrate them again
  • php artisan migrate:refresh
    • Execute one by one down method for migrations and migrate them again
  • php artisan make:migration "add {columnName} to {tableName} table
    • Create a new migration to add a new column for a created table

For modify table columns need to do this

Another flags for php artisan make commands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment