compact(): Undefined variable: operator

前端 未结 4 2261
没有蜡笔的小新
没有蜡笔的小新 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 02:51

    Please refer to this https://github.com/laravel/framework/issues/26936

    The version of Laravel would need to be updated.

    0 讨论(0)
  • 2021-02-13 03:01

    Go to your project in vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php

    In line number 1337, you can found below code inside the addWhereExistsQuery method

    $this->wheres[] = compact('type', 'operator', 'query', 'boolean');

    you just remove the 'operator' paramiter

    and I hope it will work fine

    0 讨论(0)
  • 2021-02-13 03:03

    If you are not able to upgrade your Laravel, you just could change your Query to RAW query, it worked for me.

    0 讨论(0)
  • 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'));
    
    0 讨论(0)
提交回复
热议问题