Search code examples
laravellaravel-cashier

Laravel Cashier - publish migration results in "cannot declare class CreateCustomersColumns"


I have a fresh Laravel installation and I've added Cashier to my project.

Since the Users model on my app won't have a stripe connection, but rather an Accounts model, I need to alter their migration to add columns to Accounts instead of Users

The documentation says to run:

php artisan vendor:publish --tag="cashier-migrations"

which adds the two migration files to database/migrations

From there I can change users to accounts in the migration file.

When I try to run php artisan migrate, I get:

Whoops\Exception\ErrorException : Cannot declare class CreateCustomerColumns, because the name is already in use

This problem only goes away when I delete the migration files, but then the new columns are added to users.


Solution

  • The documentation states that you can disable their migration files by putting Cashier::ignoreMigrations(); in AppServiceProvider

    I didn't realize that's what I wanted to do. I thought the publish command only published the two files I needed to edit, however, those are the only migration files that come with Cashier.

    Be sure to add Cashier::ignoreMigrations(); in the register method.

    And add use Laravel\Cashier\Cashier;