public function scopeExtrasWithValues($query, $model)
    {
        $modelSlug = $model ? getModelSlug($model) : false;
        return $query->with([
            'extras' => function($query) use($model,$modelSlug)
            {
                if ( ! $model ) return $query;

                return $query->with([
                    "{$modelSlug}s" => function($query) use($model,$modelSlug)
                    {
                        return $query->wherePivot("{$modelSlug}_id",$model->id);
                    }
                ]);
            }
        ]);
    }
public function scopeExtrasWithValues($query, $model)
    {
        $modelSlug = $model ? getModelSlug($model) : false;
        return $query->with([
            'extras' => function($query) use($model,$modelSlug)
            {
                if ( ! $model ) return $query;

                return $query->with([
                    "{$modelSlug}s" => function($query) use($model,$modelSlug)
                    {
                        return $query->wherePivot("{$modelSlug}_id",$model->id);
                    }
                ]);
            }
        ]);
    }
public function scopeExtrasWithValues ( $ query , $ model ) { $ modelSlug = $ model ? getModelSlug ( $ model ) : false ; return $ query -> with ( [ 'extras' => function ( $ query ) use ( $ model , $ modelSlug ) { if ( ! $ model ) return $ query ; return $ query -> with ( [ "{$modelSlug}s" => function ( $ query ) use ( $ model , $ modelSlug ) { return $ query -> wherePivot ( "{$modelSlug}_id" , $ model -> id ) ; } ] ) ; } ] ) ; }
get extra column datas with model values

@param \Illuminate\Database\Eloquent\Builder $query
@param $model
@return \Illuminate\Database\Eloquent\Builder
get extra column datas with model values