model.beforeGetAttribute

Called before the model attribute is retrieved (only when the attribute exists in $model->attributes or has a get mutator method defined; i.e. getFooAttribute())

Note: also triggered in Winter\Storm\Halcyon\Model

Example usage:

$model->bindEvent('model.beforeGetAttribute', function ((string) $key) use (\Winter\Storm\Database\Model $model) { if ($key === 'not-for-you-to-look-at') { return 'you are not allowed here'; } });

Usage

Globally

use Event;

Event::listen('model.beforeGetAttribute', function () {
    // Your event listener code goes here...
});

Triggers

Class or file Line
Winter\Storm\Database\Model 1106
Copyright © 2024 Winter CMS