public function scopeOwnedBy(Builder $query, Model $related, ?string $key = null): Builder
    {
        if (\is_null($key)) {
            $key = $related->getForeignKey();
        }

        return $query->where($key, $related->getKey());
    }
public function scopeOwnedBy(Builder $query, Model $related, ?string $key = null): Builder
    {
        if (\is_null($key)) {
            $key = $related->getForeignKey();
        }

        return $query->where($key, $related->getKey());
    }
public function scopeOwnedBy ( Builder $ query , Model $ related , ? string $ key = null ) : Builder { if ( \ is_null ( $ key ) ) { $ key = $ related -> getForeignKey ( ) ; } return $ query -> where ( $ key , $ related -> getKey ( ) ) ; }
Scope query to get model which are owned by the specified model.

@param  \Illuminate\Database\Eloquent\Builder  $query
@param  \Illuminate\Database\Eloquent\Model  $related
@param  string|null  $key

@return \Illuminate\Database\Eloquent\Builder
Scope query to get model which are owned by the specified model .