Tuesday, 28 May 2019

laravel scopes with relation and conditions

i have this laravel scope code

public function apply(Builder $builder, Model $model)
{
    $builder->whereDoesntHave('getPermissionData');
}

everything working fine till now what i need is to wright conditions like this

public function apply(Builder $builder, Model $model)
{
    /*
        if($builder->whereHas('getPermissionData'))
        {
            check the relation 
            and do some code here
        }
    */
    $builder->whereDoesntHave('getPermissionData');
}

is that possible or not



from laravel scopes with relation and conditions

No comments:

Post a Comment