【发布时间】:2020-01-02 01:03:12
【问题描述】:
这是我的 Webhook 控制器中显示错误的部分。一切对我来说都是正确的。我可能会错过什么?
此外,只有处理付款发票 webhook 有效,其他一切都给我下面的 500 错误。
/**
* Get the billable entity instance by Stripe ID.
*
* @param string|null $stripeId
* @return \Laravel\Cashier\Billable|null
*/
protected function getUserByStripeId($stripeId)
{
if ($stripeId === null) {
return;
}
$model = config('cashier.model');
return (new $model)->where('stripe_id', $stripeId)->first();
}
这是我在尝试测试条带 Webhook 时遇到的 500 错误。
Test webhook error: 500
Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App/User' not found in file /.../vendor/laravel/cashier/src/Http/Controllers/StripeWebhookController.php on line 208
我的用户文件在 App\User 中。她是我的用户档案
class User extends Authenticatable
{
use Notifiable, Billable;
protected $connection = 'mongodb';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'username', 'password', 'phone',
];
/**
* The collection name
*
* @var array
*/
protected $collection = 'users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $dates = ['deleted_at'];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
这是我的配置\auth.php
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
【问题讨论】:
-
这听起来像是 Laravel 错误:stackoverflow.com/questions/35821477/…
-
请检查命名空间下和顶部是否有代码'use App\User'。
-
你的用户模型的命名空间是什么,你有没有将你的用户模型导入这个类?回答这两个问题应该可以解决您的问题。
-
@PrafullaKumarSahu 我的 User 模型的命名空间是,命名空间 App;如何将用户模型导入此类?谢谢
-
@rohit 我有'使用 App\User;'命名空间下。谢谢。
标签: php laravel laravel-cashier