我在Laravel 5商店工作,用户可以在那里买卖东西。在卖方交付物品后,买方可以确认订单并且卖方获得货币。 (仅用于学习Laravel并升级我的技能)
现在我想要编码一个按钮,卖家也可以确认订单并获得Money即时自我,而不仅仅是买家。
买方代码位于PurchaseController
ProfileController
中ProfileController
所有其他卖家工具中。
我在我的TokenMismatchException
中编写代码,但是我收到此错误:
<form action="{{ route('confirm',['uid'=>$sale->uniqueid]) }}" method="post" enctype="multipart/form-data">
<button type="submit" name="button" class="btn btn-success">Confirm</button>
</form>
seller.blade.php:
public function ConfirmDelivery($uniqueid){
$sales = Purchase::where('uniqueid',$uniqueid)->first();
$sales->state = 2;
$sales->save();
$settings = Settings::first();
$fee = (100 - $settings->fee)/100;
if ($sales->product->auction == true) {
$sales->seller->balance += $sales->value*$fee;
$sales->seller->save();
$settings->collected_fee += $sales->value - $sales->value*$fee;
$settings->save();
} else {
$sales->seller->balance += $sales->value*$fee;
$sales->seller->save();
$settings->collected_fee += $sales->value - $sales->value*$fee;
$settings->save();
}
return redirect()->route('oursales');
}
ProfileController可:
Route::post('confirm/{uniqueid}','ProfileController@ConfirmDelivery')->name('confirm');
web.php:
.env.example
任何人都知道如何解决它?
非常感谢!
答案 0 :(得分:0)
当您使用constructor(private http: ProgressHttp) {}
onSubmit(): void {
const _formData = new FormData();
_formData.append('title', this.title);
_formData.append('doc', this.doc);
this.http.withUploadProgressListener(progress => { console.log(`Uploading ${progress.percentage}%`); })
.withDownloadProgressListener(progress => { console.log(`Downloading ${progress.percentage}%`); })
.post('youruploadurl', _formData)
.subscribe((response) => {
console.log(response);
});
}
个链接时,您发送了a href
个请求,并且您的路由为GET
。您应该使用表单发送数据:
POST
答案 1 :(得分:0)
<form action="{{ route('confirm',['uid'=>$sale->uniqueid]) }}" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
<button type="submit" name="button" class="btn btn-success">Confirm</button>
</form>
如果您出于安全原因要创建POST请求,则需要{{ csrf_field() }}
。