Allows callables for default model attribute to gain access

to the current model in order to calculate the value needed.
This commit is contained in:
Daniël Klabbers 2020-10-07 11:26:58 +02:00
parent 6977c24dd8
commit ad9917f0d6

View File

@ -82,7 +82,7 @@ abstract class AbstractModel extends Eloquent
}
$this->attributes = array_map(function ($item) {
return is_callable($item) ? $item() : $item;
return is_callable($item) ? $item($this) : $item;
}, $this->attributes);
parent::__construct($attributes);