Атрибут наблюдателя Laravel 10 не работаетPhp

Кемеровские программисты php общаются здесь
Anonymous
Атрибут наблюдателя Laravel 10 не работает

Сообщение Anonymous »


У меня есть модель ProductPrice, в которой я регистрирую атрибут наблюдателя с помощью ObservedBy следующим образом:

Код: Выделить всё

#[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


Источник: https://stackoverflow.com/questions/781 ... ot-working

Вернуться в «Php»