Page Events where you can insert a code that will run before and after the main action function.
Note: If you want to remove your page event code, click Clear Page Event.
For our example we will be creating a Log System where we can track every new Todo added.
So everytime you add a new Todo in the Todos module, it saves a log record on the Logs module.
private function afterAdd($record){
//enter statement here
$modeldata = ['action' => 'Add', 'todo' => $record['todo']];
DB::table('Logs')->insert($modeldata);
}
private function afterAdd($record){
//enter statement here
$modeldata = ['action' => 'Add', 'todo' => $record['todo']];
DB::table('Logs')->insert($modeldata);
}
async function afterAdd(record, req){
//enter statement here
let tableModel = models.Logs; //Logs is the name of the table
let modeldata = {
action: 'Add',
todo: record.todo
}
await tableModel.create(modeldata);
}
def after_add(record):
# statement here
new_record = Logs(action="Add", todo=record.todo)
db.session.add(new_record)
db.session.commit()
private void afterAdd(Todos record){
//enter statement here
var modeldata = new Logs(); //Logs is the tablename or modelname
modeldata.action = "Add";
modeldata.todo = record.todo;
DB.Logs.Add(modeldata);
DB.SaveChanges();
}