0

I have a ProductPrice Model which I register an observer attribute with ObservedBy on as follows

#[ObservedBy([ProductPriceObserver::class])]
class ProductPrice extends Model
{
    use HasFactory, HasUlids;

    protected $fillable = ['price', 'is_current', 'product_id'];

}

This doesn't fire the observer at all.

manually registering the observer in the boot method of EventServiceProvider works

    public function boot(): void
    {
        ProductPrice::observe(ProductPriceObserver::class);

    }

I am very keen on getting the above to work as it is much more neater reference here

2
  • That feature is available from Laravel 10.44 Commented Mar 10, 2024 at 4:52
  • That answers it. I'm on 10.40.0. Thanks Commented Mar 10, 2024 at 12:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.