I am using cakephp v3.3.3
After using cake bake to auto-generate code, I have this php file BallsTable.php which has the initialize() function below;
public function initialize(array $config)
{
parent::initialize($config);
$this->table('balls');
$this->displayField('id');
$this->primaryKey('id');
$this->belongsTo('Baskets', [
'foreignKey' => 'basket_id',
'joinType' => 'INNER'
]);
$this->hasMany('BallRecords', [
'foreignKey' => 'ball_id',
]);
}
However, the above initialize() function does not allow me to do cascading delete.
I need to manually modify initialize() like below to enable cascading delete. But this is cumbersome as the file gets overwritten every time with a new cake bake.
$this->hasMany('BallRecords', [
'foreignKey' => 'ball_id',
//http://book.cakephp.org/3.0/en/orm/deleting-data.html
//manually add the 2 lines below to enable cascading delete
'dependent' => true,
'cascadeCallbacks' => true,
]);
Is there some way to configure cake bake to auto-generate code that manually enable cascading delete?
EDIT: A bounty was added to invite answers that configure bake templates.