feat: custom attributes sync; update: default User model
This commit is contained in:
parent
14b47b6f6e
commit
3b79a880ae
|
@ -5,7 +5,7 @@ return [
|
||||||
/**
|
/**
|
||||||
* OAuth model
|
* OAuth model
|
||||||
*/
|
*/
|
||||||
'model' => \App\User::class,
|
'model' => \App\Models\User::class,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Route that redirects to Bluesquare Connect
|
* Route that redirects to Bluesquare Connect
|
||||||
|
|
|
@ -8,6 +8,8 @@ trait HasConnectSync
|
||||||
abstract function save();
|
abstract function save();
|
||||||
abstract function delete();
|
abstract function delete();
|
||||||
|
|
||||||
|
protected $fillable = [];
|
||||||
|
|
||||||
public static $connectResource;
|
public static $connectResource;
|
||||||
|
|
||||||
public static $connectColumnId = 'connect_resource_id';
|
public static $connectColumnId = 'connect_resource_id';
|
||||||
|
@ -20,7 +22,13 @@ trait HasConnectSync
|
||||||
public static function onConnectResourceCreated($id, $data)
|
public static function onConnectResourceCreated($id, $data)
|
||||||
{
|
{
|
||||||
$record = self::findConnectResource($id) ?? new self;
|
$record = self::findConnectResource($id) ?? new self;
|
||||||
$record->fill($data); // TODO
|
$attributes = $record->getConnectFillableAttributes();
|
||||||
|
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
if (in_array($key, $attributes))
|
||||||
|
$record->$key = $value;
|
||||||
|
}
|
||||||
|
|
||||||
$record->{self::$connectColumnId} = $id;
|
$record->{self::$connectColumnId} = $id;
|
||||||
return $record->save();
|
return $record->save();
|
||||||
}
|
}
|
||||||
|
@ -40,4 +48,9 @@ trait HasConnectSync
|
||||||
{
|
{
|
||||||
return $record->forceDelete();
|
return $record->forceDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConnectFillableAttributes()
|
||||||
|
{
|
||||||
|
return $this->fillable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue