Description
Approval is a Laravel package that provides a simple way to approve new Model data before it is persisted.
Add the MustBeApproved trait to your Model and now the data will be stored in an approvals table, ready for you to approve or deny.
For example, you add it to a Post Model and each time a Post is created or updated, all the dirty data will be stored in the database as JSON for you to do something with it.
<?php use Cjmellor\Approval\Concerns\MustBeApproved; class Post extends Model{ use MustBeApproved; // ...}
All Models using the Trait will now be stored in a new table -- approvals. This is a polymorphic relationship.
Here is some info about the columns in the approvals table:
approvalable_type => The class name of the Model that the approval is for
approvalable_id => The ID of the Model that the approval is for
state => The state of the approval. This uses an Enum class. This column is cast to an ApprovalStatus Enum class
new_data => All the fields created or updated in the Model. This is a JSON column. This column is cast to the AsArrayObject Cast
original_data => All the fields in the Model before they were updated. This is a JSON column. This column is cast to the AsArrayObject Cast
rolled_back_at => A timestamp of when this was last rolled back to its original state
audited_by => The ID of the User who set the state
foreign_key => A foreign key to the Model that the approval is for
creator_id => The ID of the model who requested the approval
creator_type => The class name of the model who requested the approval
custom_state => A custom state name (when using configurable states beyond the defaults)
expires_at => When this approval expires
expiration_action => What action to take on expiry (reject, postpone, or custom)
actioned_at => When an expired approval was processed
actioned_by => The ID of the User (or null for system) who processed the expiry