diff --git a/app/Jobs/Account/CreateAccount.php b/app/Jobs/Account/CreateAccount.php index daf79f32811e..4dc50f4a2ace 100644 --- a/app/Jobs/Account/CreateAccount.php +++ b/app/Jobs/Account/CreateAccount.php @@ -81,8 +81,6 @@ class CreateAccount $sp794f3f->account_sms_verified = false; } - // $sp794f3f->trial_started = now(); - // $sp794f3f->trial_plan = 'pro'; } $sp794f3f->save(); diff --git a/app/Libraries/MultiDB.php b/app/Libraries/MultiDB.php index 8b9f2a4d5764..2b6274345d3e 100644 --- a/app/Libraries/MultiDB.php +++ b/app/Libraries/MultiDB.php @@ -310,7 +310,24 @@ class MultiDB self::setDB($current_db); - return false; + return null; + } + + public static function findAndSetDbByShopifyName($shopify_name) :?Company + { + $current_db = config('database.default'); + + foreach (self::$dbs as $db) { + if ($company = Company::on($db)->with('tokens')->where('shopify_name', $shopify_name)->first()) { + self::setDb($db); + + return $company; + } + } + + self::setDB($current_db); + + return null; } public static function findAndSetDbByAccountKey($account_key) :bool @@ -413,7 +430,7 @@ class MultiDB self::setDB($current_db); - return false; + return null; } public static function findAndSetDbByDomain($query_array) diff --git a/app/Models/User.php b/app/Models/User.php index 9fd05311598c..aa578900d31d 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -203,6 +203,7 @@ class User extends Authenticatable implements MustVerifyEmail 'custom_value3', 'custom_value4', 'is_deleted', + 'shopify_user_id', // 'oauth_user_token', // 'oauth_user_refresh_token', ]; diff --git a/composer.json b/composer.json index df88a3d8e6e9..adf2e9cbe051 100644 --- a/composer.json +++ b/composer.json @@ -81,6 +81,7 @@ "sentry/sentry-laravel": "^3", "setasign/fpdf": "^1.8", "setasign/fpdi": "^2.3", + "shopify/shopify-api": "^4.3", "socialiteproviders/apple": "^5.2", "socialiteproviders/microsoft": "^4.1", "sprain/swiss-qr-bill": "^3.2", diff --git a/composer.lock b/composer.lock index 442dcfbcd1b6..71488b238373 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8c21eb3ea2c2baeecb223d5fdbc8423c", + "content-hash": "c5abc776f4fd59ba436de99f6c401429", "packages": [ { "name": "adrienrn/php-mimetyper", @@ -9342,6 +9342,69 @@ ], "time": "2023-02-09T10:38:43+00:00" }, + { + "name": "shopify/shopify-api", + "version": "v4.3.0", + "source": { + "type": "git", + "url": "https://github.com/Shopify/shopify-api-php.git", + "reference": "80cde593a69acb9b9095235fa8f7748e9389294c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Shopify/shopify-api-php/zipball/80cde593a69acb9b9095235fa8f7748e9389294c", + "reference": "80cde593a69acb9b9095235fa8f7748e9389294c", + "shasum": "" + }, + "require": { + "doctrine/inflector": "^2.0", + "ext-json": "*", + "firebase/php-jwt": "^5.2 || ^6.2", + "guzzlehttp/guzzle": "^7.0", + "php": "^7.4 || ^8.0 || ^8.1", + "psr/http-client": "^1.0", + "psr/log": "^1.1 || ^2.0 || ^3.0", + "ramsey/uuid": "^4.1" + }, + "require-dev": { + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "^9", + "squizlabs/php_codesniffer": "^3.6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Shopify\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Shopify Inc.", + "email": "dev-tools-education@shopify.com" + } + ], + "description": "Shopify API Library for PHP", + "keywords": [ + "Storefront API", + "admin api", + "app", + "graphql", + "jwt", + "node", + "rest", + "shopify", + "webhook" + ], + "support": { + "issues": "https://github.com/Shopify/shopify-api-php/issues", + "source": "https://github.com/Shopify/shopify-api-php/tree/v4.3.0" + }, + "time": "2023-04-12T15:42:26+00:00" + }, { "name": "smalot/pdfparser", "version": "v0.19.0", diff --git a/database/migrations/2023_05_03_023956_add_shopify_user_id.php b/database/migrations/2023_05_03_023956_add_shopify_user_id.php index bb56f8e69420..8accbea0ea9b 100644 --- a/database/migrations/2023_05_03_023956_add_shopify_user_id.php +++ b/database/migrations/2023_05_03_023956_add_shopify_user_id.php @@ -27,13 +27,15 @@ return new class extends Migration }); - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Illuminate\Database\Schema\Blueprint $table) { $table->unsignedInteger('shopify_user_id')->index()->nullable(); }); + Schema::table('companies', function(Illuminate\Database\Schema\Blueprint $table){ + $table->string('shopify_name')->index()->nullable(); + }); - //902541635 } /**