compact(): Undefined variable: operator

前端 未结 4 2266
没有蜡笔的小新
没有蜡笔的小新 2021-02-13 02:22

I\'m getting the following error

  (1/1) ErrorException
  compact(): Undefined variable: operator

This is my line of code

$pos         


        
4条回答
  •  花落未央
    2021-02-13 03:05

    Instead of passing the variable to the compact() method, you'll passe it the name of the variable as a string without the dollar symbol.

    $postsCats = Post::all(); // example
    
    return view('posts.index', compact('postsCats'));
    

提交回复
热议问题