Skip to content

Commit

Permalink
Test model.relation.attach and model.relation.detach
Browse files Browse the repository at this point in the history
  • Loading branch information
octoberapp committed Mar 28, 2023
1 parent 65e8794 commit 747b066
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ public function beforeValidate()
'files_secure' => [\System\Models\File::class, 'public' => false],
];

/**
* __construct
*/
public function __construct(...$args)
{
parent::__construct(...$args);

$this->bindEvent('model.relation.detach', function (string $relationName, array $ids) {
traceLog("Relation {$relationName} was removed", $ids);
});

$this->bindEvent('model.relation.attach', function (string $relationName, array $ids, array $attributes) {
traceLog("New relation {$relationName} was created", $ids, $attributes);
});
}

/**
* filterScopes
*/
Expand Down

0 comments on commit 747b066

Please sign in to comment.