Php 如何获取要保存在数据库中的唯一标识符
我正在建立一个网站,允许用户在付款后上传一个文件到我的网站。如何从条带中获取唯一标识符、令牌、id等,以便保存在数据库中 标识符必须是唯一的;我想用它作为一种安全措施来运行Php 如何获取要保存在数据库中的唯一标识符,php,laravel,laravel-5,stripe-payments,Php,Laravel,Laravel 5,Stripe Payments,我正在建立一个网站,允许用户在付款后上传一个文件到我的网站。如何从条带中获取唯一标识符、令牌、id等,以便保存在数据库中 标识符必须是唯一的;我想用它作为一种安全措施来运行if语句,确保用户在允许上传之前付费 比如: if($newfile->stripe\u identifier===$stripe\u identifier){ //允许用户上传 } 您可以在这种情况下使用 我想这就是我们成功充电后得到的response/JSON对象: 我将定义一个支付模型,并使其与用户建立一对一的关系:
if
语句,确保用户在允许上传之前付费
比如:
if($newfile->stripe\u identifier===$stripe\u identifier){
//允许用户上传
}
您可以在这种情况下使用
我想这就是我们成功充电后得到的response/JSON对象:
我将定义一个支付模型,并使其与用户建立一对一的关系:
class User
{
public function payment()
{
return $this->hasOne(Payment::class);
}
}
您可以通过以下方式向用户收费:
try {
$response = $user->charge(100);
// Persist the response object for later use.
$user->payment()->create([
'stripe_id' => $response->id,
'status' => $response->status,
]);
} catch (Exception $e) {
//
}
稍后,当用户实际上载文件时:
FilesController
{
public function store()
{
abort_unless(
optional(auth()->user()->payment)->status === 'paid',
402,
"Please pay before uploading a file."
);
// Proceed uploading the file.
}
}
这是最基本的想法。您可以在本例中使用
我想这就是我们成功充电后得到的response/JSON对象:
我将定义一个支付模型,并使其与用户建立一对一的关系:
class User
{
public function payment()
{
return $this->hasOne(Payment::class);
}
}
您可以通过以下方式向用户收费:
try {
$response = $user->charge(100);
// Persist the response object for later use.
$user->payment()->create([
'stripe_id' => $response->id,
'status' => $response->status,
]);
} catch (Exception $e) {
//
}
稍后,当用户实际上载文件时:
FilesController
{
public function store()
{
abort_unless(
optional(auth()->user()->payment)->status === 'paid',
402,
"Please pay before uploading a file."
);
// Proceed uploading the file.
}
}
这是最基本的想法。我想你可以将你的文件与条带收费相关联,例如,在提出收费请求时(
ch_xxxyyyyyzz
)?我想您可以将您的文件与条带收费相关联,例如,在提出收费请求(ch_xxxyyyyzz
)时,$ch->id
)?