當我嘗試訪問我認為的變量時,遇到未定義的變量錯誤。我在這里經歷了幾種解決方案,但沒有一個對我有用。我已經徹底檢查了可能導致 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);
- 1 回答
- 0 關注
- 148 瀏覽
添加回答
舉報
0/150
提交
取消