ujj*_*tha 0 php laravel stripe-payments laravel-cashier
我想将默认收银员模型更改为我的自定义模型(用户到公司)
我所做的是
php artisan migrate 仍会更新收银员的默认模型,即 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();
});
}
Run Code Online (Sandbox Code Playgroud)
小智 7
Laravel 会不断从供应商文件夹加载 Cashier 迁移,即使您已将它们发布到数据库/迁移文件夹并进行编辑。
解决方案是明确告诉 Laravel 忽略供应商迁移。
将以下内容添加到AppServiceProvider的register方法中:
// Use the Cashier migrations from migration folder instead of vendor folder
Cashier::ignoreMigrations();
Run Code Online (Sandbox Code Playgroud)
请记住还包括:
use Laravel\Cashier\Cashier;
Run Code Online (Sandbox Code Playgroud)