What error is it giving you?
Aside, if you own RudrakshaFace, then why do you need a macro at all?
Hello.
I have created a custom macro for my class using a Macroable trait that laravel provides. If I test the same thing in Tinkerwell or in the browser. I get the expected result and everything works. But on the test, its giving me error.
it('ensures the getSizeValue Macro is present', function (): void {
expect(RudrakshaFace::hasMacro('getSizeValue'))->toBeTrue();
});
it('ensures ...', function ($range, $value, $expectedResult): void {
$sizeRange = $range;
$result = RudrakshaFace::getSizeValue($value, $sizeRange);
expect($result)
->toBe($expectedResult);
})->with([
[['Re' => '<19', 'Me' => '19-20', 'Co' => '21-22'], 12, 'Re'],
]);
Thank you in advance.
@anuzpandey again, I don't know why you need to make your Model macroable at all? Is this part of a package that would allow others to extend your model?
A problem I see with using Macroable on a Model class is the __call and __callStatic magic methods are defined in both the trait and in the base Model class. The trait's definition will take precedence over the base class' method which will break a lot of Eloquent behaviours.
So no, using Macroable on a Model is not a good idea!
Please or to participate in this conversation.