PHPackages                             cjmellor/approval - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. cjmellor/approval

ActiveLibrary[Database &amp; ORM](/categories/database)

cjmellor/approval
=================

Approve or Deny new Model data before it is persisted

v2.0.0(1mo ago)36538.5k↓27.6%23[2 PRs](https://github.com/cjmellor/approval/pulls)MITPHPPHP ^8.3CI passing

Since Jul 5Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/cjmellor/approval)[ Packagist](https://packagist.org/packages/cjmellor/approval)[ Docs](https://github.com/cjmellor/approval)[ RSS](/packages/cjmellor-approval/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (20)Versions (31)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/464a38d3c03061c9c147e3e6b72e859c80446f22129c9ac2df71430c902439f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636a6d656c6c6f722f617070726f76616c3f636f6c6f723d7267622532383536253230313839253230323438253239266c6162656c3d72656c65617365267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/cjmellor/approval)[![GitHub Tests Action Status](https://camo.githubusercontent.com/77752f56cf238d184d6d2788a69dd04dcfac13e9d3bebf9869a0503afa99282b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636a6d656c6c6f722f617070726f76616c2f72756e2d706573742e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666f722d7468652d626164676526636f6c6f723d726762253238313334253230323339253230313238253239)](https://github.com/cjmellor/approval/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/4658330b115d77653102ab411505b110cde6b39dee90fdde1ea5f6769eace64d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636a6d656c6c6f722f617070726f76616c2e7376673f636f6c6f723d7267622532383234392532303131352532303232253239267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/cjmellor/approval)[![Packagist PHP Version](https://camo.githubusercontent.com/0d02af80e914336c19ac19172d806f74c9f832d199dc17216d7e488a9876b25b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f636a6d656c6c6f722f617070726f76616c2f7068703f636f6c6f723d726762253238313635253230313830253230323532253239266c6f676f3d706870266c6f676f436f6c6f723d726762253238313635253230313830253230323532253239267374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/0d02af80e914336c19ac19172d806f74c9f832d199dc17216d7e488a9876b25b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f636a6d656c6c6f722f617070726f76616c2f7068703f636f6c6f723d726762253238313635253230313830253230323532253239266c6f676f3d706870266c6f676f436f6c6f723d726762253238313635253230313830253230323532253239267374796c653d666f722d7468652d6261646765)[![Laravel Version](https://camo.githubusercontent.com/4a6a6a3bf37643be3d1c64a82697afd8891ff7f528a6b19af12ba5569242cbe4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d25354531315f2537435f25354531325f2537435f25354531332d7267622832333525323036382532303530293f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)](https://camo.githubusercontent.com/4a6a6a3bf37643be3d1c64a82697afd8891ff7f528a6b19af12ba5569242cbe4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d25354531315f2537435f25354531325f2537435f25354531332d7267622832333525323036382532303530293f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)

Approval is a Laravel package that provides a simple way to approve new Model data before it is persisted.

[![](https://camo.githubusercontent.com/f8f582220287271d3cff49e0ffa9eeded6d13374d496989433f233dbfe1ae359/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f417070726f76616c2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d636a6d656c6c6f72253246617070726f76616c267061747465726e3d627269636b57616c6c267374796c653d7374796c655f32266465736372697074696f6e3d417070726f76652b6e65772b4d6f64656c2b646174612b6265666f72652b69742b69732b706572736973746564266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d636865636b2d636972636c65267769647468733d33303026686569676874733d333030)](https://camo.githubusercontent.com/f8f582220287271d3cff49e0ffa9eeded6d13374d496989433f233dbfe1ae359/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f417070726f76616c2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d636a6d656c6c6f72253246617070726f76616c267061747465726e3d627269636b57616c6c267374796c653d7374796c655f32266465736372697074696f6e3d417070726f76652b6e65772b4d6f64656c2b646174612b6265666f72652b69742b69732b706572736973746564266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d636865636b2d636972636c65267769647468733d33303026686569676874733d333030)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require cjmellor/approval
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="approval-migrations"
php artisan migrate
```

Upgrading from v1
-----------------

[](#upgrading-from-v1)

If you're upgrading from v1.x to v2.x, please follow the [detailed upgrade guide](UPGRADE.md) to ensure a smooth transition. Version 2 introduces database schema changes that require running specific commands in the correct order.

You can publish the config file with:

```
php artisan vendor:publish --tag="approval-config"
```

This is the contents of the published config file:

```
return [
    'approval_pivot' => 'approvalable',
    'users_table' => 'users',
    'states' => [
        'approved' => ['name' => 'Approved'],
        'pending' => ['name' => 'Pending', 'default' => true],
        'rejected' => ['name' => 'Rejected'],
    ],
];
```

Usage
-----

[](#usage)

Note

This package does not approve/deny the data for you, it just stores the new/amended data into the database. It is up to you to decide how you implement a function to approve or deny the Model.

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.

```
