Download the PHP package ganyicz/nova-callbacks without Composer

On this page you can find all versions of the php package ganyicz/nova-callbacks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nova-callbacks

Banner

Missing Nova resource callback functions

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

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 which allows you to create custom fields that won't be persisted in your model and will only be available inside the callbacks.

Installation

You can install the package via composer:

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

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?

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

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.


All versions of nova-callbacks with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2.5|^8.0
laravel/nova Version ^3.0|^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ganyicz/nova-callbacks contains the following files

Loading the files please wait ....