2

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.

good_afternoon
  • 1,529
  • 1
  • 12
  • 41
  • check your migration files you must creating CreateCustomerColumns class. change the name of that class. It is already being used somewhere. – Sehdev Feb 24 '20 at 16:36

2 Answers2

4

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;

good_afternoon
  • 1,529
  • 1
  • 12
  • 41
0

The file (and thus the class) must exist twice, probably in your database/migrations directory, most likely with 2 different datetime prefixes on the filenames.

Malki Mohamed
  • 1,578
  • 2
  • 23
  • 40