You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, every time I want to implement an after load hook, I see myself doing this:
public function after_load($model_or_collection) {
if (Au::type()->is_collection($model_or_collection)) {
// either loop through it
foreach ($model_or_collection as $model) {
$this->after_load($model);
}
// or silently return;
return;
}
// it's a model now, change variable name
// for the sake of readability
$model = $model_or_collection;
...
}
So I am thinking of separating the hooks for models and collections. I hope to have two separate hooks for each case, something like:
public function after_load_model($model);
public function after_load_collection($collection);
The text was updated successfully, but these errors were encountered:
Currently we have the following hooks:
before_load(&$params)
after_load($model_or_collection)
before_save($model_or_collection)
after_save($model_or_collection)
before_create($model)
after_create($model)
before_update($model)
after_update($model)
before_delete($model_or_collection)
after_delete($model_or_collection)
Now, every time I want to implement an after load hook, I see myself doing this:
So I am thinking of separating the hooks for models and collections. I hope to have two separate hooks for each case, something like:
The text was updated successfully, but these errors were encountered: