Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (5) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2020-09-14 (15 days ago) | Not yet rated by the users | Total: 11 | All time: 10,064 This week: 266 |
Version | License | PHP version | Categories | |||
fireworks 1.0 | Custom (specified... | 7.1 | PHP 5, Databases, Libraries, Design P... |
Description | Author | |
This package can be used to handle model class events in the object itself. |
A simple trait that will help to fire model property wise event on your laravel model. Using laravel model events, to create hooks with changed column and data.
You can start it from composer. Go to your terminal and run this command from your project root directory.
composer require hashemi/fireworks
At first, you need to use Fireworks
trait on your model where you want register your model events.
class User extends Model
{
// Use Fireworks Trait
// ....
use \Hashemi\Fireworks\Fireworks;
// ....
}
`Fireworks
trait add
boot
method on your model and register pre-defined model event hooks that already provided by laravel. This package supports
retrieved, creating, created, updating, updated, deleting, deleted, saving, saved
hooks. So, you don't need to register again this hooks are on
boot
` method.
This package will help you figure out of every hooks in methods. Example: suppose you want to use `creating
hooks, just declare
onModelCreating
` method on your model.
class User extends Model
{
// Use Fireworks Trait
// ....
use \Hashemi\Fireworks\Fireworks;
protected $fillable = [
'name',
];
// ....
protected function onModelCreating($model) {
$model->name = "Kuddus";
}
protected function onModelUpdating($model) {}
protected function onModelSaving($model) {}
protected function onModelCreated($model) {}
protected function onModelUpdated($model) {}
protected function onModelSaved($model) {
$model->name = "Ali";
$model->save();
}
protected function onModelNameSaved($model, $newValue, $oldValue)
{
}
}
You can use `onModelCreating
instead of
static::creating
`
You can use `onModelUpdating
instead of
static::updating
`
You can use `onModelSaving
instead of
static::saving
`
You can use `onModelDeleting
instead of
static::creating
`
You can use `onModelRetrieved
instead of
static::creating
`
You can use `onModelCreated
instead of
static::created
`
You can use `onModelUpdated
instead of
static::updated
`
You can use `onModelSaved
instead of
static::saved
`
You can use `onModelDeleted
instead of
static::deleted
`
format. Where the
` will be replaced by the StudlyCase Hooks names. So, if your hook is `creating`, then the method name should be `onModelCreating()`.
Please use hooks proper way other way data will modified in each hook.
Pull requests are welcome. For any changes, please open an issue first to discuss what you would like to change.
Files |
File | Role | Description | ||
---|---|---|---|---|
examples (1 file) | ||||
src (1 file) | ||||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
README.md | Doc. | Documentation |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.