CRUD Hooks
Once you've made some custom post types, you might need to add some custom functionality when these are created/saved/whatever.
You can use the following hooks by adding a configureHooks method to your CRUD controller. E.g.
protected function configureHooks()
{
Eventy::addAction('crud.store.after', function ($request, $item) {
do('somestuff');
}, 10, 2);
}
Available Hooks
Eventy::action('crud.index.before', $request, $this->getConfig());
Eventy::action('crud.index.beforeRender', $request, $this->getConfig());
Eventy::action('crud.index.beforeAjax', $request, $this->getConfig(), $items);
Eventy::action('crud.create.before', $request, $this->getConfig());
Eventy::action('crud.create.after', $request, $this->getConfig(), $item);
Eventy::action('crud.store.before', $request);
Eventy::action('crud.store.after', $request, $item);
Eventy::action('crud.edit.before', $request, $this->getConfig());
Eventy::action('crud.edit.after', $request, $this->getConfig(), $item);
Eventy::action('crud.update.before', $request);
Eventy::action('crud.update.after', $request, $this->getConfig(), $item);
Eventy::action('crud.destroy.before', $request, $item);
Eventy::action('crud.destroy.after', $request);
Eventy::action('crud.reorder.before', $request);
Eventy::action('crud.reorder.after');
Controller Methods
You can also override the beforeSaveCallback and afterSaveCallback methods on your Crud controller. These methods both take the same arguments.
public function beforeSaveCallback(Model $model, array $data, string $action): Model
{
// Do stuff with your model here
return $model;
}