| Package Data | |
|---|---|
| Maintainer Username: | ronan-gloo |
| Maintainer Contact: | sonotone13@gmail.com (ronan-gloo) |
| Package Create Date: | 2012-10-22 |
| Package Last Update: | 2014-09-06 |
| Language: | PHP |
| License: | Unknown |
| Last Refreshed: | 2025-12-15 03:00:18 |
| Package Statistics | |
|---|---|
| Total Downloads: | 8 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 5 |
| Total Watchers: | 2 |
| Total Forks: | 3 |
| Total Open Issues: | 0 |
Dispatch Eloquent’s models events to the model’s instance, and / or a specific class
php artisan bundle:install observer
class Post extends Eloquent {
/**
* This method will be run after an update or a creation.
*/
public function event_saved()
{
Log::info(get_class($this).' with title "'.$this->title.'" saved');
}
}
// The Model
class Post extends Eloquent {
public static $observe = array(
// Single observer for a single event
'saving' => 'Observe_Slug',
// Multiple observers for a single event
'created' => array('Observe_Log', 'Observe_Mail'),
// Observer with parameters
'updated' => array('Observe_History' => array('log' => true))
);
}
// Observer
class Observer_Slug extends Observer\Observe {
// Modelfy object before to save it
public function saving($model)
{
model->slug = Str::slug($model->title);
}
// event with parameters: parameters from model are instance properties here
public function updated($model)
{
if ($this->log == true)
{
Do something...
}
}
}