Scopes, query builders and missing methods
If your models have fluent APIs you can work on the right level of abstraction and hide DB specific information. And here is an example of what this looks like. Order::wherePaid() ->whereLocalDelivery() ->whereHasExtraPackaging(); To enhance your model in Laravel is quite easy. namespace App\QueryBuilders; use Illuminate\Database\Eloquent\Builder; class OrderQueryBuilder extends Builder { public function wherePaid(): Builder { return $this->where('status', 'PAID'); } public function whereHasExtraPackaging(): Builder { return $this->where('extra_packaging', true); } public function whereLocalDelivery(): Builder { return $this->where('local_delivery', true); } } namespace App; use Illuminate\Database\Eloquent\Model; use App\QueryBuilders\OrderQueryBuilder; class Order extends Model { public function newEloquentBuilder($query): OrderQueryBuilder { return new OrderQueryBuilder($query); } } The trouble is, that none of the query builder’s methods are showing up in the autocomplete of the text editor or IDE. Let’s be honest. Once you’ve got more than 10 models in a system and pretty much the same amount of query builders you need an autocomplete. At least I do. ...