feat: post-fill hook
This commit is contained in:
parent
9d17dacae2
commit
abce313193
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -44,4 +44,9 @@ trait HasConnectData
|
|||
foreach ($touched as $model)
|
||||
$model->save();
|
||||
}
|
||||
|
||||
public function postFillConnectData(array $data)
|
||||
{
|
||||
// Intended for post-processing / relationship handling
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue