I would like to change the default cashier's model to my custom model (Users to Companies)
What i have done is
php artisan migrate will still update cashier's default model that is Users
// services.php
'stripe' => [
'model' => App\Models\Companies\Companies::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
'webhook' => [
'secret' => env('STRIPE_WEBHOOK_SECRET'),
'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300),
],
],
CASHIER_MODEL=App\Models\Companies\Companies // on .env
// on migration
public function up()
{
Schema::table('companies', function (Blueprint $table) {
$table->string('stripe_id')->nullable()->collation('utf8mb4_bin')->index();
$table->string('card_brand')->nullable();
$table->string('card_last_four', 4)->nullable();
$table->timestamp('trial_ends_at')->nullable();
});
}
Laravel keeps loading the Cashier migrations from the vendor folder even if you have published them to the database/migrations folder and edited them.
The solution is to explicitly tell Laravel to ignore the vendor migrations.
Add the following to the register method of the AppServiceProvider:
// Use the Cashier migrations from migration folder instead of vendor folder
Cashier::ignoreMigrations();
Remember to also include:
use Laravel\Cashier\Cashier;