Some Laravel useful commands

Create a Model (table representation & his relations)

php artisan make:model {Tabla}

Create a Controller (the logic). Name in singular

php artisan make:controller PhotoController --resource // --model=Photo

php artisan make:controller {SingularTableName}

php artisan make:controller API

Create file migration (table blueprint)

php artisan make:migration create_{table}_table
php artisan make:migration {action}_table

Create a Request

php artisan make:request StoreCommentsExternal

Create a file Seeder (to feed tables)

php artisan make:seeder {Tabla}TableSeeder

Process only the file database/seeds/{Table}Seeder

php artisan db:seed --class={Table}Seeder

When a table is created and you need to insert a new field, you need to create a new “migration” that only create the new field blueprint.

For example, if you need to insert a new field called “descripcion” to the table “roles”, create a new migration. Edit the file and then run the migration.

php artisan make:migration add_descripcion_to_roles --table="roles"
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('roles', function (Blueprint $table) {
            $table->timestamp('descripcion')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('roles', function (Blueprint $table) {
            $table->dropColumn('descripcion');
        });
    }
php artisan migrate

To go backward (rollback) in the migration

php artisan migrate:rollback

Other Commands

composer require laravel/ui --dev
sudo php artisan ui bootstrap --auth
npm install && npm run dev

php artisan route:list

php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:cache

composer dump-autoload