Hi,
It’s a basic question. I think I misunderstood when I read about Lifecycle Callbacks.
I have two tables: orders and items.
// OrdersTable.php
$this->table('orders');
$this->displayField('id');
$this->primaryKey('id');
$this->hasMany('Items', [
'foreignKey' => 'order_id',
'saveStrategy' => 'replace',
'dependent' => true,
'joinType' => 'INNER',
]);
// ItemsTable.php
$this->table('items');
$this->displayField('id');
$this->primaryKey('id');
$this->belongsTo('Orders', [
'foreignKey' => 'order_id',
'joinType' => 'INNER'
]);
Items are being inserted and deleted correctly, but since I want to record inventory exits, I had planned to use the afterSave and afterDelete events in ItemsTable. But it’s not working.
I can not access these events from an associated table?
Thanks for any advice.