Closed f4llenz closed 2 years ago
Update: It works as expected after I disabled fluency by adding protected bool $disableFluentMeta = true;
to my model.
protected bool $disableFluentMeta = true;
only affects fluent access like $bot->needapproval
which you don't use it in this case. perhaps problem was from Postgres. I never worked with Postgres so I don't know how it works.
this package includes tests with sqlite and this scenario:
https://github.com/kodeine/laravel-meta/blob/ceeeb56c13d5e36ff89a9c8bd09894af0b5c1d08/tests/MetableTest.php#L223-L235
and all the test are passed.
I currently struggle with a similar problem. As @f4llenz says getMeta
returns an empty Collection unless disableFluentMeta
is turned off. I can't really tell how turning this property off is making getMeta
work again..
In my case the problem lies in the package spatie/laravel-model-states
https://github.com/spatie/laravel-model-states/blob/main/src/HasStates.php#L24-L27 where it calls initializeHasStates
. I did not find out yet how to keep this functionality and making getMeta
work as expected.
@bfiessinger
Please send laravel version, casts, mutators, accessors, the traits you're using on the model and all of laravel-meta
related properties or methods.
Also tell me how you set and get metas step by step, so I can reproduce this bug and hopefully find it.
Hi @siamak2,
I've just created a PR with a working solution.
I'm having a weird issue where I set meta for my model inside a job so I can retrieve it from another job. It gets saved in the database, but it's not retrieved when using
getMeta()
.I set the meta inside a job like so:
The meta exists:
However the package doesn't retrieve it with getMeta():
My
bots_meta
schema:The
Bot
model has theMetable
trait.Weirdly enough, if I do the same inside Tinker rather than inside an async job, it works fine. This only happens when I set the meta from an async job.
I'm using Postgres and Laravel Horizon. Any clues on how I can fix or debug this?