PHPackages                             ganyicz/nova-callbacks - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ganyicz/nova-callbacks

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ganyicz/nova-callbacks
======================

Add after-save callbacks to your Laravel Nova resources.

1.1.5(4y ago)20138.5k↓46%9[1 issues](https://github.com/ganyicz/nova-callbacks/issues)MITPHPPHP ^7.2.5|^8.0

Since Mar 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ganyicz/nova-callbacks)[ Packagist](https://packagist.org/packages/ganyicz/nova-callbacks)[ RSS](/packages/ganyicz-nova-callbacks/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (0)

[![Banner](https://camo.githubusercontent.com/9428c3fddc6b91a3550eaba09e39ca823a53fcbb670ff64e146612ff48693add/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4e6f766125323063616c6c6261636b25323066756e6374696f6e732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d67616e7969637a2532466e6f76612d63616c6c6261636b73267061747465726e3d636861726c696542726f776e267374796c653d7374796c655f31266465736372697074696f6e3d446566696e652b61667465722d736176652b63616c6c6261636b732b6469726563746c792b696e736964652b796f75722b4e6f76612b5265736f757263652e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d7265706c79)](https://camo.githubusercontent.com/9428c3fddc6b91a3550eaba09e39ca823a53fcbb670ff64e146612ff48693add/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4e6f766125323063616c6c6261636b25323066756e6374696f6e732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d67616e7969637a2532466e6f76612d63616c6c6261636b73267061747465726e3d636861726c696542726f776e267374796c653d7374796c655f31266465736372697074696f6e3d446566696e652b61667465722d736176652b63616c6c6261636b732b6469726563746c792b696e736964652b796f75722b4e6f76612b5265736f757263652e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d7265706c79)

Missing Nova resource callback functions
========================================

[](#missing-nova-resource-callback-functions)

This package adds support for defining callback functions directly inside your resource class.

```
use Illuminate\Http\Request;
use Ganyicz\NovaCallbacks\HasCallbacks

class User extends Resource
{
    use HasCallbacks;

    public function fields(Request $request)
    {
        return [];
    }

    public static function beforeSave(Request $request, $model)
    {
      // Do something before the model is created or updated
    }

    public static function afterSave(Request $request, $model)
    {
      // Do something after the model is created or updated
    }

    public static function beforeCreate(Request $request, $model)
    {
      // Do something before the model is created
    }

    public static function afterCreate(Request $request, $model)
    {
      // Do something after the model is created
    }

    public static function beforeUpdate(Request $request, $model)
    {
      // Do something before the model is updated
    }

    public static function afterUpdate(Request $request, $model)
    {
      // Do something after the model is updated
    }
}
```

Why?
----

[](#why)

Currently, if you want to do anything after your resource is saved, you have to define a model observer outside of the resource class. This just makes the code harder to find. This package is especially useful if you only need to do a simple logic after your resource is saved, as everything can be kept in one file.

To expand the possibilities, check out my other package [Nova Temporary Fields](https://github.com/ganyicz/nova-temporary-fields) which allows you to create custom fields that won't be persisted in your model and will only be available inside the callbacks.

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

[](#installation)

You can install the package via composer:

```
composer require ganyicz/nova-callbacks
```

Usage
-----

[](#usage)

1. Apply `HasCallbacks` trait on your resource.
2. Define one of the callback functions.

TIP: Apply the trait on your base Resource class inside your Nova folder so that the callback functions are available for you in every new resource.

Available callbacks
-------------------

[](#available-callbacks)

`public static function beforeSave(Request $request, $model)`

Called both before creating and updating the resource

`public static function afterSave(Request $request, $model)`

Called both after creating and updating the resource

`public static function beforeCreate(Request $request, $model)`

Called before creating a new resource

`public static function afterCreate(Request $request, $model)`

Called after creating a new resource

`public static function beforeUpdate(Request $request, $model)`

Called before updating an existing resource

`public static function afterUpdate(Request $request, $model)`

Called after updating an existing resource

How does it work?
-----------------

[](#how-does-it-work)

The implementation is really simple. Before Nova fills the model, we overwrite `fill` and `fillForUpdate` methods exposed by `Laravel\Nova\FillsFields` trait to add a closure based model event listener. After the model is saved, we simply call the callback function defined inside your resource.

Keep in mind
------------

[](#keep-in-mind)

As the implementation works on `saved` model event, saving the model itself inside the callback function will throw you into infinite loop. If you really need to save your model inside the callback, use `saveQuietly()` so that the event is not dispatched.

As mentioned above, the trait provided by this package overrides `fill` and `fillForUpdate` methods on your resource.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 76.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~77 days

Recently: every ~113 days

Total

7

Last Release

1470d ago

PHP version history (3 changes)1.0.0PHP ^7.2.5

1.1.1PHP ^7.2.5|^8.0

1.1.4PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3823354?v=4)[Filip Ganyicz](/maintainers/ganyicz)[@ganyicz](https://github.com/ganyicz)

---

Top Contributors

[![ganyicz](https://avatars.githubusercontent.com/u/3823354?v=4)](https://github.com/ganyicz "ganyicz (13 commits)")[![agustinprod](https://avatars.githubusercontent.com/u/343407?v=4)](https://github.com/agustinprod "agustinprod (2 commits)")[![clink-aaron](https://avatars.githubusercontent.com/u/42357661?v=4)](https://github.com/clink-aaron "clink-aaron (1 commits)")[![milewski](https://avatars.githubusercontent.com/u/2874967?v=4)](https://github.com/milewski "milewski (1 commits)")

---

Tags

laravelcallbacksnova

### Embed Badge

![Health badge](/badges/ganyicz-nova-callbacks/health.svg)

```
[![Health](https://phpackages.com/badges/ganyicz-nova-callbacks/health.svg)](https://phpackages.com/packages/ganyicz-nova-callbacks)
```

###  Alternatives

[ebess/advanced-nova-media-library

Laravel Nova tools for managing the Spatie media library.

6163.5M22](/packages/ebess-advanced-nova-media-library)[optimistdigital/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2852.1M6](/packages/optimistdigital-nova-sortable)[outl1ne/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2862.1M9](/packages/outl1ne-nova-sortable)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[advoor/nova-editor-js

A Laravel Nova field bringing EditorJs magic to Nova.

92219.3k3](/packages/advoor-nova-editor-js)[outl1ne/nova-page-manager

Page(s) and region(s) manager for Laravel Nova.

17947.0k](/packages/outl1ne-nova-page-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
