Logs
Qore\Next\System\Models\Log stores audit-style entries for a model.
Logs are shown through the resource logbook modal on detail pages and are usually written through qore()->logger().
What The Model Stores
Log stores:
entity_typeandentity_idfor the model being logged;user_idfor the user responsible for the change;descriptionfor the event name;field,value_oldandvalue_newfor field-level mutations;payloadfor action or workflow data.
The payload attribute is cast to array.
Writing Logs
Use the logger service instead of creating Log directly:
qore()->logger()
->setEntity($product)
->setDescription('price_updated')
->setFieldName('price')
->setOldValue($oldPrice)
->setNewValue($newPrice)
->setPayload(['source' => 'manual_review'])
->save();
The service automatically sets the authenticated user ID when there is a logged-in user.
Automatic Logs
Qore writes logs for common resource flows:
- resource create, update and delete mutations;
- field mutation changes;
- file attachments and removals;
- relation attach and detach changes;
- resource action execution.
Field mutation logging compares the original model value with the new model value and skips the log when nothing changed.
Resource Logbook
The default detail page always adds a logbook item to the actions dropdown. It opens a modal table with:
- ID;
- date;
- user;
- description;
- field;
- new value;
- old value.
The table query is scoped to the current detail model:
Log::query()->whereMorphedTo('entity', $model);
Descriptions
Use stable descriptions such as price_imported, approved or the values from ResourceMutationDescription.
Avoid putting long human text in description; put detailed context in payload so the log stays filterable and consistent.