feat: post-fill hook

This commit is contained in:
Maxime 2024-04-17 13:06:48 +02:00
parent 9d17dacae2
commit abce313193
4 changed files with 18 additions and 0 deletions

View File

@ -4,6 +4,7 @@ namespace Bluesquare\Connect\Commands;
use Bluesquare\Connect\Connect;
use Bluesquare\Connect\ConnectException;
use Bluesquare\Connect\Traits\HasConnectData;
use Bluesquare\Connect\Traits\HasConnectTokens;
use Illuminate\Console\Command;
@ -32,6 +33,10 @@ class Sync extends Command
$data = $connect->getUserData($model->connect_access_token);
$connect->updateUserData($model, $data);
$model->save();
if (in_array(HasConnectData::class, class_uses($model))) {
$model->postFillConnectData($data);
}
}
}
catch (\Exception $exception) {

View File

@ -224,6 +224,10 @@ class Connect
} else {
$this->updateUserData($model, $data);
$model->save();
if (in_array(HasConnectData::class, class_uses($model))) {
$model->postFillConnectData($data);
}
}
return $model;

View File

@ -44,4 +44,9 @@ trait HasConnectData
foreach ($touched as $model)
$model->save();
}
public function postFillConnectData(array $data)
{
// Intended for post-processing / relationship handling
}
}

View File

@ -18,6 +18,10 @@ trait HasConnectWebhook
}
$this->save();
if (in_array(HasConnectData::class, class_uses(self::class))) {
$this->postFillConnectData($data);
}
}
public function onConnectDelete(array $data)