src/Metable.php
public function scopeWhereMeta(Builder $q, string $key, $operator, $value = null)
    {
        // Shift arguments if no operator is present.
        if (!isset($value)) {
            $value = $operator;
            $operator = '=';
        }

        // Convert value to its serialized version for comparison.
        if (!is_string($value)) {
            $value = $this->makeMeta($key, $value)->getRawValue();
        }

        $q->whereHas('meta', function (Builder $q) use ($key, $operator, $value) {
            $q->where('key', $key);
            $q->where('value', $operator, $value);
        });
    }
public function scopeWhereMeta(Builder $q, string $key, $operator, $value = null)
    {
        // Shift arguments if no operator is present.
        if (!isset($value)) {
            $value = $operator;
            $operator = '=';
        }

        // Convert value to its serialized version for comparison.
        if (!is_string($value)) {
            $value = $this->makeMeta($key, $value)->getRawValue();
        }

        $q->whereHas('meta', function (Builder $q) use ($key, $operator, $value) {
            $q->where('key', $key);
            $q->where('value', $operator, $value);
        });
    }
public function scopeWhereMeta ( Builder $ q , string $ key , $ operator , $ value = null ) { // Shift arguments if no operator is present. if ( ! isset ( $ value ) ) { $ value = $ operator ; $ operator = '=' ; } // Convert value to its serialized version for comparison. if ( ! is_string ( $ value ) ) { $ value = $ this -> makeMeta ( $ key , $ value ) -> getRawValue ( ) ; } $ q -> whereHas ( 'meta' , function ( Builder $ q ) use ( $ key , $ operator , $ value ) { $ q -> where ( 'key' , $ key ) ; $ q -> where ( 'value' , $ operator , $ value ) ; } ) ; }
Query scope to restrict the query to records which have `Meta` with a specific key and value.

If the `$value` parameter is omitted, the $operator parameter will be considered the value.

Values will be serialized to a string before comparison. If using the `>`, `>=`, `<`, or `<=` comparison operators, note that the value will be compared as a string. If comparing numeric values, use `Metable::scopeWhereMetaNumeric()` instead.

@param Builder $q
@param string  $key
@param mixed   $operator
@param mixed   $value

@return void
Query scope to restrict the query to records which have Meta with a specific key and value .