Admin rules

Rules are reusable classes with hooks running before and after records are created, updated, deleted or published.
The class is created in app/Admin/Rules and registered on the model:
app/Models/Invoice.php
app/Admin/Rules/SetInvoiceNumber.php
Rules can also be returned by a rules($row) method, or extended with setRulesProperty($rules).

Rule hooks

Every method receives the record. Saving the record inside a rule does not run the rules again. Stop the action with an error:

Where rules run

Rules with $frontend = true also run in console (commands, queues, scheduler). Disable rules for one record, or silence some of them:

Changing the admin form

$this->isFieldDirty('price') returns true when the field was changed in the admin form.

Admin hooks

Methods called only by actions in the administration, not by Model::create(), update() or delete() in your code.
app/Models/Partner.php

Eloquent events

Standard Eloquent events fire for admin actions too, before the admin hooks: saving, creating, created, saved, then onCreate, and deleting, deleted, then onDelete. Use them for logic which has to run everywhere.

Modules

Modules are reusable classes extending admin models with fields, parameters, scopes and responses.
The class is created in app/Admin/Modules. Modules in the module directories are loaded for all admin models, isActive() decides for which of them the module runs.
app/Admin/Modules/BannerModule.php
app/Models/Page.php
$this->getModel() returns the model, or the listed row, the module currently runs for.

Registering a module on one model

app/Models/Product.php
AdminModel::addGlobalModule(PriceModule::class) in a service provider adds a module to all models.
protected $modules = [...] replaces the default modules (SEO, filter states, history, global relations). Use addModule() instead.

Module hooks