app/Filters/BaseFilter.php
public function doesnt_have($values)
    {
        $doesnt_haves = explode(',', $values);
        $model = $this->builder->getModel();
        $doesnt_haves = collect($doesnt_haves)->filter(function ($doesnt_have) use($model) {
            if (str_contains($doesnt_have, '.')) return ($model->{explode('.', $doesnt_have)[0]}() instanceof Relation);
            return ($model->{$doesnt_have}() instanceof Relation);
        })->toArray();
        $validator = validator([ 'values' => $doesnt_haves ], [ 'values' => 'array|min:1' ]);
        return $this->builder->when(!$validator->fails(), function (Builder $query) use($doesnt_haves) {
            foreach ($doesnt_haves as $doesnt_have) {
                $query->doesntHave($doesnt_have);
            }
        });
    }
public function doesnt_have($values)
    {
        $doesnt_haves = explode(',', $values);
        $model = $this->builder->getModel();
        $doesnt_haves = collect($doesnt_haves)->filter(function ($doesnt_have) use($model) {
            if (str_contains($doesnt_have, '.')) return ($model->{explode('.', $doesnt_have)[0]}() instanceof Relation);
            return ($model->{$doesnt_have}() instanceof Relation);
        })->toArray();
        $validator = validator([ 'values' => $doesnt_haves ], [ 'values' => 'array|min:1' ]);
        return $this->builder->when(!$validator->fails(), function (Builder $query) use($doesnt_haves) {
            foreach ($doesnt_haves as $doesnt_have) {
                $query->doesntHave($doesnt_have);
            }
        });
    }
public function doesnt_have ( $ values ) { $ doesnt_haves = explode ( ',' , $ values ) ; $ model = $ this -> builder -> getModel ( ) ; $ doesnt_haves = collect ( $ doesnt_haves ) -> filter ( function ( $ doesnt_have ) use ( $ model ) { if ( str_contains ( $ doesnt_have , '.' ) ) return ( $ model -> { explode ( '.' , $ doesnt_have ) [ 0 ] } ( ) instanceof Relation ) ; return ( $ model -> { $ doesnt_have } ( ) instanceof Relation ) ; } ) -> toArray ( ) ; $ validator = validator ( [ 'values' => $ doesnt_haves ] , [ 'values' => 'array|min:1' ] ) ; return $ this -> builder -> when ( ! $ validator -> fails ( ) , function ( Builder $ query ) use ( $ doesnt_haves ) { foreach ( $ doesnt_haves as $ doesnt_have ) { $ query -> doesntHave ( $ doesnt_have ) ; } } ) ; }
Get collection of resources by doesnt_have relation
@param  string $values
@return \Illuminate\Database\Eloquent\Builder
Get collection of resources by doesnt_have relation