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\Connect;
|
||||||
use Bluesquare\Connect\ConnectException;
|
use Bluesquare\Connect\ConnectException;
|
||||||
|
use Bluesquare\Connect\Traits\HasConnectData;
|
||||||
use Bluesquare\Connect\Traits\HasConnectTokens;
|
use Bluesquare\Connect\Traits\HasConnectTokens;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
@ -32,6 +33,10 @@ class Sync extends Command
|
||||||
$data = $connect->getUserData($model->connect_access_token);
|
$data = $connect->getUserData($model->connect_access_token);
|
||||||
$connect->updateUserData($model, $data);
|
$connect->updateUserData($model, $data);
|
||||||
$model->save();
|
$model->save();
|
||||||
|
|
||||||
|
if (in_array(HasConnectData::class, class_uses($model))) {
|
||||||
|
$model->postFillConnectData($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (\Exception $exception) {
|
catch (\Exception $exception) {
|
||||||
|
|
|
@ -224,6 +224,10 @@ class Connect
|
||||||
} else {
|
} else {
|
||||||
$this->updateUserData($model, $data);
|
$this->updateUserData($model, $data);
|
||||||
$model->save();
|
$model->save();
|
||||||
|
|
||||||
|
if (in_array(HasConnectData::class, class_uses($model))) {
|
||||||
|
$model->postFillConnectData($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
|
|
|
@ -44,4 +44,9 @@ trait HasConnectData
|
||||||
foreach ($touched as $model)
|
foreach ($touched as $model)
|
||||||
$model->save();
|
$model->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function postFillConnectData(array $data)
|
||||||
|
{
|
||||||
|
// Intended for post-processing / relationship handling
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,10 @@ trait HasConnectWebhook
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->save();
|
$this->save();
|
||||||
|
|
||||||
|
if (in_array(HasConnectData::class, class_uses(self::class))) {
|
||||||
|
$this->postFillConnectData($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onConnectDelete(array $data)
|
public function onConnectDelete(array $data)
|
||||||
|
|
Loading…
Reference in New Issue