diff --git a/.gitignore b/.gitignore index 3d72576..97c270a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .DS_Store -.idea \ No newline at end of file +.idea +/vendor +/composer.lock \ No newline at end of file diff --git a/composer.json b/composer.json index eb5f456..18d92f6 100755 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "homepage": "https://github.com/dcblogdev/laravel-dropbox", "keywords": ["Laravel", "Dropbox"], "require": { - "illuminate/support": "^5.5|^5.6|^5.7|^5.8|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/support": "^8.0|^9.0|^10.0", "guzzlehttp/guzzle": "^6|^7" }, "autoload": { diff --git a/src/Dropbox.php b/src/Dropbox.php index 27d78ce..b5f95b2 100755 --- a/src/Dropbox.php +++ b/src/Dropbox.php @@ -2,6 +2,7 @@ namespace Dcblogdev\Dropbox; +use Carbon\Carbon; use Dcblogdev\Dropbox\Facades\Dropbox as Api; use Dcblogdev\Dropbox\Models\DropboxToken; use Dcblogdev\Dropbox\Resources\Files; @@ -171,8 +172,7 @@ public function getAccessToken($returnNullNoAccessToken = null) if (isset($token->refresh_token)) { // Check if token is expired // Get current time + 5 minutes (to allow for time differences) - $now = time() + 300; - if ($token->expires_in <= $now) { + if ($token->expires_in->lessThan(Carbon::now()->addMinutes(5))) { // Token is expired (or very close to it) so let's refresh $params = [ 'grant_type' => 'refresh_token', diff --git a/src/Models/DropboxToken.php b/src/Models/DropboxToken.php index 64f9555..7e7896d 100755 --- a/src/Models/DropboxToken.php +++ b/src/Models/DropboxToken.php @@ -7,4 +7,8 @@ class DropboxToken extends Model { protected $guarded = []; + + protected $casts = [ + 'expires_in' => 'datetime', + ]; }