---
title: "David (@dbw) | Hashnode"
description: "David (@dbw) writes on Hashnode. Read their latest articles and follow their work."
url: "https://hashnode.com/@dbw"
---

@dbw

# David

@dbw · Joined February 2017

## Comments

[I've been using scopes inside with clauses etc for a very long time, I don't think this is needed. I believe it is not working for you simply because you are not returning the $query object from the scope, it should be: public function scopeWithCalculatedPricing( $query, $include\_tax = false ) { $tax\_multiplier = $include\_tax ? 1.2 : 1; return $query->selectRaw( 'products.\*, ( products.price \* ' . $tax\_multiplier . ' ) as total\_price' ) ->where( 'stock', '>', 0 ); } Please note the added return. If you can see if you refer to the laravel docs on the subject: https://laravel.com/docs/5.4/eloquent#local-scopes](https://hashnode.com/posts/a-little-trick-with-eloquent-query-scopes-that-makes-them-super-reusable/5890be485478d2f4f656800e/comment/5891cef0cfe48c4f6b113b48)

Comment · Article · Feb 1, 2017 · 3 · [A little trick with Eloquent query scopes that makes them super reusable](https://hashnode.com/posts/a-little-trick-with-eloquent-query-scopes-that-makes-them-super-reusable/5890be485478d2f4f656800e)
