PHP code example of ganyicz / nova-callbacks
1. Go to this page and download the library: Download ganyicz/nova-callbacks library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ganyicz / nova-callbacks example snippets
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
}
}