当我尝试访问我认为的变量时,遇到未定义的变量错误。我在这里经历了几种解决方案,但没有一个对我有用。我已经彻底检查了可能导致 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 关注
- 116 浏览
添加回答
举报
0/150
提交
取消