亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Laravel 6 持久未定義變量錯誤

Laravel 6 持久未定義變量錯誤

PHP
繁華開滿天機 2023-07-08 16:45:24
當我嘗試訪問我認為的變量時,遇到未定義的變量錯誤。我在這里經歷了幾種解決方案,但沒有一個對我有用。我已經徹底檢查了可能導致 mu 代碼中出現此錯誤的所有內容,但根本找不到任何內容,請協助控制器namespace App\Http\Controllers;use Illuminate\Http\Request;use App\Product;use App\Category;use App\Depot;use Illuminate\Support\Facades\DB;use Gloudemans\Shoppingcart\Facades\Cart;use Auth;class CheckoutController extends Controller{? ? public function index()? ? {? ? ? ? $allcategories=Category::get();? ? ? ? $delivery_method = DB::table('deliverymethods')? ? ? ? ? ? ->get();? ? ? ? $cartItems=Cart::content();? ? ? ? return view('checkout.index',['delivery_method'=>$delivery_method],['allcategories'=>$allcategories]);? ? }? ? public function deliverymethod()? ? {? ? ? ? $cartItems=Cart::content();? ? ? ? $allcategories=Category::get();? ? ? ? return view('delivery.index',['cartItems'=>$cartItems],['allcategories'=>$allcategories]);? ? }? ? public function billinginfo()? ? {? ? ? ? $depots=Depot::get();? ? ? ? $cartItems=Cart::content();? ? ? ? $allcategories=Category::get();? ? ? ? return view('billing.index',compact('cartItems'),['allcategories'=>$allcategories],['depots'=>$depots]);? ? }? ? public function shipping(Request $request)? ? {? ? ? ? $user_id=Auth::user()->id;? ? ? ? $shippingaddress=DB::table('shippingaddresses')? ? ? ? ? ? ? ? ? ? ? ? ->select('shippingaddresses.*')? ? ? ? ? ? ? ? ? ? ? ? ->where('user_id',$user_id)? ? ? ? ? ? ? ? ? ? ? ? ->get();? ? ? ? $cartItems=Cart::content();? ? ? ? $allcategories=Category::get();? ? ? ? return view('shipping.index',['cartItems'=>$cartItems],['allcategories'=>$allcategories],['shippingaddress'=>$shippingaddress]);? ? }}
查看完整描述

1 回答

?
莫回無

TA貢獻1865條經驗 獲得超7個贊

嘗試將多個集合分組到一個數組中,然后將其發送到視圖,如下所示:


$viewData = [

    'cartItems'  => $cartItems,

    'allcategories'   => $allcategories,

    'shippingaddress' => $shippingaddress

];


return View::make('shipping.index')->with($viewData);


查看完整回答
反對 回復 2023-07-08
  • 1 回答
  • 0 關注
  • 148 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號