4 Commits
1.1 ... 1.2

Author SHA1 Message Date
7b3a698daa fix: model trait 2021-06-21 18:30:42 +02:00
3b79a880ae feat: custom attributes sync; update: default User model 2021-06-21 18:24:30 +02:00
14b47b6f6e Update 'composer.json' 2021-06-21 18:13:19 +02:00
eda52c3d65 Update 'README.md' 2021-06-21 18:11:25 +02:00
4 changed files with 16 additions and 8 deletions

View File

@@ -7,9 +7,6 @@ The Bluesquare Connect package allows you to use its OAuth server and sync its r
Update your `composer.json`: Update your `composer.json`:
``` ```
"require": {
"bluesquare/laravel-connect": "dev-master"
}
"repositories": [ "repositories": [
{ {
"type": "vcs", "type": "vcs",
@@ -21,7 +18,7 @@ Update your `composer.json`:
Install the package: Install the package:
```bash ```bash
composer update bluesquare/laravel-connect composer require bluesquare/laravel-connect "1.2"
``` ```
Finally, update your `.env` with your client's credentials: Finally, update your `.env` with your client's credentials:

View File

@@ -35,8 +35,8 @@
} }
}, },
"require": { "require": {
"guzzlehttp/guzzle": "^7.2", "guzzlehttp/guzzle": "^7.3",
"php": "^7.2" "php": "^7.3|^8.0"
}, },
"prefer-stable": true "prefer-stable": true
} }

View File

@@ -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

View File

@@ -20,7 +20,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 +46,9 @@ trait HasConnectSync
{ {
return $record->forceDelete(); return $record->forceDelete();
} }
public function getConnectFillableAttributes()
{
return $this->fillable;
}
} }