我将这些拖曳功能复制到我的API控制器中
public function PostCardCompleteData(Request $request){
if($request->input('card') != ''){
$validator = $this->ValidateFactor($request);
if ($validator->fails()) {
self::$result_json['error'] = 1 ;
self::$result_json['error_code'] = 1 ;
self::$result_json['msg'] = $validator->messages()->first();
}else {
$Payment = $this->InsertPaymentAndRequest($request);
$User = $request->all();
$User['city'] = DB::table('cities')->where('id', $request->input('city'))->first();
$User['state'] = DB::table('state')->where('id', $request->input('state'))->first();
$User['card'] = $request->input('card');
self::$result_json['success'] = 1;
self::$result_json['user_data'] = $User;
self::$result_json['payment'] = Hashids::encode($Payment);
}
}
else{
self::$result_json['error'] = 1;
self::$result_json['error_code'] = 1;
self::$result_json['msg'] = ' سبد خرید شما خالی میباشد ';
}
return response()->json(self::$result_json);
}
public function InsertPaymentAndRequest($request){
$Card = $request->input('card');
$All = $this->group_by('seller_id',$Card);
$Tax = DB::table('setting')->where('param','tax')->first()->value ;
$Payment = DB::table('payment')
->insertGetId([
'id_user_app' => $request->get('token') ,
'factor_table' => 'shop_request' ,
'status' => 0 ,
'id_value' => 0 ,
'price' => 0 ,
'created_at' => Carbon::now() ,
'updated_at' => Carbon::now()
]);
$AllPrice = 0 ;
$Factors = [] ;
foreach ($All as $key => $value){
$AllPriceThisFactor = 0 ;
$Factor = $this->InsertFactor($Payment,$key,$request);
array_push($Factors,$Factor);
foreach ($value as $item){
$Product = DB::table('shop_product')
->where('id',$item['id_product'])
->first();
$this->InsertFactorProduct($Product,$Factor,$Payment,$item['count'],$request->get('token'));
if($Product->discount == 1){
$price = $Product['dis_price'] ;
}
else{
$price = $Product->price ;
}
$AllPrice = $AllPrice + ( $item['count']* $price );
$AllPriceThisFactor = $AllPriceThisFactor + ( $item['count'] * $price );
}
DB::table('shop_request')
->where('id',$Factor)
->update([
'price' => $AllPriceThisFactor + (($AllPriceThisFactor / 100) * $Tax),
'tax' => ($AllPriceThisFactor / 100) * $Tax
]);
}
DB::table('payment')
->where('id',$Payment)
->update([
'price' => $AllPrice + (($Tax / 100) * $AllPrice),
'tax' => ($Tax / 100) * $AllPrice ,
'id_value' => ','.implode(",",$Factors).','
]);
return $Payment;
}
但是我遇到了这个错误
(E_PARSE)语法错误,意外的“ App”(T_STRING)
在我的服务器中 我检查了所有东西,并在本地使用此功能进行了响应,但是服务器上有错误... 这是我在服务器上的第一个控制器
<?php
namespace App\Http\Controllers\API\Shop;
use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Vinkla\Hashids\Facades\Hashids;
class ShopController extends Controller
还有另外一件事,在我复制此函数之前,我没有这个错误