public static function boot()
{
parent::boot();
// When creating the model generate an SSH Key pair and a webhook hash
static::saving(function (Project $model) {
if (!array_key_exists('private_key', $model->attributes) || $model->private_key === '') {
$model->generateSSHKey();
}
if (!array_key_exists('public_key', $model->attributes) || $model->public_key === '') {
$model->regeneratePublicKey();
}
if (!array_key_exists('hash', $model->attributes)) {
$model->generateHash();
}
});
}