close

[Solved] compact(): Undefined variable: operator

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error compact(): Undefined variable: operator in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How compact(): Undefined variable: operator Error Occurs?

Today I get the following error compact(): Undefined variable: operator in php.

How To Solve compact(): Undefined variable: operator Error ?

  1. How To Solve compact(): Undefined variable: operator Error ?

    To Solve compact(): Undefined variable: operator Error There are 2 fixes for this issue
    Downgrade your php to 7.2
    run “composer update” as in latest Laravel this issue has been resolved.

  2. compact(): Undefined variable: operator

    To Solve compact(): Undefined variable: operator Error There are 2 fixes for this issue
    Downgrade your php to 7.2
    run “composer update” as in latest Laravel this issue has been resolved.

Solution 1

Go to your project in

vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php

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

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

You just remove the ‘operator’ parameter.

And I hope it will work fine.

Solution 2

There are 2 fixes for this issue

  1. Downgrade your php to 7.2
  2. run “composer update” as in latest Laravel this issue has been resolved.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment