I want to add custom methods for Laravel Query Builder.
I want to have something like this (Methods will be more complicated in further)
<?php
namespace App\Helpers;
class Builder extends \Illuminate\Database\Query\Builder
{
/**
* @return $this
*/
public function whenWhere(): self
{
return $this;
}
}
In code I have
DB::table('items')->select('id')->whenWhere()->get()
And I'm getting error
Call to undefined method Illuminate\\Database\\Query\\Builder::whenWhere()
I know there is a way to use macros in query providers, but I don't want use it because IDE don't see macros, so it is the main reason why I need to accomplish this in another way
*I'm not using models in project.